Bah.fmod: FMOD_OUTPUTTYPE_WAVWRITER missing?

BlitzMax Forums/Brucey's Modules/Bah.fmod: FMOD_OUTPUTTYPE_WAVWRITER missing?

Grisu(Posted 2013) [#1]
Hello!

I'm trying to save the audio output as WAV file to my HDD via FMod as described in this short example here:
http://stackoverflow.com/questions/6171108/save-output-to-disk-using-fmod

Can it be that the flags "FMOD_OUTPUTTYPE_WAVWRITER" / "FMOD_OUTPUTTYPE_WAVWRITER_NRT" aren't implemented yet? As soon as I call "system.setOutput(FMOD_OUTPUTTYPE_WAVWRITER)" I get an "Identifier not found" error.

Is there another / easier way to save the current audio output to the HDD? I found this ancient tutorial from Midimaster on the forums. But the links / sources are dead by now: http://www.blitzbasic.com/Community/posts.php?topic=90830#1094743.

Grisu


Midimaster(Posted 2013) [#2]
Don't know why Creativ Labs removed the installer of OpenAl. This must be completely new, because also Wikipedia links to the same adress. But you can find the same file on my homepage:

OpenAl Installer:

http://www.midimaster.de/download/oalinst.exe

In my sample you need OpenAl only for recording, but not for saving. For Saving use this OGG-Saver module here:

axe.oggsaver.mod:

http://max-edit.googlecode.com/svn/trunk/mod/axe.mod/


Brucey(Posted 2013) [#3]
Can it be that the flags "FMOD_OUTPUTTYPE_WAVWRITER" / "FMOD_OUTPUTTYPE_WAVWRITER_NRT" aren't implemented yet?

The OUTPUTTYPE enums were not defined in the module. I've just added them.


Grisu(Posted 2013) [#4]
Thanks a lot you two!

Made some progress during the last hour. FMod is now recording the PRP stream that is currently playing and dumping the data to the expected "fmodoutput.wav".

Strangely, I get the following error message with RecordStart():
"An invalid parameter was passed to this function." -> result:Int=system.RecordStart:Int(1,stationsound,False)
Not sure what is causing this, as there is no invalid parameter present from my point of view.

Furthermore I need to figure out how to set a custom output filename. So I can name the files created according to the streams.
Also there should be a way to play the music loud and record it at the same time.

Anyway, Rome wasn't built in one day...


Brucey(Posted 2013) [#5]
Furthermore I need to figure out how to set a custom output filename.

With system.Init(), you can pass a C-String as the third parameter. So you should be able to do something like :
Local system:TFMODSystem = New TFMODSystem.Create()

Local filename:String = "myfile.wav"
Local filePtr:Byte Ptr = filename.ToUTF8String()

system.Init(32, , filePtr)

MemFree(filePtr)

A bit low-level, but it should work, as per the documentation - "Use the 'extradriverdata' parameter in System::init, by simply passing the filename as a string, to set the wav filename. "

I'm sure you'll let me know if it doesn't work ;-)


Brucey(Posted 2013) [#6]
Strangely, I get the following error message with RecordStart():
"An invalid parameter was passed to this function." -> result:Int=system.RecordStart:Int(1,stationsound,False)


Hard to say. Maybe it doesn't like you including ":Int" as part of the function call?


Grisu(Posted 2013) [#7]
The extra parameter for the filename works. Though I can't get around the error message.

In order to further test this, I made this recording example:


Can someone please test it. I need to know if the recording device is set up correctly on different machines.

The WAV file starts with some seconds of blank music. I guess this is due to the buffering.


Brucey(Posted 2013) [#8]
The first parameter of RecordStart and RecordStop is the id of the recorder driver.

On my Mac, GetRecordNumDrivers() is returning 0 drivers, but passing in 0 as the id gives the error despite it still working.
Presumably, if you are writing straight to disk, you wouldn't be needing a sound card to record stuff, so it seems to work anyway.

Not sure how you play (so you can hear it) and record at the same time.


Grisu(Posted 2013) [#9]
Ahm, so you need "system.RecordStart(0, station_record, False)" run the code under Mac?

There are some examples for recording & playing at the same time that come with the fmod api, such as:

Got this info via: http://stackoverflow.com/questions/6025955/playback-and-listen-to-recording-device-in-fmod

Couldn't make it work though.

One more ugly workaround might be to start a separate system just for recording a stream. So the user can freely select and listen to other PRP stations while one station stream is recording in the background.


Brucey(Posted 2013) [#10]
Ahm, so you need "system.RecordStart(0, station_record, False)" run the code under Mac?

No. It doesn't matter what number you put in there, since you are using the wav output recorder, as it doesn't need a real sound card record driver to work. So you get the error value, but you can ignore it.
Of course, if you wanted to write to a soundcard instead and it returned 0 drivers you'd have a real problem.


Grisu(Posted 2013) [#11]
Thanks for the clarification. I just tried "Null" as paramter and it even works then.

Did you change something in your module code?

I'm going to implement the stuff into PRP soon. Fingers crossed. :)


Brucey(Posted 2013) [#12]
Did you change something in your module code?

I added GetRecordDriverInfo() method. But it will only return stuff if you have a valid record driver to begin with.


Grisu(Posted 2013) [#13]
Thanks for the module update.

Uploaded the first prp test build with the new recording button.


Just hope it works for all machines / platforms...