Recording Audio?

BlitzMax Forums/BlitzMax Programming/Recording Audio?

Is it possible to record audio through a microphone and then save it as a WAVE (or other?) file?

I have never seen much as far as BMax having these capabilities, but is it in any way feasible?

Search on 'Microphone' and there are a few posts that cover this topic.

I grabbed the code from another thread:
Import axe.portaudio


Global astream:Byte Ptr

''''''''''''''''''''''''' stuff missing from port audio
Extern
	Function Pa_GetDefaultOutputDeviceID:Int()
EndExtern

Const paInt8	:Int=32
Const paUInt8	:Int=64
Const paInt16	:Int=2
'''''''''''''''''''''''''' end of missing stuff

Graphics 640,480

Global buf:Float[256]

error( Pa_Initialize() ,"init")

' set the mix buffer running....
playstreamPA(astream,myCallback)	


While Not KeyDown(key_escape)


		Cls
		For Local n:Int=0 To 255

			DrawLine 320,n+100,320+buf[n],n+100
		Next

		Flip


Wend


Pa_CloseStream(astream)

End



Function myCallback:Int( inputBuffer:Float Ptr, outputBuffer:Short Ptr,..
                           framesPerBuffer:Int,outTime:Double, userData:Byte Ptr )
	For Local n:Int=0 To 255
		buf[n]=inputBuffer[0]*128
		inputbuffer:+1
	Next
EndFunction





Function error(e:Int,s:String)
	If e=0 Then Return
	Pa_Terminate()
	Print "error "+e+" in "+s
	Print "message "+String.FromCString(Pa_GetErrorText(e))
	End
EndFunction	


Function playstreamPA(stream:Byte Ptr Var,callback:Byte Ptr)

	error(.. 
	Pa_OpenStream( Varptr stream,Pa_GetDefaultOutputDeviceID(),2,paFloat32,Null,..
						paNoDevice,0,paInt8,Null,44100,256,0,paClipOff,..
			              			Callback,Null )..
	,"open stream")	
	
	error( Pa_StartStream( stream ),"start stream" )
	Print "playing"



EndFunction

It is kinda cool...
But I need to save a sound, about maybe 3 seconds to a .wav file.
Any Ideas?

Look in the Code Archives under Audio, filter using BMX and search for WAV you will find Ogg Converter/Wav Saver which should help.

I'll give it a shot but I always appreciate the input from those with more experience than me....That's pretty much everyone!