OAL/DS MaxMod Beta Test

BlitzMax Forums/BlitzMax Programming/OAL/DS MaxMod Beta Test

REDi(Posted 2007) [#1]
I've been working on the next version of maxmod that uses both DirectSound and OpenAL depending on which audio driver blitzmax is using at the time...

http://code.google.com/p/maxmod/

unfortunately I'm unable to test this on mac,linux,vista or 64bit, if anybody has a spare few minutes to test it for me I would be very grateful. (I'm expecting problems with endianness (is that right?) ect)

The new version provides a TSampleLoader for the standard loadsound command, and a seperate streaming module. I've also completly changed the command set to be more blitzmax friendly, just call the new CreateAudioStream command and it will return a TChannel for use with the built-in channel commands. (see the documention for examples ect)

Please note that you must change the audio driver to either "OpenAL" or "DirectSound" for streaming to work, the default "FreeAudio" driver will not produce any sound.

one problem at the moment is that I swapped it to using the Pub.DirectX module for directsound support, which has added a bug that should be fixed with the release of blitzmax 1.28, but until then any testers may need to correct line 140 in "pub/directx.mod/dsound.bmx" from this...
Method GetCurrentPosition( pos Var )
to this...
Method GetCurrentPosition(playpos Var, writepos Var)


Please delete any previous version of maxmod first, then extract the archive to your "blitzmax/mod" folder, that will create a "maxmod.mod" folder which contains "modplayer.mod" and "audiostream.mod"

Thanks in advance.


