如何录制声音并延迟播放?

发布于 2024-11-16 07:31:45 字数 64 浏览 2 评论 0原文

我知道我可以通过媒体播放器组件录制声音,但录制后我必须保存它然后播放它。但是有什么办法可以立即播放或自定义延迟吗?

I know that i can record sounds by Media Player component, but after record i have to save it and then play it. But is there any way to play it instantly or with a custom delay?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

橘寄 2024-11-23 07:31:45

您可以使用 LakeofSoft VC 组件轻松完成此操作。他们的录音演示如您所愿。

You can easily do it with LakeofSoft VC components. Their voice recording demo works like you want.

我是男神闪亮亮 2024-11-23 07:31:45

您可以尝试以下位置的音频库: http://www.un4seen.com/

“BASS”DLL 可以工作适用于 Windows Xp 和 Win 7。它们对于非商业用途是免费的。下载内容包括一个简单的 Delphi 录音机示例,允许用户“录音”,然后“保存”为音频文件,或者立即“播放”该文件,而无需在音频文件仍在内存中时保存该文件。 “BASS”与 Delphi 2007 配合得很好。它可能非常适合您的目的。

You might try the audio library at: http://www.un4seen.com/

The "BASS" DLLs work fine with Windows Xp and Win 7. They are free for non-commercial use. The download includes a simple Delphi example of an audio recorder that allows one to "record," then "save" as an audio file or "playback" the file immediately without saving the audio file while the audio file is still in memory. "BASS" works very well with Delphi 2007. It might work great for your purposes.

叹梦 2024-11-23 07:31:45

以下是如何使用 http://www.un4seen.com/ 中的 bass.dll 执行此操作,

您可以使用un4seen中的RecordTest示例并修改以下功能,如下所示:

function RecordingCallback(Handle: HRECORD; buffer: Pointer; length: DWORD; user: Pointer): boolean; stdcall;
begin
  BASS_StreamPutData(chan, buffer, length); // added: pass the captured data to the push stream
    // Copy new buffer contents to the memory buffer
    Form1.WaveStream.Write(buffer^, length);
    // Allow recording to continue
    Result := True;

    Form1.WaveStream.Write(WaveHdr, SizeOf(WAVHDR));
    chan := BASS_StreamCreate(44100, 2, 0, STREAMPROC_PUSH, nil); // added: create a push stream
    BASS_ChannelPlay(chan, False); // added: start it
    // start recording @ 44100hz 16-bit stereo
end;


procedure TForm1.StopRecording;
var
    i: integer;
begin
    BASS_ChannelStop(rchan);
    BASS_StreamFree(chan); // added: free the push stream
    bRecord.Caption := 'Record';
    // complete the WAV header
    WaveStream.Position := 4;
    i := WaveStream.Size - 8;
    WaveStream.Write(i, 4);
    i := i - $24;
    WaveStream.Position := 40;
    WaveStream.Write(i, 4);
    WaveStream.Position := 0;
    // create a stream from the recorded data
    chan := BASS_StreamCreateFile(True, WaveStream.Memory, 0, WaveStream.Size, 0);
    if chan <> 0 then
    begin
        // enable "Play" & "Save" buttons
        bPlay.Enabled := True;
        bSave.Enabled := True;
    end
    else
        MessageDlg('Error creating stream from recorded data!', mtError, [mbOk], 0);
end;

修改后按下录制时,它会在录制的同时播放声音。

我在论坛上从 Ian 那里得到了这个代码。

Here is how to do it with bass.dll from http://www.un4seen.com/

You can use the RecordTest example from un4seen and modify the following functions like this:

function RecordingCallback(Handle: HRECORD; buffer: Pointer; length: DWORD; user: Pointer): boolean; stdcall;
begin
  BASS_StreamPutData(chan, buffer, length); // added: pass the captured data to the push stream
    // Copy new buffer contents to the memory buffer
    Form1.WaveStream.Write(buffer^, length);
    // Allow recording to continue
    Result := True;

    Form1.WaveStream.Write(WaveHdr, SizeOf(WAVHDR));
    chan := BASS_StreamCreate(44100, 2, 0, STREAMPROC_PUSH, nil); // added: create a push stream
    BASS_ChannelPlay(chan, False); // added: start it
    // start recording @ 44100hz 16-bit stereo
end;


procedure TForm1.StopRecording;
var
    i: integer;
begin
    BASS_ChannelStop(rchan);
    BASS_StreamFree(chan); // added: free the push stream
    bRecord.Caption := 'Record';
    // complete the WAV header
    WaveStream.Position := 4;
    i := WaveStream.Size - 8;
    WaveStream.Write(i, 4);
    i := i - $24;
    WaveStream.Position := 40;
    WaveStream.Write(i, 4);
    WaveStream.Position := 0;
    // create a stream from the recorded data
    chan := BASS_StreamCreateFile(True, WaveStream.Memory, 0, WaveStream.Size, 0);
    if chan <> 0 then
    begin
        // enable "Play" & "Save" buttons
        bPlay.Enabled := True;
        bSave.Enabled := True;
    end
    else
        MessageDlg('Error creating stream from recorded data!', mtError, [mbOk], 0);
end;

When you press record after the modification, It plays the sound at the same time while recording it.

I got this code from Ian in the forum.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文