SpikeyThePilot
02-06-2008, 09:01 AM
Hi, Im having problems trying to save a recorded soundcard input as a WAV file with a file path. Saving to the app.path is fine but not to a sub directory.
Dim i As Long
i = mciSendString("open new type waveaudio alias RecWavFile", 0&, 0, 0)
i = mciSendString("record RecWavFile", 0&, 0, 0) 'record
'wait
i = mciSendString("Stop RecWavFile", 0&, 0, 0) 'stop record
i = mciSendString("save RecWavFile c:/recordings/test.wav", 0&, 0, 0) 'save
i = mciSendString("close RecWavFile", 0&, 0, 0)
The above code will not save/create any file but if I remove the "/recording/" from the path it is fine and the file is saved.
Any ideas please?
Thanks in advance.
Angry Kreyon
02-06-2008, 10:46 AM
in the project I am working on now I too need to save a wave file and this is the code that does that:
Dim DataBytes(0 To 1, 0 To 44099) As Long
WriteWave txtOutputPath.Text, CreateWaveArray(DataBytes, 44100, 16)
now I have the path of where the wav file is supposed to be saved being pulled from a textbox and it works just fine, the only difference may be that I am creating the wave file there not just saving it to there. (my program will write wav files from data.)
hope this helps.
oh, and your slashes are Backwards! should be "c:\" not "c:/" - more than likely that is your issue!
Rockoon
02-06-2008, 01:14 PM
An issue with mci, I believe, is that it does not support long filenames. The path and name must conform to the old short 8.3 specification. Since the path has a folder name longer than 8 characters, the path must be translated to its short name with GetShortPathName() (http://msdn2.microsoft.com/en-us/library/aa364989(VS.85).aspx)
An example where I used this API for an MCI application:
http://www.xtremevbtalk.com/showthread.php?t=171130&highlight=midi+getshortpathname
Angry Kreyon
02-06-2008, 01:31 PM
I use long path names and names with spaces with no issues at all! my current project creates a new wave file at "C:\storage\vb projects\StockSongs\tempwave.wav" and has no issues. ( as you can see I have 10 digit folders and a 2 word folder, and it does this with no problems, always make sure to use the Quotes around any path that is like this and it should work.)
BUT
if he is using the "/" instead of "\" in his path statement then I will almost guarentee that is the problem here.
I could be wrong as I am doing a createwavearray instead of an MCI call but it should work.
SpikeyThePilot
02-06-2008, 05:12 PM
Thanks for you suggestions and help, it gave me some ideas to get it working.
My problem was a first backslash not required i.e.
This does not work (error code 286)
i = mciSendString("save RecWavFile \recordings\test.wav", 0&, 0, 0)
This does work
i = mciSendString("save RecWavFile recordings\test.wav", 0&, 0, 0)
Both '/' and '\' work and are interchangeable.
I have a new problem now, the above code in my first post recorded audio on one computer but I just get a WAV of popping and banging on another. I can record a clean WAV on this non working computer using other sound recording software.