简体   繁体   English

播放“已录制”的声音

[英]Playback of 'recorded' sounds

I'm building a fairly simple sampler in C#. 我正在用C#构建一个相当简单的采样器。 I've got the basic sound structure down (sounds pitched, stopping sounds mid play, etc). 我已经掌握了基本的声音结构(声音变高,播放过程中停止声音等)。 But my problem arises when I try to record and play the sounds the user inputs. 但是,当我尝试录制和播放用户输入的声音时,就会出现我的问题。 When recording, I save the sound into a dictionary with the starting time as the key (Class 'time' starts from 0), along with the length of the sound. 录制时,我将声音以开始时间(键为“时间”从0开始)作为开始时间保存到字典中,并伴以声音的长度。 When playing back the recorded sound, I'm currently using a timer to simulate time in the system. 播放录制的声音时,我目前正在使用计时器来模拟系统中的时间。 I set the timer interval to the time difference between the current sound and the next sounds every time I play a sound. 每次播放声音时,我将计时器间隔设置为当前声音与下一个声音之间的时间差。 It mostly starts out fine, but the sound usually goes completely out of sync, sounds are cut short or start too late, etc etc, I assume the problem is with my use of a timer, but I have no idea of another way of doing it. 它通常一开始就很好,但是声音通常会完全不同步,声音被切短或开始得太晚等等,我认为问题出在我使用计时器的问题上,但是我不知道另一种处理方法它。 I'm using Bass.Net for the sounds. 我正在使用Bass.Net发出声音。

What timers are you using? 您正在使用什么计时器? Most timers in .NET would be too inaccurate for this task, you should look into P/Invoking Multimedia Timers (see this for example) or building your own using Stopwatch . .NET中的大多数计时器对于此任务而言都不是很准确,您应该研究P / Invoking Multimedia Timers(例如,参见此内容 )或使用Stopwatch构建自己的计时器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM