コード例 #1
0
ファイル: test1-3.py プロジェクト: mooWw/moo.github.io
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()
コード例 #2
0
#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()
コード例 #3
0
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()
コード例 #4
0
ファイル: Signals.py プロジェクト: ResilientSpring/Python
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()
コード例 #5
0
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()
コード例 #6
0
ファイル: test.py プロジェクト: edwardgallyot/ThinkDSP
from thinkdsp import CosSignal, SinSignal
from thinkdsp import decorate

cos_sig = CosSignal(freq=440, amp=1, offset=0)
sin_sig = SinSignal(freq=880, amp=0.5, offset=0)

cos_sig.plot()
decorate(xlabel='Time (s)')

コード例 #7
0
import os

if not os.path.exists('thinkdsp.py'):
    get_ipython().system(
        'wget https://github.com/AllenDowney/ThinkDSP/raw/master/code/thinkdsp.py'
    )

# ## Signals
#
# Instantiate cosine and sine signals.

# In[33]:

from thinkdsp import CosSignal, SinSignal

cos_sig = CosSignal(freq=450, amp=1.0, offset=0)
sin_sig = SinSignal(freq=900, amp=0.5, offset=0)

# Plot the sine and cosine signals.  By default, `plot` plots three periods.

# In[34]:

from thinkdsp import decorate

cos_sig.plot()
decorate(xlabel='Time (s)')

# Here's the sine signal.

# In[35]:
コード例 #8
0
ファイル: 混叠.py プロジェクト: 54hdh/test
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()
コード例 #9
0
ファイル: WaveModulation.py プロジェクト: NagaSadow/SPM
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)
コード例 #10
0
plt.show()
segment.segment(start=1.1, duration=0.005).plot()
spectrum = segment.make_spectrum()
spectrum.plot(high=7000)
plt.show()
spectrum.low_pass(4000)
spectrum.plot(high=7000)
plt.show()
spectrum.high_pass(1000)
spectrum.plot(high=7000)
plt.show()
spectrum.band_stop(2500, 1000)
spectrum.plot(high=7000)
plt.show()

cos_sig = CosSignal(freq=440, amp=1.0, offset=0)
sin_sig = SinSignal(freq=880, amp=2.0, offset=0)
# # 正弦信号和波形
plt.subplot()
cos_sig.plot()
decorate(xlabel='Time (s)')

wave1 = cos_sig.make_wave(duration=1)
wave1.apodize()
wave1.make_audio()
spectrum1 = wave1.make_spectrum()
plt.subplot()
spectrum1.plot(high=2000)

# # 余弦信号和波形
sin_sig.plot()