forum

[Coding] osbpy

posted
Total Posts
20
Topic Starter
Wafu
The thread is outdated and most things aren't going to work, better refer to osbpy wiki, it explains everything, has examples and is written for updated version of osbpy.

Hello everyone. I'm here to present you my new project called osbpy. You probably heard about SGL and maybe made a storyboard in it. I even created a guide for using it. However, it's not a real programming language, therefore you cannot do anything you want, you can't even import basic libraries. Experimenting with it for long time inspired me to make something simplier, more powerful and fully customizable.

osbpy is a simple Python file (some may call it library) that contains all storyboard functions listed here and here. That basically allows you to use all functions in SGL with much more freedom as you're only limited with Python, which is really wide. At the top of that, it contains spectrum function - because you have access to everything, it'll allow you to do things like this, it also can adjust maximum height and minimum height, so for loud songs, it wouldn't jump like insane and for quiet songs, it would still be pretty visible.
As I already mentioned, osbpy is coded in Python. That requires you to have it installed. Apart from that, you'll need some libraries to make it work, you can install them with few steps. Please, mention that osbpy is coded for Python 3.5.1, some features may not work on older versions or in new releases.

First of all, download Python from their official website. Install it, preferably with default settings, "Add Python 3.5 to PATH" must be ticked! If using custom installation, leave pip installed too.

After Python is installed, we'll need to install all libraries that osbpy is using. First one will be Numpy, which is mathematical library which is required by other libraries we are using. You can get numpy here. Be aware you need +MKL version (vanilla won't work with scipy) and be sure it is cpxx fits your version of python, we have 3.5, so it must be cp35, 32bit/64bit version must fit your Python too!

Another library you need is scipy, this is to load audio files so another library can work with it properly. Lastly, you need matplotlib, which is another mathematical library, which allows you to make graphs - these are very useful to obtain spectrogram data etc.

All libraries are available here for Windows, both 32 and 64bit versions:
  1. Mediafire
  2. Baidu
  3. Mega
After downloading numpy, matplotlib and scipy for your version of Python, open up a command prompt. That can be done by using WindowsKey+R, typing in 'cmd' (without quotation marks) and pressing enter. Or you may find it if you simply press WindowsKey and write 'Command Prompt'. You have to install the Wheel (.whl) files. This is why unticking pip in Python installation would break everything, it's here to install them. To install them, just simply write 'pip install nameofpackage.whl' - You're most likely not in the same folder, so you need full path to the whl file. You can just write 'pip install ' and then drag the file into command prompt window, it will put in the whole path. At the end, you should run only three commands similar to those below.
pip install C:\Users\Wafu\Downloads\numpy-1.10.4+mkl-cp35-none-win32.whl
pip install C:\Users\Wafu\Downloads\matplotlib-1.5.1-cp35-none-win32.whl
pip install C:\Users\Wafu\Downloads\scipy-0.17.0-cp35-none-win32.whl
Path will differ depending on where you saved the files and which version did you download. For Python 3.5.1, if you installed it from scratch, it should install them properly and you'll be ready to go!
Usage of osbpy is not difficult at all. Download osbpy and extract it into folder where you plan to have code files for your storyboards.

Now to make storyboard code, you need some basic programming skills. If you don't know Python, I recommend you to check out some tutorials or Codecademy, it's really cool if you want to learn basics of Python quickly. After all, everything you'll need to know are loops anyway. Python is very simple language and anyone can learn it in few days if he was never programming before.

Now, you have two options, edit osbpy.py directly and manage everything on your own. However, I don't recommend this - You may experiment with the code, but doing it unless you are unexperienced won't bring you anything good. Easier way would be importing the file. That means, you need some text editor, it may be for example Sublime Text, but you can run it even in simple Notepad. Please note that once you save a file as .py, you can right click it and "Edit with IDLE" will appear. If you want to have a little bit better view, edit your file with this - good thing is you can even run file with it if you press F5. To import the file, just simply save it in same folder as osbpy.py and put this line at the start of your file:
from osbpy import *
This imports osbpy into your code so you can use all the commands. Now, the main code comes in, you are free to use all of following commands + regular Python:
There is list of all objects definited. It's called obj. Each object has its index (number) and then commands. First, you start with defining whether it's animation or static sprite:

obj[index] = stat(path,layer,origin,posX,posY)
obj[index] = anim(path,layer,origin,posX,posY,framecount,framerate,loop)

