Page 1 of 1
lua music player
Posted: 21 Sep 2007, 14:49
by BigHead
Skip to the next post for info on music player.
Old thread name: call-out request: PlayOggFile(yes I want to make a music w.)
I know that AF tried to make a music player for Spring as a groupAI but complained about the lack of data avaliable to groupAIs. What he did is a good workaround but not a good solution.
Today I woke up and reallized (really, that's how it happened) that lua has all the necessary call-ins and call-outs to make a perfect music widget. However it's still missing one crucial call-out: PlayOggFile. I prefer the ogg format becouse:
- it's more modern than mp3 (smaller files)
- it has no license issues (I know there are some with mp3 but not sure what)
- it's open source so all you need to do is some copy&pasting (== joke, I know it's not easy and that I'm asking for a lot

)
API:
PlayOggFile(filename, [volume, x, y, z]) -> soundLength, oggID
StopOgg(oggID, [fadeOutTime]) -> nil
PlaySoundFile can be used as a substitute for PlayOggFile before it's implemented so I can just convert mp3s from AFs musicAI into low-bitrate wavs and start working on the widget right now. All I need is a positive reply that the call-out will be implemented in the next release.
What do you think?
Edit: Btw StopSound(soundID) for the current PlaySoundFile would be useful as well.
Posted: 30 Sep 2007, 17:22
by BigHead
Lua music player:
More appropriate name for this widget would be: Low quality lua "mp3" player.
I made this player as a substitute until lua is given some serious music-playing capabilities. However my request was ignored so I'm releasing it as it is. If you're a lua scripter check out how I achieved pause/stop/next function using PlaySoundFile() which doesn't support it. You'll propably LOL. Otherwise don't bother downloading it.
Install:
Copy your mp3's to LuaUI/music folder (OTA music from dynamic music AI is recommended).
Run convertAll.bat in the same folder.
Start spring, music should start playing immediately.
Supported commands:
/luaui play
/luaui pause
/luaui stop
/luaui next
Download:
http://www.unknown-files.net/3579/lua_music_player/
Posted: 30 Sep 2007, 17:36
by BrainDamage
haskish solution is hackish!

yeah, chunking files so you use the file name as seek position is really kind of sad, too bad spring doesn't support a more proper solution
---------------------------------------------
may i sugest you to start adding a sort of even-driven playlist?
eg.
naval battles: triggered when 30%+ of army ships have attack orders
air raid: 50%+ of the bombers have attack orders
expansion: no battles under run
superweapon: stockpiled weapon is firing
custom events: mod-defined callable by widgets API interface
Posted: 30 Sep 2007, 17:51
by AF
To be precise this isnt an mp3 player at all.
Its a .wav player, so be warned the mp3 OTA soundtrack of 20-40MB will balloon into a folder of several hundred megabytes of wav files.
Posted: 30 Sep 2007, 18:02
by BigHead
Brain Damage: Good suggestions. However the sound output is too crappy to use it as the basis of a serious dynamic music widget.
AF: Name of the thread is lua music player as well as the name of the file at UF. I've corrected the post to show music instead of mp3 as well.
Size of the wav files after conversion is 42MB (mp3s: 30MB).
Posted: 30 Sep 2007, 20:46
by AF
I take it the reason the file size increase is so small is due to the quality of the wav files?
Posted: 30 Sep 2007, 20:52
by BrainDamage
he downsampled the wavs from 44.1 KHz to 11.2 KHz, hence he reduced the side to 1/4 towards "normal" wavs
the loss of quality is obviously huge, but without an proper codec compression i guess there isn't much else you can do (besides not downsampling them

)
Posted: 30 Sep 2007, 22:29
by jK
However my request was ignored so I'm releasing it as it is.
The request isn't new and you will find 100% more than two posts in this forum about it.
Also trepan already said why it isn't supported yet. Here again:
Spring uses 2 different sound systems, OpenAL and DirectSound (under m$). As trepan is using linux, he has no interests to spend time on the second one. He is only willing to add mp3 support for OpenAl, but as long as not both sound systems have such a support it would be useless ...
Note: because you already convert mp3s to wav, you can start iirc any program with luaUI, so you can also give command params to winamp or any other (lightweight) mp3 player

Posted: 01 Oct 2007, 09:25
by BigHead
I should have searched the forum before posting the request. However you knew the answer so you could have at least told me that it's been discussed before.
Now back on topic.
you can start iirc any program with luaUI
That's great news. There must be some command line mp3 player avaliable so it's possible to make full-quality lua music player after all. I have one question. How do I start a program from lua? I know your knowledge of spring lua is very good so you can propably help me.
In other news. I upgraded this widget into a simple dynamic music player. It starts playing battle music on these events:
- Your unit anywhere on the map takes damage.
- Allied unit in the view takes damage.
- You issue an attack order (attack, area_attack, fight)
... and it works very well

I'll upload it after some testing.
Posted: 01 Oct 2007, 22:43
by jK
Posted: 01 Oct 2007, 23:30
by BrainDamage
you could use
mplayer it's primary a movie player, but works great for audio too, and it's cross platform, it's only a bit heavy in the size (9 MB), but takes basically no cpu here ( < 0.1% while playing music files) and self contains all necessary codecs
while you might have to ship the exec for windows installations, you can pretty much assume linux distros already ship it or provide all the facilities to install it easily
run in
slave mode and it will accept commands from stdin instead of key bindings
Posted: 02 Oct 2007, 12:44
by BigHead
jK: Thanks, I was looking at that page yesterday but missed that method somehow.
Brain Damage: I have a problem with mplayer.
Re: lua music player
Posted: 28 Mar 2008, 10:02
by BlueTemplar
Could someone please upload it? Thank you.
Re: lua music player
Posted: 31 Mar 2008, 01:26
by LOrDo
Re: lua music player
Posted: 31 Mar 2008, 01:45
by BlueTemplar
If I'm asking for this one, it's because I can't use the other on my current computer.