How to record sounds from a mike ?
How to record sounds from a mike ?
Hi all,
It is a question sending on the french forum but without answer.
The problem is to record sounds from a mike and then to read this record. I have no really idea. Is there a way to catch sound with the sound card and then to encode ( or not) it to reduce size ?
Thanks for Help.
Denis
It is a question sending on the french forum but without answer.
The problem is to record sounds from a mike and then to read this record. I have no really idea. Is there a way to catch sound with the sound card and then to encode ( or not) it to reduce size ?
Thanks for Help.
Denis
A+
Denis
Denis
I found this in my HD, but I'm sure I didn't code it. It must be old, it still used InitGadget():
Code: Select all
Global buffer$
buffer$=Space(256)
Procedure MCI(command.s)
result=MciSendString_(command,@buffer$,256,0)
ProcedureReturn result
EndProcedure
;---------------------------------------------------------------------
clip.s="C:\Test.wav" ;file to save to disk
alignment=4
bits=16 ;16bit wave file
channels=2 ;1=mono 2=stero
samples=44100 ;44.1kHz sample rate
reclength=5 ;length of audio to record (this example records 5 seconds)
If OpenWindow(0,10,10,200,100,#PB_Window_SystemMenu,"Record Audio")=0:End:EndIf
If CreateGadgetList(WindowID())=0:End:EndIf
TextGadget(0,10,10,100,20,"")
MCI("open new type waveaudio alias recsound")
MCI("set recsound time format ms")
MCI("set recsound alignment "+Str(alignment)+" bitspersample "+Str(bits)+" samplespersec "+Str(samples)+" channels "+Str(channels)+" bytespersec "+Str(samples*alignment) )
MCI("record recsound")
While elapsed < reclength*1000
MCI("status recsound position")
elapsed=Val(buffer$)
SetGadgetText(0,"Recorded: "+Str(elapsed/1000)+" secs.")
Delay(20)
Wend
MCI("save recsound "+clip)
MCI("close recsound")
End
El_Choni
Record Sound?
If you mean manually you can use windows accessories sound recorder to create a .wav file and then get a .mp3 encoder to compress it just as you would music.
If you mean programatically then you should investigate these api calls:
Declare Function waveInOpen Lib "winmm.dll" (lphWaveIn As Long, ByVal uDeviceID As Long, lpFormat As WAVEFORMAT, ByVal dwCallback As Long, ByVal dwInstance As Long, ByVal dwFlags As Long) As Long
Declare Function waveInPrepareHeader Lib "winmm.dll" (ByVal hWaveIn As Long, lpWaveInHdr As WAVEHDR, ByVal uSize As Long) As Long
Declare Function waveInReset Lib "winmm.dll" (ByVal hWaveIn As Long) As Long
Declare Function waveInStart Lib "winmm.dll" (ByVal hWaveIn As Long) As Long
Declare Function waveInStop Lib "winmm.dll" (ByVal hWaveIn As Long) As Long
Declare Function waveInUnprepareHeader Lib "winmm.dll" (ByVal hWaveIn As Long, lpWaveInHdr As WAVEHDR, ByVal uSize As Long) As Long
Declare Function waveInClose Lib "winmm.dll" (ByVal hWaveIn As Long) As Long
Declare Function waveInGetDevCaps Lib "winmm.dll" Alias "waveInGetDevCapsA" (ByVal uDeviceID As Long, lpCaps As WAVEINCAPS, ByVal uSize As Long) As Long
Declare Function waveInGetNumDevs Lib "winmm.dll" () As Long
Declare Function waveInGetErrorText Lib "winmm.dll" Alias "waveInGetErrorTextA" (ByVal err As Long, ByVal lpText As String, ByVal uSize As Long) As Long
Declare Function waveInAddBuffer Lib "winmm.dll" (ByVal hWaveIn As Long, lpWaveInHdr As WAVEHDR, ByVal uSize As Long) As Long
I did a google on 'sound record vb' to find this, looks like it is fairly involved, definitely not a ten minute job.
If you mean programatically then you should investigate these api calls:
Declare Function waveInOpen Lib "winmm.dll" (lphWaveIn As Long, ByVal uDeviceID As Long, lpFormat As WAVEFORMAT, ByVal dwCallback As Long, ByVal dwInstance As Long, ByVal dwFlags As Long) As Long
Declare Function waveInPrepareHeader Lib "winmm.dll" (ByVal hWaveIn As Long, lpWaveInHdr As WAVEHDR, ByVal uSize As Long) As Long
Declare Function waveInReset Lib "winmm.dll" (ByVal hWaveIn As Long) As Long
Declare Function waveInStart Lib "winmm.dll" (ByVal hWaveIn As Long) As Long
Declare Function waveInStop Lib "winmm.dll" (ByVal hWaveIn As Long) As Long
Declare Function waveInUnprepareHeader Lib "winmm.dll" (ByVal hWaveIn As Long, lpWaveInHdr As WAVEHDR, ByVal uSize As Long) As Long
Declare Function waveInClose Lib "winmm.dll" (ByVal hWaveIn As Long) As Long
Declare Function waveInGetDevCaps Lib "winmm.dll" Alias "waveInGetDevCapsA" (ByVal uDeviceID As Long, lpCaps As WAVEINCAPS, ByVal uSize As Long) As Long
Declare Function waveInGetNumDevs Lib "winmm.dll" () As Long
Declare Function waveInGetErrorText Lib "winmm.dll" Alias "waveInGetErrorTextA" (ByVal err As Long, ByVal lpText As String, ByVal uSize As Long) As Long
Declare Function waveInAddBuffer Lib "winmm.dll" (ByVal hWaveIn As Long, lpWaveInHdr As WAVEHDR, ByVal uSize As Long) As Long
I did a google on 'sound record vb' to find this, looks like it is fairly involved, definitely not a ten minute job.
Record Sound
I think el choni's approach is definitely easier
@El_Choni
Thanks for this code. I will investigate. Just a question. I'm too young in PB (less one year) and i don't know the command InitGadget(). What about it ?
Hope we'll see you back on the french forum.
@ppjm99
Thanks too, may be this code will help some of us.
@Polo
Are you French-speaking ?
Denis
Thanks for this code. I will investigate. Just a question. I'm too young in PB (less one year) and i don't know the command InitGadget(). What about it ?
Hope we'll see you back on the french forum.

@ppjm99
Thanks too, may be this code will help some of us.
@Polo
Are you French-speaking ?
Denis
A+
Denis
Denis
Re: How to record sounds from a mike ?
> The problem is to record sounds from a mike and then to read this
> record. I have no really idea.
> record. I have no really idea.
Code: Select all
Procedure RecordWav(filename$,ms)
buffer$=Space(128) : DeleteFile_(filename$)
mciSendString_("open new type waveaudio alias capture",buffer$,128,0)
mciSendString_("set capture samplesperbuffer 8000 bytesperbuffer 8000",0,0,0)
mciSendString_("record capture",buffer$,128,0)
Sleep_(ms) ; Wait for specified capture time to end.
mciSendString_("save capture "+filename$,buffer$,128,0)
EndProcedure
;
MessageRequester("Info","Click OK to capture audio to c:\test.wav for 2 secs",0)
RecordWav("c:\test.wav",2000)
MessageRequester("Info","Done!",0)
LOUDER!!!
I record sounds from Mike by beating the crap out of him while holding my microphone just above his head. But be careful not to get blood in your mic as this tends to dampen the sound quality considerably.
I don't see how this has anything to do with Purebasic, try S&M next door.
I don't see how this has anything to do with Purebasic, try S&M next door.
in this code :
is it possible ti send the captured sound over a network to make a basic VoIP software ?
In this case should I send the "buffer$" parameter ?
How at the other end the buffer can be read ?
I read about a "play" command on MSDN, but I don't see how to read a variable.
Thanks in advance.
(I hope that to bump this old topic is ok, I didn't find any other talking about this subject on the forum).
Code: Select all
Procedure RecordWav(filename$,ms)
buffer$=Space(128) : DeleteFile_(filename$)
mciSendString_("open new type waveaudio alias capture",buffer$,128,0)
mciSendString_("set capture samplesperbuffer 8000 bytesperbuffer 8000",0,0,0)
mciSendString_("record capture",buffer$,128,0)
Sleep_(ms) ; Wait for specified capture time to end.
mciSendString_("save capture "+filename$,buffer$,128,0)
EndProcedure
;
MessageRequester("Info","Click OK to capture audio to c:\test.wav for 2 secs",0)
RecordWav("c:\test.wav",2000)
MessageRequester("Info","Done!",0)
In this case should I send the "buffer$" parameter ?
How at the other end the buffer can be read ?
I read about a "play" command on MSDN, but I don't see how to read a variable.
Thanks in advance.
(I hope that to bump this old topic is ok, I didn't find any other talking about this subject on the forum).
- Registered PB user -
Using PB 4.00
Using PB 4.00
-
- User
- Posts: 30
- Joined: Tue Sep 09, 2003 11:44 pm
- Location: Queensland, Australia