sounds in Algodoo?

About advanced scenes, and the Thyme scripting language used in Algodoo.

sounds in Algodoo?

Postby FLO » Sun Apr 09, 2017 7:06 pm

is it possible to play with thyme scripting in Algodoo sounds?
I make mainly games.
best games
best game engine
User avatar
FLO
 
Posts: 12
Joined: Thu Aug 18, 2016 5:11 pm
Location: germany

Re: sounds in Algodoo?

Postby Kilinich » Sun Apr 09, 2017 11:33 pm

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...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

Re: sounds in Algodoo?

Postby FLO » Fri Jun 16, 2017 4:53 pm

Ok
I make mainly games.
best games
best game engine
User avatar
FLO
 
Posts: 12
Joined: Thu Aug 18, 2016 5:11 pm
Location: germany

Re: sounds in Algodoo?

Postby Supertrain12 » Sun Sep 17, 2017 9:29 pm

One word:
Impossible.
Lol.
User avatar
Supertrain12
 
Posts: 6
Joined: Thu Jul 13, 2017 7:11 pm

Re: sounds in Algodoo?

Postby s_noonan » Fri Nov 24, 2017 8:38 am

AlgoSound

    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:

      Notes:
    1. Only one program ("runVbAlgoSound.bat" or "pyAlgoSound_04.py"), depending on the PC operating system, is needed to use AlgoSound.
    2. 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.

      Windows:
    • 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.


      Other operating systems:
    • 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.


      Adding sound to your own scene:
    • 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.

AlgoSound Features and Benefits:

    vbAlgoSound:

      Pros:
    • 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

      Cons:
    • Works only in Windows

    pyAlgoSound:

      Pros:
    • 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

      Cons:
    • 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.


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)

      If Item1 = someSoundFile(.wav,.mp3,.mid) Then
        scene.my.playSound("filename,[numberOfPlays],[volume]",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)

      If Item1 = "tone" Then
        scene.my.playSound("tone,leftFrequency,rightFrequency,duration,[volume]",channel)
      • [] 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)

      If Item1 = "midi" Then
        scene.my.playSound("midi,midiNoteNum,duration,[volume],[instrument]",channel)
      • [] 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)

      If Item1 = "speak" Then
        scene.my.playSound("speak,text to be spoken,[voice],[volume]",channel)
      • [] 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)

    How it works:

    1. Start "runVbAlgoSound.bat" or "pyAlgoSound_04.py"
    2. Start an Algodoo scene.
    3. AlgoSound creates a "snd" + n + ".txt" file for each channel, where "n" is the channel number. Each file contains a single semicolon.
    4. If Algodoo sees a single semicolon in the file, then it writes the sound parameters to the file.
    5. 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.
    6. AlgoSound creates temporary files in the AlgoSound folder. Deleting those files won't hurt anything.


    Change Log:

    1. _01 Initial release
    2. _02 Added text to speech
    3. _03 Speech text now handles commas
    4. _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: 57
Joined: Tue Mar 30, 2010 2:25 am

Re: sounds in Algodoo?

Postby JakubKubo » Tue Jan 02, 2018 1:25 am

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) ?
JakubKubo
 
Posts: 18
Joined: Thu Mar 12, 2015 6:27 pm

Re: sounds in Algodoo?

Postby s_noonan » Thu Jan 04, 2018 10:30 am

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).
s_noonan
 
Posts: 57
Joined: Tue Mar 30, 2010 2:25 am

Re: sounds in Algodoo?

Postby JakubKubo » Sun Jan 07, 2018 1:51 am

scene.my.playSound("speak,I finally made it steve,0,90", 0)
:clap:
JakubKubo
 
Posts: 18
Joined: Thu Mar 12, 2015 6:27 pm

Re: sounds in Algodoo?

Postby s_noonan » Sun Jan 07, 2018 2:42 pm

Good. I'm glad it worked out for you.
s_noonan
 
Posts: 57
Joined: Tue Mar 30, 2010 2:25 am

Re: sounds in Algodoo?

Postby hpstricker » Fri Jan 12, 2018 11:45 am

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
hpstricker
 
Posts: 16
Joined: Wed Jan 03, 2018 11:10 am

Re: sounds in Algodoo?

Postby s_noonan » Thu Jan 18, 2018 12:10 pm

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.
s_noonan
 
Posts: 57
Joined: Tue Mar 30, 2010 2:25 am

Re: sounds in Algodoo?

Postby hpstricker » Thu Jan 18, 2018 5:59 pm

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.)
hpstricker
 
Posts: 16
Joined: Wed Jan 03, 2018 11:10 am

Re: sounds in Algodoo?

Postby hpstricker » Thu Jan 18, 2018 6:03 pm

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?

Postby s_noonan » Sat Jan 20, 2018 1:13 pm

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.
s_noonan
 
Posts: 57
Joined: Tue Mar 30, 2010 2:25 am

Re: sounds in Algodoo?

Postby Xray » Sat Jan 27, 2018 10:54 pm

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.
User avatar
Xray
 
Posts: 484
Joined: Sun Jun 17, 2012 6:12 am
Location: USA

Re: sounds in Algodoo?

Postby s_noonan » Mon Jan 29, 2018 12:00 pm

Xray,

Thanks for the feedback. I used your suggestion to modify the Overview and Quick Start notes.
s_noonan
 
Posts: 57
Joined: Tue Mar 30, 2010 2:25 am

Re: sounds in Algodoo?

Postby izzy1794 » Sat Aug 24, 2019 9:34 am

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


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 1 guest