|
-
Dec 17th, 2000, 06:19 PM
#1
Thread Starter
New Member
take a look at this piece of code...
filename = "untitled"
Dim whatever&
whatever& = mciSendString("open new type waveaudio alias something", "", 0, 0)
If whatever& <> 0 Then DisplayError whatever&
whatever& = mciSendString("set something time format ms samplespersec 44100 bitspersample 16 channels 2", "", 0, 0)
If whatever& <> 0 Then DisplayError whatever&
now that's supposed to open a device (waveaudio) aliased 'something', set its time format to milliseconds and set the sound quality to 44100Hz, 16bits stereo. However it doesn't. The only valid values for the sound quality are 11025Hz, 8bits and 1 channel. Every single other value generates an error message. Anybody have an idea as to what am i missing or doing wrong ?
Thanks in advance...
-
Dec 17th, 2000, 06:42 PM
#2
Lively Member
Nope that code should work.. but it needs to be like this
Code:
Private Function RecordInstead() As String
Dim dwreturn(1 To 3) As Long
Dim ret As String * 128
'now before playing the song we need to set up a record mode capture
dwreturn(1) = mciSendString("open new Type waveaudio Alias tune", 0&, 0&, 0&)
dwreturn(2) = mciSendString("set tune bitspersample 16 samplespersec" _
& " 44100 channels 2 bytespersec 17640 alignment 8", 0&, 0&, 0&)
dwreturn(3) = mciSendString("set tune format tag pcm", 0&, 0&, 0&)
'record to 16bit 4410khz Stereo
For i = 1 To 3
If dwreturn(i) <> 0 Then
mciGetErrorString dwreturn(i), ret, 128 'Get the error
MsgBox ret, vbCritical
mciSendString "close tune", 0&, 0&, 0&
Exit Function
End If
Next i
dwreturn(1) = mciSendString("record tune", 0&, 0, 0)
If dwreturn(1) <> 0 Then
mciGetErrorString dwreturn(i), ret, 128
mmopen = ret
MsgBox ret, vbCritical
Exit Function
End If
'if all is fine then success#
RecordInstead = "Success"
End Function
I know that this works as I am already using it, but this is the code I am using to record an mp3 to a wav, you will need to have the following function to stop the recording
Code:
Private Function StopRecording() As String
Dim dwreturn(1 To 3) As Long
Dim ret As String * 128
'Change the file extension to .wav
filename = Mid(filename, 1, Len(filename) - 4) & ".wav"
dwreturn(1) = mciSendString("stop tune", 0&, 0, 0)
dwreturn(2) = mciSendString("save tune c:\NewTune.wav", 0&, 0&, 0&)
dwreturn(3) = mciSendString("close tune", 0&, 0, 0)
'check each command sent
For i = 1 To 3
If dwreturn(i) <> 0 Then
mciGetErrorString dwreturn(i), ret, 128
mmopen = ret
MsgBox ret, vbCritical
RecordMode = False
Exit Function
End If
Next i
'sucess if we reach here
StopRecording = "Success"
RecordMode = False
End Function
plus you need to be playing an Mp3 first before calling the first function and you call the second function when the mp3 stops playing....
-
Dec 17th, 2000, 07:14 PM
#3
Thread Starter
New Member
nice...
Ah, obviously, I forgot I was working with the MCI. Took a look at the Waveformatex structure as well, now its all clear to me.
Thanks, you've been a great help...
-
Dec 17th, 2000, 07:44 PM
#4
Lively Member
No problem..
But can you solve this one?
When recording a wav.. if you don't specify the settings the output wav will be of the right time length, but at mono.
If you do specify the settings you get some really weird outputs.. it is possible to play the tune at 2.2X speed but the recorded format goes to pot...
Any Idea???
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|