wave recording

hi,
i need a code for using wavein ,waveout functions to record and play sounds .something realy works.
thanks.
mnahelAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

LischkeCommented:
Hi mnahel,

firstly, you have posted this question twice. I recommend that you delete one of them. Secondly, for 15 points you need already luck to get a link to somewhere. For working code you need about 20 times this amount and for complete code you better append at least two zero's.

Ciao, Mike
0
mnahelAuthor Commented:
Adjusted points to 30
0
mnahelAuthor Commented:
hi,
my points is less than what you suggested even for the amount without the  two zero's.I realy need your help.
thanks.
0
LischkeCommented:
Honestly mnahel, you should not think I'm greedy, but what you want is tough stuff and needs much time to explain and implement it. Here's code for recording start, stop and storing while recording:

function TMicAudioDriver.StartRecording: Boolean;

var I : Integer;

begin
  WaitForStoppedRecording;

  FBufferLock.Acquire;
  try
    FBufferStream.Position:=0;
    FReadPosition:=0;

    // Open des Aufnahmegeräts. Callbacks gehen an das Hilfsfenster
    Result:=CheckOK(waveInOpen(@FWaveHandle,WAVE_MAPPER,@FWaveFormat,RecWindow,0,CALLBACK_WINDOW));

    if Result then
    begin
      // Installation der WaveIn-Puffer
      for I:=0 to FBufferCount-1 do
      begin
        Result:=Result and CheckOK(waveInPrepareHeader(FWaveHandle,@FBuffers[I],SizeOf(TWaveHdr)));
        Result:=Result and CheckOK(waveInAddBuffer(FWaveHandle,@FBuffers[I],SizeOf(TWaveHdr)));
        if not Result then
        begin
          Result:=False;
          Break;
        end;
      end;

      // Mikrofon an, ab jetzt läuft der Input (-> MM_WIM_DATA an RecWindow)
      if Result then Result:=CheckOK(waveInStart(FWaveHandle));
      FFinished:=False;
      FStopping:=False;
    end;
  finally
    FBufferLock.Release;
  end;
end;

//--------------------------------------------------------------------------------

procedure TMicAudioDriver.StopRecording;

var I : Integer;

begin
  if (FWaveHandle <> 0) and not FStopping then
  begin
    FStopping:=True;
    FBufferLock.Acquire;
    try
      CheckOK(waveInReset(FWaveHandle));

      for I:=0 to FBufferCount-1 do
        if not CheckOK(waveInUnprepareHeader(FWaveHandle,@FBuffers[I],SizeOf(TWaveHdr))) then Break;

      CheckOK(waveInClose(FWaveHandle));
    finally
      FBufferLock.Release;
    end;

    // Thread anhalten bis alle MM_WIM_ Nachrichten durch sind
    WaitForStoppedRecording;
  end;
end;


procedure TMicAudioDriver.StoreRawData(Hdr: PWaveHdr);

begin
  FBufferLock.Acquire;
  try
    if not FFinished then
    begin
      // Ringpuffer modellieren, die verwendeten AudioBuffer liegen im Stream direkt hintereinander
      // beginnend mit dem ersten Buffer (was sonst?)
      if Hdr.dwUser = 0 then FBufferStream.Position:=0;

      // Daten schreiben, wrap around hier nicht nötig, da die Größe des Streams genau
      // nach der Größe der Buffer ausgerichtet ist
      FBufferStream.Write(Hdr.lpData^, Hdr.dwBytesRecorded);

      // Buffer gleich wieder zur Verfügung stellen
      if not FStopping then CheckOK(waveInAddBuffer(FWaveHandle,Hdr,SizeOf(TWaveHdr)));
    end;  
  finally
    FBufferLock.Release;
  end;
end;

//--------------------------------------------------------------------------------

procedure TMicAudioDriver.WaitForStoppedRecording;

// blockt den Thread bis das Recordingevent "signaled" ist (passiert im RecWindow)

begin
  if GetCurrentThreadID = MainthreadID then
    while WaitForSingleObject(FRecordingEvent, 100) = WAIT_TIMEOUT do Application.ProcessMessages
                                       else WaitForSingleObject(FRecordingEvent, INFINITE);
end;

Please, don't ask for more...

Ciao, Mike
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
LischkeCommented:
Sorry, the last function didn't make it through...


procedure TMicAudioDriver.WaitForStoppedRecording;

// blockt den Thread bis das Recordingevent "signaled" ist (passiert im RecWindow)

begin
  if GetCurrentThreadID = MainthreadID then
    while WaitForSingleObject(FRecordingEvent, 100) = WAIT_TIMEOUT do Application.ProcessMessages
                                       else WaitForSingleObject(FRecordingEvent, INFINITE);
end;


Ciao, Mike
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.