sounds
Forum rules
This is a sub-forum for things specific to MicroMacro.
This is not the place to ask questions about the RoM bot, which uses MicroMacro. There is a difference.
This is a sub-forum for things specific to MicroMacro.
This is not the place to ask questions about the RoM bot, which uses MicroMacro. There is a difference.
- Administrator
- Site Admin
- Posts: 5313
- Joined: Sat Jan 05, 2008 4:21 pm
Re: sounds
Yeah, unfortunately, printing the \a (alarm) character is the (currently) only sound available. I intend to allow for a full sound system eventually. If I get some time tomorrow (as I might hopefully only have a half day, assuming that these 2 other clients of mine don't need anything done), I might be able to quickly implement some code to allow for more control over the internal speaker (pretty much just like \a, except it allows you to set the frequency and duration...pretty much similar to a MIDI, but for the internal speaker). I'll look into finding a library for playing audio files, but I have very specific requirements (most importantly, it must be very light-weight).
Re: sounds
Thanks for the very fast reply.
I see a few projects on the internet for sound integration into Lua. I don't think sound was ever an intention for LUA I guess. My lack of fully understanding of LUA and how MicroMacro, or even any language, Integrates the LUA engine shows my newbness here. But could I integrate one of these projects myself without any changes to MicroMacro?
BTW- I think MicroMacro is absolutely fantastic. I've been a big fan of AutoIt, but let me tell you, MicroMacro really ups the level on AutoIt. I am also really beginning to dig the LUA language.
I see a few projects on the internet for sound integration into Lua. I don't think sound was ever an intention for LUA I guess. My lack of fully understanding of LUA and how MicroMacro, or even any language, Integrates the LUA engine shows my newbness here. But could I integrate one of these projects myself without any changes to MicroMacro?
BTW- I think MicroMacro is absolutely fantastic. I've been a big fan of AutoIt, but let me tell you, MicroMacro really ups the level on AutoIt. I am also really beginning to dig the LUA language.
- Administrator
- Site Admin
- Posts: 5313
- Joined: Sat Jan 05, 2008 4:21 pm
Re: sounds
Well, I've got good news. I now have some code in-place that will load and play WAV audio files using OpenAL.
Here's an example:
Once I've finished this, I'll upload the updated MicroMacro package. Can you think of anything else that will be needed (other than different formats)?
Here's an example:
Code: Select all
function main()
local s = soundLoad("stereo.wav");
soundPlay(s);
rest(200);
soundPause(s);
rest(200);
soundPlay(s);
rest(5000);
end
startMacro(main, true);
Re: sounds
I am not sure what others may find uses for playing sounds. I know my purpose is for an alarm. My specific case is a captcha is displayed while the bot is playing, I need a sound to indicate the bot needs manual intervention.
The only thing I can think of is adjusting the volume.
Great Job!
Thanks!
The only thing I can think of is adjusting the volume.
Great Job!
Thanks!
- Administrator
- Site Admin
- Posts: 5313
- Joined: Sat Jan 05, 2008 4:21 pm
Re: sounds
Ok, I've added per-sound volume control, looping, state-checking, and error logging. That should be just about all that's needed for most purposes.
Functions are:
Functions are:
- soundLoad(filename) - Loads a sound. Make sure you include the proper path (make use of getExecutionPath() if the sound file exists inside the script's folder). Returns a sound resource.
soundPlay(soundresource) - Plays a sound.
soundStop(soundresource) - Stops a sound.
soundPause(soundresource) - Pauses a sound.
soundGetState(soundresource) - Returns the state of a sound as a string ("playing", "paused", "stopped", "initial").
soundSetVolume(soundresource, volume) - Sets the volume for a sound. Volume should between 0 (no sound) and 1.0 (100%). The volume can exceed 1.0 if your sound card supports it (this would effectively make the sound louder, obviously).
soundSetLooping(soundresource, loop) - Sets whether to loop a sound or not. 'loop' should be true or false. You should set this before playing the sound (if you need to change it).
- Attachments
-
- micromacro.zip
- MicroMacro 1.01 beta 4 experimental sound support
- (432.96 KiB) Downloaded 338 times
Re: sounds
Perfect. Took me a few tries. I guess I don't know when the last time I had to worry about escape sequences in strings. I should have realized faster we are dealing with c strings. LOL. Once I dbl escaped the backslash, it all worked.
Great Job!
Great Job!
Re: sounds
This its my code:
And this is the answer:
I try everything I think, but i cant get it works fine. What i'm doing wrong?. Please help me.
Code: Select all
local soundresource = soundLoad(getExecutionPath() .. "/alarm.wav");
....
soundPlay(soundresource);
Code: Select all
bad argument #1 to 'soundPlay' (userdata expected, got nil)
- Administrator
- Site Admin
- Posts: 5313
- Joined: Sat Jan 05, 2008 4:21 pm
Re: sounds
It isn't loading the resource. You probably have it in the wrong directory. Try:
And make sure it is the right directory.
Code: Select all
printf("Sound path: " .. getExecutionPath() .. "/alarm.wav\n");
Re: sounds
I found the problem. I maked an error installing your files (sorry, was my fault. :s).
But i can not get works fine. the command that you gave me, turns
" The file alarm.wav is in the correct folder. In really, I still have the file in every folders. Now the bot works, but this command:
haven't any effect, any sound. The command "soundPlay" doesn't stop the bot. Could you help me?
But i can not get works fine. the command that you gave me, turns
Code: Select all
C:/micromacro/scripts/rom/alarm.wav".
Code: Select all
"soundPlay(soundresource)"
- Administrator
- Site Admin
- Posts: 5313
- Joined: Sat Jan 05, 2008 4:21 pm
Re: sounds
So, what you're saying is you completely disregarded the big blue text at the top of this forum that says this is not the place to discuss RoMbot and decided to do so anyways? You're in the wrong place.
http://www.solarstrike.net/phpBB3/viewforum.php?f=21
http://www.solarstrike.net/phpBB3/viewforum.php?f=21
Re: sounds
oh... I'm terribly sorry, I don't knew it.
Who is online
Users browsing this forum: No registered users and 0 guests