def effect3(): effect = \ (AudioEffectsChain() .highshelf() .reverb() .phaser() .delay() .lowshelf()) return effect
def effect2(): effect = \ (AudioEffectsChain() .equalizer(50, 1.0, 10.0) .equalizer(100, 1.0, 10.0) .equalizer(200, 1.0, 10.0) .equalizer(500, 1.0, 10.0) .equalizer(1000, 1.0, 10.0) .equalizer(2000, 1.0, 10.0) .equalizer(5000, 1.0, 10.0) .equalizer(10000, 1.0, 10.0) .equalizer(20000, 1.0, 10.0)) return effect
"""Testing module for the DSP package, preferably run with py.test.""" import logging import librosa as lr import soundfile as sf from pysndfx.dsp import AudioEffectsChain logger = logging.getLogger('pysndfx') logger.setLevel(logging.DEBUG) apply_audio_effects = \ (AudioEffectsChain() .highshelf() .reverb() .phaser() .delay() .lowshelf()) infile = lr.util.example_audio_file() mono, sr = lr.load(infile, sr=None) stereo, _ = lr.load(infile, sr=None, mono=False) outfile = 'test_output.ogg' def test_file_to_file(): apply_audio_effects(infile, outfile) y = lr.load(outfile, sr=None, mono=False)[0] sf.write('test_file_to_file.wav', y.T, sr) assert lr.util.valid_audio(y, mono=False)
# coding=utf-8 """Testing module for the DSP package, preferably run with py.test.""" import numpy as np import librosa as lr from pysndfx.dsp import AudioEffectsChain apply_audio_effects = AudioEffectsChain()\ .highshelf()\ .reverb()\ .phaser()\ .delay()\ .lowshelf() infile = lr.util.example_audio_file() mono, sr = lr.load(infile, sr=None) stereo, _ = lr.load(infile, sr=None, mono=False) outfile = 'test_output.ogg' def test_file_to_file(): apply_audio_effects(infile, outfile) y = lr.load(outfile, sr=None, mono=False)[0] lr.output.write_wav('test_file_to_file.wav', y, sr) assert lr.util.valid_audio(y, mono=False) def test_ndarray_to_ndarray(): y = apply_audio_effects(mono) lr.output.write_wav('test_ndarray_to_ndarray_mono.wav', y, sr) assert lr.util.valid_audio(y)
def effect0(): effect = (AudioEffectsChain().vol(6, 'dB', '0.02')) return effect
elif e == 2: effect = effect2() elif e == 3: effect = effect3() y = effect(mono) print(filename + "_" + str(e) + ext) lr.output.write_wav(filename + "_" + str(e) + ext, y, sr) assert lr.util.valid_audio(y, mono=False) apply_audio_effects1 = \ (AudioEffectsChain() .equalizer(50, 1.0, -10.0) .equalizer(100, 1.0, -10.0) .equalizer(200, 1.0, -10.0) .equalizer(500, 1.0, -10.0) .equalizer(1000, 1.0, -10.0) .equalizer(2000, 1.0, -10.0) .equalizer(5000, 1.0, -10.0) .equalizer(10000, 1.0, -10.0) .equalizer(20000, 1.0, -10.0)) apply_audio_effects2 = \ (AudioEffectsChain() .equalizer(50, 1.0, 10.0) .equalizer(100, 1.0, 10.0) .equalizer(200, 1.0, 10.0) .equalizer(500, 1.0, 10.0) .equalizer(1000, 1.0, 10.0) .equalizer(2000, 1.0, 10.0) .equalizer(5000, 1.0, 10.0) .equalizer(10000, 1.0, 10.0)
# This script test the pysndfx code on a simple 440hz sine wav file # Import the package and create an audio effects chain function. from pysndfx.dsp import AudioEffectsChain import numpy as np import os.path from scipy import signal from scipy.io.wavfile import read, write import sounddevice as sd fx = ( AudioEffectsChain() #.highshelf() #.reverb() #.phaser(decay=0.5, triangular=True) .pitch(-1000) #.delay() #.lowshelf() ) def genTestWav(): frequency = 440 # Our played note will be 440 Hz fs = 44100 # 44100 samples per second seconds = 3 # Note duration of 3 seconds # Generate array with seconds*sample_rate steps, ranging between 0 and seconds t = np.linspace(0, seconds, seconds * fs, False) # Generate a 440 Hz sine wave note = np.sin(frequency * t * 2 * np.pi).astype(np.int16)
from pydub import AudioSegment from pysndfx.dsp import AudioEffectsChain fx = (AudioEffectsChain().reverb().phaser()) songName = input("name of song: ") out = "text.ogg" def converter(inName): song = AudioSegment.from_wav(inName).split_to_mono() faded1 = song[0].fade(to_gain=0, start=0, duration=3100) faded2 = song[1].fade(to_gain=0, start=0, duration=1000) fadedL = faded1 fadedr = faded2.fade(to_gain=-12, start=1000, duration=600) fadedR = fadedr.fade(to_gain=0, start=1600, duration=1500) st = 3100 gain = -4 n = 1 while st < len(song[0]): fadedL = fadedL.fade(to_gain=(gain), start=st, duration=600) if n % 3 == 0: fadedL = fadedL.fade(to_gain=0, start=st + 600, duration=1500) st += 2100 gain *= -1