Green ones must be string, strings have quotation marks, like "this is random text". Index can be any number, e.g. obj[0] = ... However, if building spectrum, reserve first indexes depending on how many bars do you want, otherwise you'll overwrite spectrum or your old objects. For example if you want 20 spectrum bars, put your first object on obj[21] etc.
  1. path = Where the file is stored, for example "SB/image.png"
  2. layer = "Background","Fail","Pass","Foreground"
  3. origin = "TopLeft","TopCentre","TopRight","CentreLeft","Centre","CentreRight","BottomLeft","BottomCentre","BottomRight"
  4. posX, posY - Position on X and Y axis
  5. framecount - How many frames does the animation have. e.g. if you use 3, it will loop image0.png, image1.png and image2.png
  6. framerate - How many ms does it take to change between frames
  7. loop = "LoopForever","LoopOnce"
Each object can be manipulated with after creating it, that can be done with these commands:

please note that you need to merge it with certain object in objects, use += instead of =

obj[index] += fade(easing,startTime,endTime,startFade,endFade,loop)
  1. easing = Determines speed changes of the action, put in number easing
  2. startTime - Self explanatory, when do you want the action to start in ms
  3. endTime - When do you want the action to end in ms
  4. startFade - Fade value at start (0.0 - 1.0)
  5. endFade - Fade value at end
  6. loop = Type in just True of False, depending on whether it's part of loop. This must be true for objects which come trigger() or loop(), if you use False, it will end trigger() or loop(). If empty (recommended unless you use trigger()/loop()), it's set to False.
All other commands work very similarly, they have easing, startTime+endTime and then start and end values. You should be able to realize from example above.

move(easing,startTime,endTime,startmoveX,startmoveY,endmoveX,endmoveY,loop)
moveX(easing,startTime,endTime,startmoveX,endmoveX,loop)
moveY(easing,startTime,endTime,startmoveY,endmoveY,loop)
scale(easing,startTime,endTime,startScale,endScale,loop)
vecscale(easing,startTime,endTime,startscaleX,startscaleY,endscaleX,endscaleY,loop)
rotate(easing,startTime,endTime,startRotate,endRotate,loop)
color(easing,startTime,endTime,startR,startG,startB,endR,endG,endB,loop)
para(easing,startTime,endTime,parameter)
  1. parameter = "H" - Horizontal Flip, "V" - Vertical Flip, "A" - Additive
loop(startTime,loopCount)
  1. loopCount - How many times do you want actions in the loop to repeat
  2. Actions that should be in this loop must have loop set to True
trigger(trigger, startTime,loopCount)
  1. Actions that should be triggered must have loop set to True
  2. trigger - There are many trigger options, please refer to wiki
spectrum(wav_file,mi,mx,har,start,end,posX,posY,layer,origin,gaparrange,radius,sinheight)
  1. wav_file = Path to the song in .wav format. You can obtain it by simply converting the mp3 in Audacity to .wav or you may use original .wav.
  2. mi = Sets minimum scale to number you choose, that's here so many bars are not scaled to 0, this makes it usable for quiet songs
  3. mx = Sets maximum scale to number you choose, that's so you don't have very huge jumps, this makes it usable for loud songs
  4. har = Count of bars you want to generate
  5. start = Start time in ms
  6. end = End time in ms
  7. gap = How big gap should be between each bar (doesn't afflict spacing for circular pattern)
  8. posX = Explained for other commands
  9. posY = Explained for other commands
  10. layer = Explained for other commands
  11. origin = Explained for other commands
  12. arrange = "circle" or "sinus", if ignored, uses linear spectrum
  13. radius = Changes circle size or width of sinus
  14. sinheight = Changes height of sinus
Call spectrum by only spectrum(...), don't add obj[index] ... as spectrum is added to sprites by itself

When your code is done, you need to save data to some file. Put this line at the end of your code:

end("anyfileyouwant.osb")

For more reference, wiki can help you too, if you don't know what values are acceptable. If you want to report issue, be sure to PM me or use GitHub
Feel free to ask me anything you need, I'll be always here to help you out. I'll be sharing all my storyboard codes here, just so you have some examples.
XinCrin
I already have a class in java to make my storyboards but I think it would be useful to start learning python, a great motivation. Good job! :)
Topic Starter
Wafu

XinCrin wrote:

