4

first: I don't know where to put this topic because it's an programming and sound-question. Please comment if it's at the wrong place.

But this is my question: How can I load a sound into Python and create the "reverse-sound" of it. So when I play the original and the "pi-shifted" file, they create an destructive interference and cancel each other out so you hear almost nothing. Are there any Libraries to use?

Here's a small explanation-video.

Thank you a lot. Just want to experiment a little.

4

1 に答える 1

9

オーディオをロードする最も簡単な方法pythonは、外部ライブラリ モジュールを使用することです。そのようなモジュールがpydub. 詳細はこちら

次に、あなたが話している reversing phaseのは、逆位相の2つの音を追加すると、それらが互いに打ち消し合うような入力音です。
には同じプリンシパルが使用されnoise cancelling technologyます。詳細はこちら

phase cancelling effect以下は、逆位相の 2 つのサウンドをマージし て示すサンプル コードです。

デモコード

from pydub import AudioSegment
from pydub.playback import play

#Load an audio file
myAudioFile = "yourAudioFile.wav"
sound1 = AudioSegment.from_file(myAudioFile, format="wav")

#Invert phase of audio file
sound2 = sound1.invert_phase()

#Merge two audio files
combined = sound1.overlay(sound2)

#Export merged audio file
combined.export("outAudio.wav", format="wav")

#Play audio file :
#should play nothing since two files with inverse phase cancel each other
mergedAudio = AudioSegment.from_wav("outAudio.wav")
play(mergedAudio)
于 2016-04-05T17:36:42.397 に答える