sounds in Algodoo?
19 posts • Page 1 of 1
sounds in Algodoo?
is it possible to play with thyme scripting in Algodoo sounds?
-
FLO - Posts: 16
- Joined: Thu Aug 18, 2016 5:11 pm
- Location: germany
Re: sounds in Algodoo?
FLO wrote:is it possible to play with thyme scripting in Algodoo sounds?
There was some external app for that and that feature was planned but never released
Dream of Algodoo as game development engine...
-
Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
Re: sounds in Algodoo?
AlgoSound
AlgoSound Features and Benefits:
Developer SDK:
- Overview:
- AlgoSound adds sound capability to Algodoo scenes. It does this by using either a vbSript or a Python program to read and play sound requests sent to text files from an Algodoo scene. Each text file represents a channel of sound, allowing multiple sounds to play concurrently. In operation, the vbSript or a Python program runs at the same time as the scene that uses AlgoSound.
- Installation:
- Only one program ("runVbAlgoSound.bat" or "pyAlgoSound_04.py"), depending on the PC operating system, is needed to use AlgoSound.
- After you execute "runVbAlgoSound.bat" or "pyAlgoSound_04.py", a "command" window will open. Keep that window open (minimized is OK) while running an Algodoo sound scene in order to hear sound.
- Unzip "AlgoSound.zip" file in the Algodoo working folder (typically "C:\Users\SomeUser\Documents\Algodoo").
"runVbAlgoSound.bat", "vbAlgoSound_04.vbs", and "pyAlgoSound_04.py" should end up in "C:\Users\SomeUser\Documents\Algodoo\AlgoSound"
- Delete "pyAlgoSound_04.py".
- Unzip "sounds.zip" file in the Algodoo working folder (typically "C:\Users\SomeUser\Documents\Algodoo").
All sound files should end up in "C:\Users\SomeUser\Documents\Algodoo\sounds"
- Double-click "runVbAlgoSound.bat". Disregard the warning when running runVbAlgoSound.bat the first time. This warning is expected since the program does read and write text files when running.
- Run AlgoSound Test Utility to see how it works.
- Unzip "AlgoSound.zip" file in the Algodoo working folder (typically "C:\Users\SomeUser\Documents\Algodoo").
"runVbAlgoSound.bat", "vbAlgoSound_04.vbs", and "pyAlgoSound_04.py" should end up in "C:\Users\SomeUser\Documents\Algodoo\AlgoSound"
- Delete "runVbAlgoSound.bat" and "vbAlgoSound_04.vbs".
- Unzip "sounds.zip" file in the Algodoo working folder (typically "C:\Users\SomeUser\Documents\Algodoo").
All sound files should end up in "C:\Users\SomeUser\Documents\Algodoo\sounds"
- Download and install Python, pygame, numpy, and gtts. See How To Download And Install Pygame On Python 3.6.0 On Windows 10 if you have any problems. I know the video is for Windows OS, but installation for other OS's is similar.
- Double-click "pyAlgoSound_04.py".
- Run AlgoSound Test Utility to see how it works.
- See How to Install AlgoSound if you run into any problems.
- Run the following code in the Algodoo console
- Code: Select all
scene.my.playSound := (sParams, chan)=>{
sXFile := "snd" + chan + ".txt";
system.ReadWholeFile(sXFile) == ";" ? {
System.WriteToFile(sXFile, sParams)
} : {}
}
- Create a box in Algodoo
- Add the following code to the box's onClick event:
- Code: Select all
scene.my.playSound("speak,Hello world.", 1)
- See "Usage" below for playing different sounds.
- Notes:
- Windows:
- Other operating systems:
- Adding sound to your own scene:
AlgoSound Features and Benefits:
- vbAlgoSound:
- Plays .mp3, .wav, & .mid files
- Generates stereo tones
- Converts text to speech
- Generates and plays midi notes with choice of 128 instruments
- Uses 8 channels
- No added programs are needed
- Works only in Windows
- Pros:
- Cons:
- pyAlgoSound:
- Plays .mp3, .wav, .OGG, & .mid files
- Generates stereo tones
- Converts text to speech
- Generates and plays midi notes with choice of 128 instruments
- Uses 8 channels
- written in Python
- All code is visible
- Works cross platform
- Requires Python, pygame, numpy, and gtts download and installation
- Only supports 1 channel (channel 0) of music (.mp3, .mid, .OGG) The other channels support .wav files.
- Pros:
- Cons:
Developer SDK:
- AlgoSound requires the following function in the Algodoo scene:
- Code: Select all
scene.my.playSound := (sParams, chan)=>{
sXFile := "snd" + chan + ".txt";
system.ReadWholeFile(sXFile) == ";" ? {
System.WriteToFile(sXFile, sParams)
} : {}
}
- Usage: scene.my.playSound("Item1,Item2,Item3,... ",channel)
- [] indicates optional parameter
- numberOfPlays = number of play cycles; -1 = loop, 0 = stop, 1 = 1, 2 = 2..., default = 1
- volume = 1 to 100, default = 100
- channel = channel number; 0 or 1
- Sample1: scene.my.playSound("phunTheme.mp3", 0)
- Sample2: scene.my.playSound("phunTheme.mp3,1,90", 0)
- [] indicates optional parameter
- leftFrequency = frequency out of left speaker
- rightFrequency = frequency out of right speaker
- duration = duration in seconds
- volume = 1 to 100, default = 100
- channel = channel number; 0 or 1
- Sample: scene.my.playSound("tone,440,444,10,5", 1)
- [] indicates optional parameter
- midiNoteNum = midi note number
- duration = duration in seconds
- volume = 1 to 127, default = 127
- instrument = midi instrument; 1 to 128
- Sample: scene.my.playSound("midi,72,1.0,127,1", 1)
- [] indicates optional parameter
- text to be spoken = some text to be spoken
- voice = voice to be used; 0 = male, 1 = female, default = 0
- volume = 1 to 100, default = 100
- channel = channel number; 0 or 1
- Sample: scene.my.playSound("speak,Hello World,0,90", 0)
- If Item1 = someSoundFile(.wav,.mp3,.mid) Then
- scene.my.playSound("filename,[numberOfPlays],[volume]",channel)
- If Item1 = "tone" Then
- scene.my.playSound("tone,leftFrequency,rightFrequency,duration,[volume]",channel)
- If Item1 = "midi" Then
- scene.my.playSound("midi,midiNoteNum,duration,[volume],[instrument]",channel)
- If Item1 = "speak" Then
- scene.my.playSound("speak,text to be spoken,[voice],[volume]",channel)
- How it works:
- Start "runVbAlgoSound.bat" or "pyAlgoSound_04.py"
- Start an Algodoo scene.
- AlgoSound creates a "snd" + n + ".txt" file for each channel, where "n" is the channel number. Each file contains a single semicolon.
- If Algodoo sees a single semicolon in the file, then it writes the sound parameters to the file.
- If AlgoSound sees more than a semicolon in the file, then it gets the sound information, removes it from the file, and then processes the sound information.
- AlgoSound creates temporary files in the AlgoSound folder. Deleting those files won't hurt anything.
- Notes:
- Python, pygame, and numpy download and installation is shown at How To Download And Install Pygame On Python 3.6.0 On Windows 10
- If you create a scene that uses sound, then add an "AlgoSound" Tag to the scene page. This way we can search for all the scenes that use AlgoSound.
- See How to Install AlgoSound.
- Change Log:
- _01 Initial release
- _02 Added text to speech
- _03 Speech text now handles commas
- _04 8 channels was 2. Program now has its own folder.
Last edited by s_noonan on Sat Feb 10, 2018 7:44 am, edited 28 times in total.
- s_noonan
- Posts: 61
- Joined: Tue Mar 30, 2010 2:25 am
Re: sounds in Algodoo?
If i got it right:
1. Put "runVbAlgoSound_01.bat" and "vbAlgoSound_01.vbs" into documents>algodoo (leave "pyAlgoSound_01.py" in ZIP).
Put .mp3, .wav, .OGG, & .mid files there too.
2. Start .bat, then Algodoo.
3. Make new scene, insert this into console:
scene.my.playSound := (sParams, chan)=>{
sXFile := "snd" + chan + ".txt";
system.ReadWholeFile(sXFile) == ";" ? {
System.WriteToFile(sXFile, sParams)
} : {}
}
4. now use script: scene.my.playSound("phunTheme.mp3", 0).....nothing happens
Or is there directory where sounds are? Like scene.my.playSound("sounds/phunTheme.mp3", 0) ?
1. Put "runVbAlgoSound_01.bat" and "vbAlgoSound_01.vbs" into documents>algodoo (leave "pyAlgoSound_01.py" in ZIP).
Put .mp3, .wav, .OGG, & .mid files there too.
2. Start .bat, then Algodoo.
3. Make new scene, insert this into console:
scene.my.playSound := (sParams, chan)=>{
sXFile := "snd" + chan + ".txt";
system.ReadWholeFile(sXFile) == ";" ? {
System.WriteToFile(sXFile, sParams)
} : {}
}
4. now use script: scene.my.playSound("phunTheme.mp3", 0).....nothing happens
Or is there directory where sounds are? Like scene.my.playSound("sounds/phunTheme.mp3", 0) ?
- JakubKubo
- Posts: 18
- Joined: Thu Mar 12, 2015 6:27 pm
Re: sounds in Algodoo?
Q" 1. Put "runVbAlgoSound_01.bat" and "vbAlgoSound_01.vbs" into documents>algodoo (leave "pyAlgoSound_01.py" in ZIP).
Put .mp3, .wav, .OGG, & .mid files there too.
A: No. Everything goes into the Algodoo/sounds folder. If you put the sounds.zip file in the Algodoo folder, and unzip everything, then everything should go automatically in an Algodoo/sounds folder.
Note: "vbAlgoSound_01.vbs" is now "vbAlgoSound_02.vbs"."pyAlgoSound_01.py" is now "pyAlgoSound_02.py","runVbAlgoSound_01.bat" is still "runVbAlgoSound_01.bat".
Steps 2,3, and 4 are OK.
Q: Or is there directory where sounds are? Like scene.my.playSound("sounds/phunTheme.mp3", 0) ?
A: Yes and No. Yes, there is a directory where the sounds are (Algodoo/sounds). No, you don't need to include the directory when calling the sound. Use scene.my.playSound("phunTheme.mp3", 0) not scene.my.playSound("sounds/phunTheme.mp3", 0).
Put .mp3, .wav, .OGG, & .mid files there too.
A: No. Everything goes into the Algodoo/sounds folder. If you put the sounds.zip file in the Algodoo folder, and unzip everything, then everything should go automatically in an Algodoo/sounds folder.
Note: "vbAlgoSound_01.vbs" is now "vbAlgoSound_02.vbs"."pyAlgoSound_01.py" is now "pyAlgoSound_02.py","runVbAlgoSound_01.bat" is still "runVbAlgoSound_01.bat".
Steps 2,3, and 4 are OK.
Q: Or is there directory where sounds are? Like scene.my.playSound("sounds/phunTheme.mp3", 0) ?
A: Yes and No. Yes, there is a directory where the sounds are (Algodoo/sounds). No, you don't need to include the directory when calling the sound. Use scene.my.playSound("phunTheme.mp3", 0) not scene.my.playSound("sounds/phunTheme.mp3", 0).
- s_noonan
- Posts: 61
- Joined: Tue Mar 30, 2010 2:25 am
Re: sounds in Algodoo?
scene.my.playSound("speak,I finally made it steve,0,90", 0)
- JakubKubo
- Posts: 18
- Joined: Thu Mar 12, 2015 6:27 pm
Re: sounds in Algodoo?
Good. I'm glad it worked out for you.
- s_noonan
- Posts: 61
- Joined: Tue Mar 30, 2010 2:25 am
Re: sounds in Algodoo?
I found "Sounds in Algodoo" by user uCriterion usefull and helpfull. It worked out of the box.
http://www.algodoo.com/algobox/details.php?id=67648
http://www.algodoo.com/algobox/details.php?id=67648
- hpstricker
- Posts: 16
- Joined: Wed Jan 03, 2018 11:10 am
Re: sounds in Algodoo?
hpstricker,
I had used "Sounds in Algodoo" by user uCriterion and found it worked well. Regarding "It worked out of the box", I don't understand the comment since my program works the same way. You download and extract a folder named "sounds", double-click a file, and open a scene that demonstrates the sounds. Please correct me if I am missing something. See How to Install AlgoSound.
The difference with with my application is that it is multi-channel, handles multiple sound types, generates tones, generates midi, and does speech to text. The application was written in vbScript to work with Windows (which I suspect you have) and Python (which is cross platform).
The only thing that I can think of that's not "out of the box" is the additional Python modules. Python is not required for Windows OS since the vbScript works on Windows.
I had used "Sounds in Algodoo" by user uCriterion and found it worked well. Regarding "It worked out of the box", I don't understand the comment since my program works the same way. You download and extract a folder named "sounds", double-click a file, and open a scene that demonstrates the sounds. Please correct me if I am missing something. See How to Install AlgoSound.
The difference with with my application is that it is multi-channel, handles multiple sound types, generates tones, generates midi, and does speech to text. The application was written in vbScript to work with Windows (which I suspect you have) and Python (which is cross platform).
The only thing that I can think of that's not "out of the box" is the additional Python modules. Python is not required for Windows OS since the vbScript works on Windows.
- s_noonan
- Posts: 61
- Joined: Tue Mar 30, 2010 2:25 am
Re: sounds in Algodoo?
Maybe I was just overwhelmed by your elaborate first post and mixture of code examples: What I found useful with "Sounds for Algodoo" was: just install and run it, enter ONE line of Thyme code, and you are done.
Having looked closer to your original post, I finally found that I just need ONE line of Thyme code to use "AlgoSound", too. The better!
What YOU should make more clear: That AlgoSound can be used out of the box by just ONE line of Thyme code. (This didn't become clear to me at first reading.)
Having looked closer to your original post, I finally found that I just need ONE line of Thyme code to use "AlgoSound", too. The better!
What YOU should make more clear: That AlgoSound can be used out of the box by just ONE line of Thyme code. (This didn't become clear to me at first reading.)
- hpstricker
- Posts: 16
- Joined: Wed Jan 03, 2018 11:10 am
Re: sounds in Algodoo?
To be honest: the "additional Python modules" DO pose a problem, at least to me (since I'm working under Windows, where Python is not a matter of course).
- hpstricker
- Posts: 16
- Joined: Wed Jan 03, 2018 11:10 am
Re: sounds in Algodoo?
hpstricker,
I appreciate your feedback and will add a "Quickstart" paragraph to the instructions. I think you may have missed a point, the Python program is not required if you you are running Windows. You can delete pyAlgoSound_03.py and just double-click runVbAlgoSound.bat. I agree that the "additional Python modules" DO pose additional effort, when you are using an OS other than windows or choose to run Python in windows.
I appreciate your feedback and will add a "Quickstart" paragraph to the instructions. I think you may have missed a point, the Python program is not required if you you are running Windows. You can delete pyAlgoSound_03.py and just double-click runVbAlgoSound.bat. I agree that the "additional Python modules" DO pose additional effort, when you are using an OS other than windows or choose to run Python in windows.
- s_noonan
- Posts: 61
- Joined: Tue Mar 30, 2010 2:25 am
Re: sounds in Algodoo?
Something which should be mentioned for the sake of dummies like me who initially did something which I should not have done: After you execute the runVbAlgoSound.bat batch file, a "command" window will open, showing the executed code. DO NOT CLOSE THAT WINDOW! If you close it, you will not hear any sounds. You may minimize the window, but don't close it.
-
Xray - Posts: 500
- Joined: Sun Jun 17, 2012 6:12 am
- Location: USA
Re: sounds in Algodoo?
Xray,
Thanks for the feedback. I used your suggestion to modify the Overview and Quick Start notes.
Thanks for the feedback. I used your suggestion to modify the Overview and Quick Start notes.
- s_noonan
- Posts: 61
- Joined: Tue Mar 30, 2010 2:25 am
Re: sounds in Algodoo?
This has worked great, although there is one small hitch - when I pause the scene, the sounds continue to play (I'm using 2-3 minute mp3 files). Is there any way to stop the music upon pausing the scene? Thanks.
- izzy1794
- Posts: 1
- Joined: Sat Aug 24, 2019 9:32 am
Re: sounds in Algodoo?
izzy1794,
Sorry for the late reply. Thanks for downloading and using Algosound.
Q: Is there any way to stop the music upon pausing the scene?
A: I used the following in Gumby Vs Alien Break Dance (with sound)
The code is in the plane (dance floor).
Which program did you use (vbScript or Python)?
Sorry for the late reply. Thanks for downloading and using Algosound.
Q: Is there any way to stop the music upon pausing the scene?
A: I used the following in Gumby Vs Alien Break Dance (with sound)
- Code: Select all
_runOnce := true;
_oldSimRunning := false;
onClick := (e)=>{
scene.my.playSound("stop", 0)
};
postStep := (e)=>{
_runOnce ? {
scene.my.playSound("StayinAlive.mp3", 0);
_runOnce = false
} : {}
};
update := (e)=>{
_oldSimRunning && ! sim.running ? {
scene.my.playSound("stop", 0);
_runOnce = true
} : {};
_oldSimRunning = sim.running
};
The code is in the plane (dance floor).
Which program did you use (vbScript or Python)?
- s_noonan
- Posts: 61
- Joined: Tue Mar 30, 2010 2:25 am
Re: sounds in Algodoo?
Wow, after 3 years I logged in and my post is at the top.
-
FLO - Posts: 16
- Joined: Thu Aug 18, 2016 5:11 pm
- Location: germany
19 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 2 guests