如果您要编写一个接收麦克风输入的程序,将其反转(通过将1的0和0的1设置为异相),然后从扬声器中播放它,是否可以取消声音? 波浪物理学说,如果波峰与波谷对齐,就会发生破坏性干扰,因此如果没有“完全”消除,可以利用这些来实现降低的噪声。 我可以想象,由于反转音频的复杂性,或者因为反转和回放需要太长时间,所以这不会起作用,因此声波已经过去了。 如果我必须将一种语言联系在一起,那就必须是c ++或java(我至少在两者中都胜任)。
If you were to write a program that takes microphone input, reverses it (sets it out of phase by making 1's 0's and 0's 1's), and plays it back out of the speakers, could that cancel out sound? Wave physics says if crests align with troughs, destructive interference occurs, so can that be utilized here to achieve a lessened noise if not canceled out "completely." I can imagine that this wouldn't work due to either complication in reversing the audio, or even because it takes too long to reverse and play back, so that the sound wave has passed. If i had to associate a language to do this in it would have to be either c++ or java (I'm at least competent in both).
最满意答案
是的它会取消声音。 这或多或少是环绕声的工作方式:通过减去左/右声道,在第三个扬声器中播放,以及反转样本,播放第四个声音,你会得到有趣的空间效果。
你也不会简单地想要切换所有位,你会得到噪音; 相反,你想要否定。
使用小样本缓冲区,您可以快速抵消某些频率的波形。 当这些攻击和腐烂时,你会落后,但只要波持续,你就可以有效地将其取消。
使用更大的样本缓冲区,显然延迟会增加,因为用样本填充缓冲区需要更长的时间。 缓冲区的大小决定了设备中断发生的频率,程序将输入样本复制到输出缓冲区,同时对它们进行操作。
通常录音是在44.1kHz,这意味着每秒钟有很多样本。 如果将缓冲区设置为256个样本,则每秒会收到44100/256次通知,要处理256个样本。
在256个样本处,您将落后于256/44100 = 0.0058秒或5.8毫秒。 声音以340米/秒的速度传播,因此声波将移动1.97米(340 * 5.8毫秒)。 该波长对应于频率172 Hz(44100/256)。 这意味着您只能有效地抵消频率低于此频率的频率,因为频率较高的频率在5.8ms内“移动”不止一次,因此高于最大“采样率”,如果愿意的话。
对于64个样本,频率将是44100/64 = 689Hz。 而且,这是最高频率! 这意味着你可以取消低音和人声的基频,但不能取消谐波。
典型的OS将其时钟频率设置为500,1000或2000 Hz,这意味着最多可以使用大约两到三个样本的样本缓冲区,最大频率为500,1000或2000 Hz。 电话通常具有大约3500Hz的最大频率。
您可以将系统时钟提升到32kHz左右,并直接轮询ADC以达到这样的频率。 但是,您可能需要将一个焊接到您的LPT并运行自定义操作系统,这意味着Java是不可能的,或者使用运行Java的预制实时嵌入式系统(请参阅@zapl的评论链接)。
我忘记提到的一件事是,您需要考虑声源,麦克风和扬声器的位置。 理想情况下,所有3个都在同一个地方,所以没有延迟。 但这几乎不是这种情况,这意味着你会得到一个干涉模式:声音被取消的房间里会有斑点,而不是它之间的斑点。
Yes it will cancel out sound. That's more or less how Surround Sound works: by subtracting the left/right channels, playing that in the 3rd speaker, and inverting the samples, playing those out of the 4th you get interesting spatial effects.
Also you wouldn't simply want to toggle all bits, you'd get noise; instead you want to negate.
With a small sample buffer you'd be fast enough to cancel out waves of certain frequencies. When these attack and decay, you'll be lagging, but as long as the wave sustains you can effectively cancel it out.
With bigger sample buffers, obviously the delay increases, since it takes longer to fill the buffer with samples. The size of the buffer determines how often a device interrupt occurs where the program would copy the input samples to an output buffer while applying an operation to them.
Typically recordings are made at 44.1kHz, meaning that many samples per second. If you set the buffer to say 256 samples, you would get notified 44100/256 times a second that there are 256 samples to be processed.
At 256 samples you'd lag behind 256/44100 = 0.0058 seconds or 5.8 milliseconds. Sound travels at around 340 m/s, so the sound wave would have moved 1.97 meters (340 * 5.8ms). This wavelength corresponds with the frequency 172 Hz (44100/256). That means that you can only effectively cancel out frequencies that have a lower frequency than that, because those of a higher frequency 'move' more than once during 5.8ms and are thus above the maximum 'sample rate', if you will.
For 64 samples, the frequency would be 44100/64 = 689 Hz. And, this is the maximum frequency! That means you could cancel out bass and the base frequency of the human voice, but not the harmonics.
A typical OS has it's clock frequency set to either 500, 1000, or 2000 Hz, meaning at best you could use a sample buffer of around two to three samples, giving you a maximum frequency of 500, 1000, or 2000 Hz. Telephones usually have a maximum frequency of about 3500 Hz.
You could get the system clock up to around 32kHz, and poll an ADC directly to reach such frequencies. However, you'd probably need to solder one to your LPT and run a custom OS, which means Java is out of the question, or use a pre-fab real-time embedded system that runs Java (see the comment by @zapl for links).
One thing I forgot to mention, is that you will need to take into account the position of the sound source, the microphone, and the speaker. Ideally all 3 are in the same place, so there is no delay. But this is almost never the case, which means you'd get an interference pattern: there will be spots in the room where the sound is cancelled, inbetween spots where it is not.
降噪计划(Noise cancelling program)如果您要编写一个接收麦克风输入的程序,将其反转(通过将1的0和0的1设置为异相),然后从扬声器中播放它,是否可以取消声音? 波浪物理学说,如果波峰与波谷对齐,就会发生破坏性干扰,因此如果没有“完全”消除,可以利用这些来实现降低的噪声。 我可以想象,由于反转音频的复杂性,或者因为反转和回放需要太长时间,所以这不会起作用,因此声波已经过去了。 如果我必须将一种语言联系在一起,那就必须是c ++或java(我至少在两者中都胜任)。
If you were to write a program that takes microphone input, reverses it (sets it out of phase by making 1's 0's and 0's 1's), and plays it back out of the speakers, could that cancel out sound? Wave physics says if crests align with troughs, destructive interference occurs, so can that be utilized here to achieve a lessened noise if not canceled out "completely." I can imagine that this wouldn't work due to either complication in reversing the audio, or even because it takes too long to reverse and play back, so that the sound wave has passed. If i had to associate a language to do this in it would have to be either c++ or java (I'm at least competent in both).
最满意答案
是的它会取消声音。 这或多或少是环绕声的工作方式:通过减去左/右声道,在第三个扬声器中播放,以及反转样本,播放第四个声音,你会得到有趣的空间效果。
你也不会简单地想要切换所有位,你会得到噪音; 相反,你想要否定。
使用小样本缓冲区,您可以快速抵消某些频率的波形。 当这些攻击和腐烂时,你会落后,但只要波持续,你就可以有效地将其取消。
使用更大的样本缓冲区,显然延迟会增加,因为用样本填充缓冲区需要更长的时间。 缓冲区的大小决定了设备中断发生的频率,程序将输入样本复制到输出缓冲区,同时对它们进行操作。
通常录音是在44.1kHz,这意味着每秒钟有很多样本。 如果将缓冲区设置为256个样本,则每秒会收到44100/256次通知,要处理256个样本。
在256个样本处,您将落后于256/44100 = 0.0058秒或5.8毫秒。 声音以340米/秒的速度传播,因此声波将移动1.97米(340 * 5.8毫秒)。 该波长对应于频率172 Hz(44100/256)。 这意味着您只能有效地抵消频率低于此频率的频率,因为频率较高的频率在5.8ms内“移动”不止一次,因此高于最大“采样率”,如果愿意的话。
对于64个样本,频率将是44100/64 = 689Hz。 而且,这是最高频率! 这意味着你可以取消低音和人声的基频,但不能取消谐波。
典型的OS将其时钟频率设置为500,1000或2000 Hz,这意味着最多可以使用大约两到三个样本的样本缓冲区,最大频率为500,1000或2000 Hz。 电话通常具有大约3500Hz的最大频率。
您可以将系统时钟提升到32kHz左右,并直接轮询ADC以达到这样的频率。 但是,您可能需要将一个焊接到您的LPT并运行自定义操作系统,这意味着Java是不可能的,或者使用运行Java的预制实时嵌入式系统(请参阅@zapl的评论链接)。
我忘记提到的一件事是,您需要考虑声源,麦克风和扬声器的位置。 理想情况下,所有3个都在同一个地方,所以没有延迟。 但这几乎不是这种情况,这意味着你会得到一个干涉模式:声音被取消的房间里会有斑点,而不是它之间的斑点。
Yes it will cancel out sound. That's more or less how Surround Sound works: by subtracting the left/right channels, playing that in the 3rd speaker, and inverting the samples, playing those out of the 4th you get interesting spatial effects.
Also you wouldn't simply want to toggle all bits, you'd get noise; instead you want to negate.
With a small sample buffer you'd be fast enough to cancel out waves of certain frequencies. When these attack and decay, you'll be lagging, but as long as the wave sustains you can effectively cancel it out.
With bigger sample buffers, obviously the delay increases, since it takes longer to fill the buffer with samples. The size of the buffer determines how often a device interrupt occurs where the program would copy the input samples to an output buffer while applying an operation to them.
Typically recordings are made at 44.1kHz, meaning that many samples per second. If you set the buffer to say 256 samples, you would get notified 44100/256 times a second that there are 256 samples to be processed.
At 256 samples you'd lag behind 256/44100 = 0.0058 seconds or 5.8 milliseconds. Sound travels at around 340 m/s, so the sound wave would have moved 1.97 meters (340 * 5.8ms). This wavelength corresponds with the frequency 172 Hz (44100/256). That means that you can only effectively cancel out frequencies that have a lower frequency than that, because those of a higher frequency 'move' more than once during 5.8ms and are thus above the maximum 'sample rate', if you will.
For 64 samples, the frequency would be 44100/64 = 689 Hz. And, this is the maximum frequency! That means you could cancel out bass and the base frequency of the human voice, but not the harmonics.
A typical OS has it's clock frequency set to either 500, 1000, or 2000 Hz, meaning at best you could use a sample buffer of around two to three samples, giving you a maximum frequency of 500, 1000, or 2000 Hz. Telephones usually have a maximum frequency of about 3500 Hz.
You could get the system clock up to around 32kHz, and poll an ADC directly to reach such frequencies. However, you'd probably need to solder one to your LPT and run a custom OS, which means Java is out of the question, or use a pre-fab real-time embedded system that runs Java (see the comment by @zapl for links).
One thing I forgot to mention, is that you will need to take into account the position of the sound source, the microphone, and the speaker. Ideally all 3 are in the same place, so there is no delay. But this is almost never the case, which means you'd get an interference pattern: there will be spots in the room where the sound is cancelled, inbetween spots where it is not.
发布评论