I already have a class in java to make my storyboards but I think it would be useful to start learning python, a great motivation. Good job! :)
Main reasons of using Python was because the spectrum takes me like 7 seconds to generate for 4 minutes long song + its compability with multiple systems is insane. Some guy may just come, take Flask, implement parsing and ayy, we have web version. For Java, using applets would be funny, so this can be run under many circumstances :)
arviejhay
0 - Linear: no easing
1 - Easing Out: the changes happen fast at first, but then slow down toward the end
2 - Easing In: the changes happen slowly at first, but then speed up toward the end
3 - Quad In
4 - Quad Out
5 - Quad In/Out
6 - Cubic In
7 - Cubic Out
8 - Cubic In/Out
9 - Quart In
10 - Quart Out
11 - Quart In/Out
12 - Quint In
13 - Quint Out
14 - Quint In/Out
15 - Sine In
16 - Sine Out
17 - Sine In/Out
18 - Expo In
19 - Expo Out
20 - Expo In/Out
21 - Circ In
22 - Circ Out
23 - Circ In/Out
24 - Elastic In
25 - Elastic Out
26 - ElasticHalf Out
27 - ElasticQuarter Out
28 - Elastic In/Out
29 - Back In
30 - Back Out
31 - Back In/Out
32 - Bounce In
33 - Bounce Out
34 - Bounce In/Out
woah, i didn't know easing can be up to 34. lel
Topic Starter
Wafu

arviejhay wrote:

woah, i didn't know easing can be up to 34. lel
I rarely see someone using different easng than 0,1,2, but some of others are surprisingly great.
arviejhay
mine, when i enter pip install [path], i got red text message
is that suppose to be an error?
Topic Starter
Wafu
Can you screenshot/copy the message? Red usually means error, yellow just a warning.
arviejhay
sheela

arviejhay wrote:

https://www.dropbox.com/s/klbnzr1m0r6u1pb/Captureaaaa.PNG?dl=0
Try updating pip by using the command said. Also, from what I see, if you have Python 32-bit, you'll need to download and install the 32-bit wheels / files.
Topic Starter
Wafu

arviejhay wrote:

https://www.dropbox.com/s/klbnzr1m0r6u1pb/Captureaaaa.PNG?dl=0
You may upgrade the pip, but this has no effect on it however. The wheels are compatible with older pip. Anyway, you installed 32bit Python, and the .whl files are 64bit, that's why it throws an error. Be aware that amd64 stands for version of Python, you need 32 for this. No matter whether yours system is 32 or 64 bit, you need to use what fits the Python version. So, just get the wheels with _win32 at the end. Or uninstall Python and install the 64bit version of it.
CSLM
It looks interesting, i'll probably look at it
Very nice
arviejhay

Wafu wrote:

You may upgrade the pip, but this has no effect on it however. The wheels are compatible with older pip. Anyway, you installed 32bit Python, and the .whl files are 64bit, that's why it throws an error. Be aware that amd64 stands for version of Python, you need 32 for this. No matter whether yours system is 32 or 64 bit, you need to use what fits the Python version. So, just get the wheels with _win32 at the end. Or uninstall Python and install the 64bit version of it.
Thank you! :D, i should uninstall python 32 instead.
-[Cow]-
Python 3.4 support please
Ferret
I run locally some bots that require python 3.5 but it seems that this library doesn't support it. Am I wrong? :o
Topic Starter
Wafu
The only difference should be that you need to install specific libraries like matplotlib, scipy etc. for that Python version. Otherwise it should work.
Ferret

Wafu wrote:

The only difference should be that you need to install specific libraries like matplotlib, scipy etc. for that Python version. Otherwise it should work.
I'm going to try then, haven't got too much time to do SB anyway, your lib sounds great to just ignore it
Flowey

Wafu wrote:

The only difference should be that you need to install specific libraries like matplotlib, scipy etc. for that Python version. Otherwise it should work.
Correct me if I'm wrong, but the only thing that uses those extra libraries is spectrum right? So if you're not using the spectrum feature, you could just delete that portion from the file and not worry about libraries, right?
Topic Starter
Wafu

Nephroid wrote:

Correct me if I'm wrong, but the only thing that uses those extra libraries is spectrum right? So if you're not using the spectrum feature, you could just delete that portion from the file and not worry about libraries, right?
Of course. Removing some of imports and whole spectrum function would work correctly.
Drum-Hitnormal
Hi wafu,

I am currently working on similar project in java.
I imagine it would be good to have more custom effects like spectrum created for user who only need to set the default parameters.
it would be like using sony vegas or after affects. and user could also code own effect using basic classes already made.
Ultimately it would be able to generate SB based on hitsound, user can map many effects to each unique sound and program will parse osu file into osb with set parameters. if you are interested i can share you the source code i have so far
-[Cow]-
When C#?
Please sign in to reply.

New reply