import sys sys.path.insert(1, 'dsp-modulo') from thinkdsp import SinSignal from thinkdsp import CosSignal from thinkdsp import decorate import matplotlib.pyplot as plt seno = SinSignal(freq=20, amp=1, offset=0) coseno = CosSignal(freq=50, amp=1.3, offset=0) waveSeno = seno.make_wave(duration=1, start=0, framerate=11025) waveCoseno = coseno.make_wave(duration=1, start=0, framerate=11025) waveResultante = waveSeno + waveCoseno decorate(xlabel="Tiempo (s)") decorate(ylabel="Amplitud") waveSeno.plot() waveCoseno.plot() plt.show() decorate(xlabel="Tiempo (s)") decorate(ylabel="Amplitud") waveResultante.plot() plt.show()
from thinkdsp import CosSignal, SinSignal from thinkdsp import decorate import matplotlib.pyplot as plt cos_sig = CosSignal(freq=440, amp=1.0, offset=0) sin_sig = SinSignal(freq=880, amp=0.5, offset=0) mix = sin_sig + cos_sig wave = mix.make_wave(duration=0.01, start=0, framerate=11025) wave.play('test3.wav') wave.normalize() wave.make_audio() plt.subplot(2, 1, 1) wave.plot() spectrum = wave.make_spectrum() plt.subplot(2, 1, 2) spectrum.plot(high=5000) decorate(xlabel='Frequency (Hz)') plt.show()
#import sys #sys.path.insert(1,'dsp-modulo') from thinkdsp import SinSignal from thinkdsp import CosSignal from thinkdsp import decorate #modulo para mostrar las graficas import matplotlib.pyplot as plt #crear señal senoidal seno = SinSignal(freq=200, amp=0.7, offset=0) coseno = CosSignal(freq=800, amp=1.1, offset=0) #creamos grafica y asignamos propiedades seno.plot() coseno.plot() decorate(xlabel='Tiempo (s)') decorate(ylabel='Amplitud') plt.show()
import sys sys.path.insert(1, 'dsp-modulo') from thinkdsp import SinSignal from thinkdsp import CosSignal from thinkdsp import decorate #Módulo para graficar import matplotlib.pyplot as plt #Crear señal senoidal seno = SinSignal(freq=329.628, amp=50, offset=0) coseno = CosSignal(freq=41.2035, amp=30, offset=0) #Crear gráfica en memoria y damos propiedades seno.plot() decorate(xlabel='Tiempo (s)') decorate(ylabel='Amplitud') coseno.plot() plt.show()
from thinkdsp import CosSignal, SinSignal, decorate import matplotlib.pyplot as plt cosine_signal = CosSignal(freq=440, amp=1.0, offset=0) sine_signal = SinSignal(freq=880, amp=0.5, offset=0) cosine_signal.plot() decorate(xlabel='Time (s)') # figure, (axes1, axes2) = plt.subplots(nrows=2) # axes1.plot(cosine_signal) # axes1.set_xlabel('Time (s)') plt.show()
import matplotlib.pyplot as plt from thinkdsp import TriangleSignal, decorate, SquareSignal, SawtoothSignal, CosSignal signal = CosSignal(4500) duration = signal.period * 5 segment = signal.make_wave(duration, framerate=10000) plt.rcParams['font.sans-serif'] = ['SimHei'] plt.rcParams['axes.unicode_minus'] = False decorate(xlabel='Time (s)') plt.subplot(121) segment.plot() signal = CosSignal(5500) duration = signal.period * 5 segment = signal.make_wave(duration, framerate=10000) decorate(xlabel='Frequency (Hz)') plt.subplot(122) segment.plot() plt.show()
import os import librosa import numpy as np from scipy.io.wavfile import write from thinkdsp import read_wave, CosSignal wave = read_wave('105977__wcfl10__favorite-station.wav') carrier_sig = CosSignal(freq=440) carrier_wave = carrier_sig.make_wave(duration=wave.duration, framerate=wave.framerate) modulated = wave * carrier_wave # amplitude modulation - multiplying the input wave by a carrier wave in the time domain modulated.make_audio() modulated.play('out1.wav') y, sr = librosa.load( '105977__wcfl10__favorite-station.wav', sr=44100) # y is a numpy array of the wav file, sr = sample rate y_shifted = librosa.effects.pitch_shift(y, sr, n_steps=-8) # shifted by n_steps # pitch shift - a step is equal to a semitone write('out2.wav', 44100, y_shifted) print('Writing out2.wav') #combining amplitude modulation and pitch shift together for greater voice modulation y, sr = librosa.load('out1.wav', sr=44100) y_shifted = librosa.effects.pitch_shift(y, sr, n_steps=-8) write('out1_2.wav', 44100, y_shifted)