REDi(Posted 2007) [#2]
Thinking about it, are the docs still unreadable on linux?

if they are you may need to load the examples manualy, you'll find them in the docs folders of audiostream.mod and modplayer.mod
obviously you'll also need to change the audio driver in the examples to openal.


JazzieB(Posted 2007) [#3]
I'm expecting problems with endianness

You may only experience this on PPC based Macs. Everything else should be fine. Can't test your mod at the moment though, as I'm at work.


REDi(Posted 2007) [#4]
Cue the tumble weed. LOL.

No worries, public release of this is now dropped, I dont even use this (as is) myself, other than to support mod files in my DJ/Tracker app, which uses a completely different mixer anyway.

No point wasting precious time flogging a dead horse.

Thanks anyway, LOL. :)


Gabriel(Posted 2007) [#5]
You do realize that any replies you had within the past two days have been wiped by the server change, right? I'm not saying I know there were more replies, or how many, just making sure you knew that any replies would be gone.


REDi(Posted 2007) [#6]
http://66.103.20.15/Community/posts.php?topic=74048 ;)

Dont get me wrong, I'm not thowing my toys out the pram!
Just being realistic, If people wanted crossplatform streaming, they would make a effort. if not, neither will I.

(DOH, that still sounds like a tantrum LOL, but i'm sure you get my point)


Gabriel(Posted 2007) [#7]
I'm just thinking that a time when the DNS changes have made the site inaccessible for long periods and where the forums have "split" might not be the best time to judge a response.

But hey, I don't know the history. Maybe there was limited interest in previous releases.


Russell(Posted 2007) [#8]
REDi, your hard work will not be in vain: To me, ALL BMax modules should try as hard as yours does to be cross-platform. I wish I could test it for you, but alas, I only have a WinBox...

If there's an Amiga port to be tested, I have 3 in the closet waiting to be used! (I'm not kidding!)

But seriously, can someone with a Mac or Linux machine test this for REDI?

Russell


REDi(Posted 2007) [#9]
I see your point Gabe, just incase I'll leave it up for a tad longer.

But honestly guys, I'd like to hear you true opinions on this. (kill it or not)

*EDIT* Thanks Russell ;)


tonyg(Posted 2007) [#10]
Hi REDi, I get your point although another post suggested NOT using Maxmod until 1.28 was released. I assumed this post was just for feedback on mac, linux, vista and 64bit but if you want win32 feedback I'm happy to try it.
I am sufgfering from a general malaise with Bmax at the moment. BRL seem uncommitted and less communicative than normal : which is difficult. I appreciate the effort you and other coders are putting in to improve the product but it *does* seem like a waste of time sometimes. My attempt to plug some gaps fell on deaf ears with just a few suggestions which then received no feedback. Personally, I'd like to see some of the third party improvements upgraded to the full product as, one-by-one, they seem to become incompatible as the releases change. Anyway, thanks for what you have done so far.


REDi(Posted 2007) [#11]
Thanks Tony, has it got that bad lately? I havent been about for quite a while (moved house, spent time in hospital ect), so i dont really know whats going on atm, does seem to be less activity than before.

Shame because I do enjoy blitzmax as a language.


Matthew Smith(Posted 2007) [#12]
Redi,

Some testing results on Vista:

SampleMusic Test - Plays fine, but there is the occasional pause when you do other things on the PC.

Stream Test - Plays fine! no pausing etc.

Ogg Export - Worked fine and the resultant file played no probs.

Max GUI - Can't sync that at the moment.


REDi(Posted 2007) [#13]
? Sorry Matt, is that the beta download from http://code.google.com/p/maxmod/

SampleMusic ect doesnt exist anymore, you just Import MaxMod.ModPlayer and use LoadSound:TSound

Think ya got the wrong one mate ;)


Roger(Posted 2007) [#14]
REDi, I have an Intel Mac, and Ubuntu 7.10 running on a PC, and am happy to test.

The Mac is running Leopard, and I believe there may be issues that need 1.28, but I will check it out. possibly not until tomorrow though

Cheers.

Rog.


REDi(Posted 2007) [#15]
Thanks Roger, much appreciated mate!


Matthew Smith(Posted 2007) [#16]
Redi,

Yep thats the one. Ahh.. actually, I just unzipped it over the top... I'll take another look.

Does work though!


GregBUG(Posted 2007) [#17]
just tryed to compile in my OSX 10.4.11 (mac Intel)
and Max Says.. "Can't find interface for module "maxmod.music"

decompressesd under my mod folder...


popcade(Posted 2007) [#18]
XP SP2 and tested, works very well.

A side note, most of us can't even see the mysterious BlitzMax 1.28 release currently so can't make a comment yet.

I can only say MaxMod is VERY nice and I hope it can be continously maintained, OGG stream will be a plus as most of us don't know how to do it, but BRL must fix their audio driver first I think.


REDi(Posted 2007) [#19]
Thanks a lot for your help and kind words guys, it is appreciated! maybe it'll live to see another day :)

GregBug, thanks mate, I get the same error if I delete all the win32 compiled files and do a rebuild. Will fix ASAP. (would have thought max would have caught that and compiled maxmod.music first, anyone else think this is a bug?)


most of us can't even see the mysterious BlitzMax 1.28 release


yeah, neither can I :)


REDi(Posted 2007) [#20]
ok, new version up that should fix the build modules problem. I ended up just renaming it to maxmod.amusic and it compiles them in the correct order. hope it works like that on all platforms.


Russell(Posted 2007) [#21]
Anyone able to test on Linux yet?

Russell


North(Posted 2007) [#22]
Hio,

i don't know what the expected behaviour here is but is it supposed to stay still for ~10-15 seconds at 100% CPU before starting to play music?

If not I bet it has to do with me using the crappy onboard soundchip.

That test was on WinXP SP2


xlsior(Posted 2007) [#23]
Redi: I haven't tried the latest release yet, but anyway: MaxMod is definitely a very useful mod, and much appreciated.


REDi(Posted 2007) [#24]
Hi North, was that using the LoadSound method, or streaming with CreateAudioStream?

The LoadSound way will take various amounts of time to produce the entire song in one go, like loading an ogg file. some mods/xms are very long, even up to 10mins+! so creating ~100mb+ of audio can take a long time. you could watch task manager to see how big the sound gets.

also the more channels in the song the longer it'll take to create, Loading the entire song in one go is really only useful for reasonably small mods/xms.

but if your streaming and getting that amount of pause, please send me a copy of the file if possible, and I'll see whats going on.

*EDIT* Thanks xlsior, I think *maybe* I was over estimating the number of mac/linux users on here?, dont know really, guess I was over reacting.


REDi(Posted 2007) [#25]
Ouch! Just downloaded the new version from google codes, and winrar came up with a cached version from 4 days ago!!!

Please right click and "save target as" if you've downloaded a previous version before just incase.

Think I'm gonna have to change the file name each release?


North(Posted 2007) [#26]
Hi REDi,

this was with LoadSound - so i understand this works as expected.

I will try the Streaming soon.

Thanks for such a nice mod - i love the old tracks ;)


REDi(Posted 2007) [#27]
Phew, ya had me worried North ;)
Thanks for testing it mate, fingers crossed the streaming works for ya.


GregBUG(Posted 2007) [#28]
HI REDI,
just redownloaded and when i try to compile

max says: "Idetifier IDirectSound not found" in file directsoundaudiostream.bmx

....some win32 include file ins OSX? (directsound....)

my system OSX 10.4.11 BMax 1.26

ciao.


GregBUG(Posted 2007) [#29]
with compiler directive i have not included DirectSound referece and now compile without error...

any ready source sample to test you module ?(i must back to work and no time to write some test code...now)

gianluca.


steph(Posted 2007) [#30]
There is an example in mod/maxmod.mod/audiostream.mod/doc
-----

Trying to compile the mod (or rebuilding all mods) gives the following error on linux:


Compiling:audiostream.bmx
ar: creating /BlitzMax/mod/brl.mod/blitz.mod/blitz.debug.linux.x86.a
Compile Error: Can't find interface for module 'maxmod.amusic'
[/BlitzMax/mod/maxmod.mod/audiostream.mod/audiostream.bmx;22;1]
Build Error: failed to compile /BlitzMax/mod/maxmod.mod/audiostream.mod/audiostream.bmx
Process complete



after first compiling maxmod.amusic via comandline and changing lines 18, 23 and 72 in audiostream.bmx (the lines containing DirectSound references) the whole thing does compile on linux (open SuSE 10.3) and seems to work ok with freeaudio.
However loading xm/mod-files takes very long ( around 3 seconds for less then 2kb, more then 20 seconds for 926kb)


Streaming OGGs using the example-source does result in too fast played music with additional noise.


North(Posted 2007) [#31]
I just tested streaming and its working very nicely.

One thing struck me odd - check this piece:



I just added the x button to start over after stopping. It works, too, but if you press X twice(or more often) after you stop the song it instantly starts over (once).
I just wonder about this queue and why it only happens once and not for subsequently pressing X?

Anyway great fun :)


REDi(Posted 2007) [#32]
Thanks again guys!

DirectSound references should now be fixed, thanks GregBUG! (how stupid was that LOL)

North, I think its the KeyHit(KEY_X) causing that as it doesnt get called until the music has stopped playing, check this...
	If ChannelPlaying(channel)
		DrawText("Streaming...",10,10)
		KeyHit(KEY_X) ' flush the x key
	Else
		DrawText("Stopped...",10,10)
		If KeyHit(KEY_X) Channel = CreateAudioStream( file )
	EndIf


steph, that dont sound good mate, does streaming with mod/xm also produce noise/errors? wierd because I did have streaming before in linux without trouble.
I'll have to think about that speed issue.

Seems odd that Max doesnt catch that "cant find interface" error, anyone know if there is a way to force it to compile a perticular module first? otherwise I'm gonna have to join all the modules together.

anyway next version will be up soon.


jhans0n(Posted 2007) [#33]
I've been messing with this on a PPC Mac. One thing I can't figure out is that it seems like if I use CreateAudioStream to create a stream, how do I delete the stream later?

I tried just setting the resulting TChannel to null, but it seems like the stream stays in memory/keeps running, because each time I do this, my app's processor usage increases.

What I'm doing is I'm streaming a song, and then want to stream a different song.


REDi(Posted 2007) [#34]
Hi jhanson, good to now it produces sound on the PPC Mac!
Hopefully this fixes that issue. well spotted mate!

New version available! http://code.google.com/p/maxmod/downloads/list

I've removed quite a bit of stuff from modplayer that related to my tracker (ability to create scopes ect) and optimized some parts, seems to have speeded it up quite alot (30% on some mods), just hope it hasnt caused any new playback issues!

Still havent addressed the "Can't find interface for module 'maxmod.amusic'" issue yet, still not sure if its something max should handle, or wether its just bad practice on my part. (probly my fault, i guess)

*EDIT* BTW I added a few mods in a folder call "media", just to make it easier to compare loading times, on the same songs.
(My crappy system loads Rebels.mod in ~5.5 secs)


jhans0n(Posted 2007) [#35]
Hmmm... I'm not really seeing a difference with that particular bug.

Can someone on another platform try to replicate it? Basically, just take North's sample code above, change it to use OpenAL sound, and alternate hitting S and X in rapid succession. Each time you do that, the processor usage inches up. On my poor G4 Mac Mini, it can jump as much as 5% at a time (but is usually around 3%).

Do you have a recommended way for dealing with the audio streams to free them properly?


REDi(Posted 2007) [#36]
Just supposed to be the StopChannel command and the object getting garbage collected.

I dont see that on my system, always returns to 0 CPU usage, wonder whats going on? does it go down at all when the stream is stopped?

It does seem to be leaking ~100K each load tho, will look into that.
*EDIT* woah, its leaking like the titanic on some songs, didnt used to do that in previous (pre-openal) versions of maxmod, so should be a easy fix.


REDi(Posted 2007) [#37]
New version is up with fixed leakage :)

jhanson, I've adding a print to the delete method of openalaudiostream to see if it is actualy being collected, if you dont mind could you have a look for it poping up for me? I have altered the way it works, so it might even be fixed now.


jhans0n(Posted 2007) [#38]
REDi, whatever you did in version beta6 seems to have fixed the issue. Great job!

And yes, it was printing the message when it was deleting, BUT it doesn't print the message the first time I hit S to stop the stream. It only prints the message from the second time onward.


REDi(Posted 2007) [#39]
Bonus! I think the message wont be printed until you press the x key, and the old channel gets overwritten then collected.

Thanks for your help mate!

Just linux to worry about now, suppose i'll have to dig out a spare harddrive.


Diordna(Posted 2007) [#40]
It compiles fine on my Intel 10.4.11 laptop, but I don't have the time to test it with any actual code. Would someone please upload a simple example that I can try to run?


Diordna(Posted 2007) [#41]
Edit: I am a moron, ignore my post before the edit if you saw it. (Forgot to switch to OpenAL...)

Works fine for oggs, but will not load mp3s. (I can't remember if it's even supposed to, but I tried.)

Included example mod files also work.


REDi(Posted 2007) [#42]
Thanks Diordna! :D

I've removed mp3 support for now, as it used acm for demuxing it only worked on windows OS.

*EDIT* seems ogg streaming in directsound is broken, will fix ASAP.
*EDIT* Fixed! http://code.google.com/p/maxmod/downloads/list


MacSven(Posted 2007) [#43]
Work's great on my Mac Pro. Is it possible to load then mod like this

incbin "test.mod"

Sound:TSound = LoadSound("incbin::test.mod", True )

I have tested it but would not work?


xlsior(Posted 2007) [#44]
.


MacSven(Posted 2007) [#45]
OK. My mistake. Works now!


REDi(Posted 2007) [#46]
Hi MainframeOSX, glad its working for ya.

Could anybody comfirm the issues on Linux, I'm having trouble getting both my DVD writers to recognise blank discs, so cant get linux installed :(

*EDIT* finaly got Ubuntu installed! should be able to look into the prob's after work.


REDi(Posted 2007) [#47]
Well, got it up and running in ubuntu edgy, seems to be about the same speed loading as in windows, around 5.5 seconds for the rebels.mod!

I can hear a nasty glitch about once a second with the openal audio driver, no matter if its streaming with maxmod or playing as a sample using blitzmax's openal audio driver, sounds perfect under freeaudio though.

Seems openal is bugged on linux! (explains why I couldn't find it in Synaptic Package Manager I guess)


Tachyon(Posted 2007) [#48]
Sorry to just hop in here right in the middle of things, but I wanted to thank REDi for his work. I have not yet had the opportunity to use MaxMod yet, but anyone who is working to improve the state of sound within BlitzMax and maintain cross compatibility is a hero in my book. Keep up the good work, man.

:salute:


REDi(Posted 2007) [#49]
*blush* Thanks Tachyon! :)

:Arnold Rimmer salute:


popcade(Posted 2007) [#50]
The streaming works very nice, starts play instantly and even use 1% cpu only, very cool, It's MAGIC!

BRL might want to integrate this in and deprecate the old FreeAudio..


REDi(Posted 2007) [#51]
Cant get rid of FreeAudio mate, its the only one that works well on linux! I think Skidracer might have a few tricks up his sleeve yet ;)


Amon(Posted 2007) [#52]
I missed this thread for some reason. I'd like to say thanks to REDi for MaxMod as it is the only thing I can use in conjunction with sidstream to stream sid chip tunes.

I'll download the new version now and test it. Hopefully it works with the sidstream mod.

:)


jhans0n(Posted 2007) [#53]
Thanks, REDi. This is a very nice mod. I've been testing it in a game I'm working on for a little while now. I'm on a G4 Mac Mini running Tiger, and it works very nicely.


REDi(Posted 2007) [#54]
Thanks guys, glad you find it useful!

Amon, Sorry mate (and GMAN) I completely forgot about SID :(
If you replace sidstream.bmx with this it should work fine...


Is GMAN still about? havent seem him on here since I've been back.


jhans0n(Posted 2007) [#55]
Don't forget that you put that print statement in there for testing the deletion of the TOpenALAudioStream objects. You probably want to get rid of that at some point.


REDi(Posted 2007) [#56]
Yep, thanks jhanson, will be gone in next release.


Big&(Posted 2007) [#57]
Hi REDi

Just been having a go with this under 1.28 on Windows. Everything seems a'ok except it throws up an error when you stop a streaming channel:

"Unhandled Exception:Attempt to call abstract method"

This is while streaming an XM file and it does it with your sample source too.

I assume you will be changing stuff with the release of 1.28 but I thought I would point it out anyway.


jhocking(Posted 2007) [#58]
Will this help at all with recording?

http://www.blitzmax.com/Community/posts.php?topic=72909

I basically know jack shit about audio programming and need to get up to speed for a new project.


REDi(Posted 2007) [#59]
Hi Big&, I'm not getting that here with either openal or directsound driver, was this with the beta7 version? will be putting up an update soon.

Anyone else seeing this?

jhocking, I'll see if I can knock up an example for ya mate.
I've not done it with openal before only directsound, but should be able to sort something out for ya.


jhocking(Posted 2007) [#60]
Thanks man, that would be very helpful!


REDi(Posted 2007) [#61]
Here ya go mate, tried to make it as user friendly as pos, hope it helps!


Just create a sampler object and call the Start method to begin recording, when you call the Stop method it returns a TAudioSample for use with LoadSound or SaveOgg ect.

You can record in whatever sample format and hertz you want.


jhocking(Posted 2007) [#62]
sweeeeeeeet thanks!


REDi(Posted 2007) [#63]
No probs mate, I've just updated the code above to fix a minor bug, you might want to take a copy of it again.

Anybody think its worth adding that to maxmod? with a directsound version of course. Please post your yay or nay below :)


Big&(Posted 2007) [#64]
REDi: Yeah, it was with beta7. When I get home I will do a clean install of Max and give it a go again.


REDi(Posted 2007) [#65]
New version is up, main fix to note sliding math in modplayer.

Please delete old maxmod folder before you install, rebuild modules and docs.

Big&, fingers crossed mate ;)


Big&(Posted 2007) [#66]
REDi:

Everything is working now. Didn't do a reinstall, just put the most recent Maxmod in and it works fine :)

Can I be cheeky and ask if there is any way to have a "Set Pattern Number" or a "FMUSIC_SetOrder" as it is in FMOD?
Its just I have loads of different tunes inside one XM file and I have had to go through said XM file and save out all the individual tunes. This is causing some playback problems with Maxmod as I am hacking and slashing away at the module, causing who knows what damage :)

(EDIT: The above cheekiness is to do with streaming.)


REDi(Posted 2007) [#67]
Yep, no problem mate. Will get onto that for ya in a tad, just got home from work, so need to wind down a bit first ;)


REDi(Posted 2007) [#68]
Big&, Here is a little function to do what you want...
Function SetModPlayerPosition(Channel:TChannel Var, Sequence:Int, Line:Int=0)
	Local Mixer:MaxMod_Mixer = MaxMod_Mixer(TAudioStream(Channel).Music)
	If Not Mixer Return
	TAudioStream(Channel).KeepMusic = True
	StopChannel(Channel)
	Mixer.Seti(MM_SEQUENCE,Sequence)
	Mixer.Seti(MM_LINE,Line)
	Channel = CreateAudioStream(Mixer)
	TAudioStream(Channel).KeepMusic = False
EndFunction

You'll need to download a copy of 1.21 to get it to work properly.

I spent ages trying to work it into maxmod, but because it uses both MaxMod.AudioStream and MaxMod.ModPlayer its a bit awkward, hopefuly a solution will come up soon, otherwise I'm gonna end up having to put it all into one module again :(

anyway this works for now.


Big&(Posted 2007) [#69]
*GOBSMACKED*

Brilliant mate, thats top!! Have to wait to get home from work to try it. Damn! Why do we have to work!?! :)


Big&(Posted 2007) [#70]
Worked a treat REDi!!!! Put a donation button up or something, definitely worth a beer or three :)


REDi(Posted 2007) [#71]
My pleasure Big&

You're a gent, Mines a stella please :o) (button in the docs)


Big&(Posted 2007) [#72]
Missed that and done :)


REDi(Posted 2007) [#73]
Thank you kind sir, much appreciated!


Josepho(Posted 2007) [#74]
Nice work! Seems that i will use this in a near future :D


REDi(Posted 2007) [#75]
Excellent, give me a shout if you come across any problems mate.


MacSven(Posted 2007) [#76]
Have anyone of the MAC Users tested the Sidplay.
Here it does not work!


REDi(Posted 2007) [#77]
New version of SIDStream.bmx is way up there on this thread.


REDi(Posted 2007) [#78]
1.22 is now available, fixes to xm keyoff command and volume envelopes, also added a tiny bit of C++ to speed up mixing a tad (1 second off a 20 second load on my system)

http://code.google.com/p/maxmod/


Matthew Smith(Posted 2008) [#79]
Guys,

For those interested in the SidPlay streaming, I updated the wrapper to work with v1.22. Copy the following into your Sid.Mod/SidStream.Mod folder:

Sidstream.bmx


The following example shows you how to use the mod:


Thanks again to REDi and GMan for the original mods.


REDi(Posted 2008) [#80]
Cool, Thanks Matt! :D


Difference(Posted 2010) [#81]
Regarding REDis audio recording code from /Community/posts.php?topic=74048#831077
I made a very small REM/modification in Method Stop:TAudioSample(), because the saved sound gets to long.

Mostly apperent when saving as ogg, but you can see the samplecount increase when you press space to stop too, because the last (I think empty) buffer is added.

Other that that this seems to work great under Snow Leopard.


This version also saves as ogg, courtesy of skidracers oggsaver.mod