Ejemplo n.º 1
0
import matplotlib.pyplot as plot
import WAV as wav
import STFT as stft
from Oscillator import *

# Load sample input...
# x, sr = wav.read("wav/tomsawyer.wav")

# or produce cos wave
# sr = 44100.0
# osc = Oscillator(sr, 440.0)
# x = 0.5 * osc.getBuffer(123456)

# Set STFT parameters
winSize = 1024*2      # in samples
hopSize = winSize/4   # in samples

# Build output signal
frames = stft.stft(x, winSize, hopSize)
y = stft.istft(frames, winSize, hopSize)

# Plot x-y difference
n = min(len(x), len(y))
diff = abs(x[0:n] - y[0:n])
plot.figure()
plot.plot(diff, "b")
plot.show()

# Write out results
wav.write(x, sr, "wav/stft_input.wav")
wav.write(y, sr, "wav/stft_output.wav")
Ejemplo n.º 2
0
import matplotlib.pyplot as plot
import WAV as wav
import STFT as stft
from Oscillator import *

# Load sample input...
# x, sr = wav.read("wav/tomsawyer.wav")

# or produce cos wave
# sr = 44100.0
# osc = Oscillator(sr, 440.0)
# x = 0.5 * osc.getBuffer(123456)

# Set STFT parameters
winSize = 1024 * 2  # in samples
hopSize = winSize / 4  # in samples

# Build output signal
frames = stft.stft(x, winSize, hopSize)
y = stft.istft(frames, winSize, hopSize)

# Plot x-y difference
n = min(len(x), len(y))
diff = abs(x[0:n] - y[0:n])
plot.figure()
plot.plot(diff, "b")
plot.show()

# Write out results
wav.write(x, sr, "wav/stft_input.wav")
wav.write(y, sr, "wav/stft_output.wav")
Ejemplo n.º 3
0
filename = "tomsawyer.wav"

# Load sample input
x, sr = wav.read("wav/" + filename)

# Set VAD parameters
winSize = int(sr*20e-3)         # in samples (fs*s)
hopSize = winSize               # in samples
smoothingGain = [0.3, 0.02]     # small numbers
triggerThresholds = [-25, -20]  # in dBFS

# Estimate silent frames
vadFlags = vad(x, winSize, hopSize, smoothingGain, triggerThresholds)

# Mute silent frames
y = mute(x, winSize, hopSize, vadFlags)

# Plot results
plot.figure()
plot.plot(x, "b")
plot.plot(y, "r")
plot.plot(range(0, len(y)-winSize, hopSize), vadFlags[:,1], "g--")
plot.legend(("Input signal", "Output signal", "Signal offset"))
plot.show()

# Write out results
wav.write(x, sr, "wav/automute_input.wav")
wav.write(y, sr, "wav/automute_output.wav")

plot.savefig("wav/test/Results/" + filename + ".pdf", dpi=600)
wav.write(y, sr, "wav/test/Results/" + filename)
Ejemplo n.º 4
0
# Load sample input
x, sr = wav.read("wav/" + filename)

# Set VAD parameters
winSize = int(sr * 20e-3)  # in samples (fs*s)
hopSize = winSize  # in samples
smoothingGain = [0.3, 0.001]  # small numbers
triggerThresholds = [-25, -20]  # in dBFS

# Estimate silent frames
vadFlags = vad(x, winSize, hopSize, smoothingGain, triggerThresholds)

# Mute silent frames
y = mute(x, winSize, hopSize, vadFlags)

# Plot results
plot.figure()
plot.plot(x, "b")
plot.plot(y, "r")
plot.plot(range(0, len(y) - winSize + 1, hopSize), vadFlags[:, 1], "g--")
plot.legend(("Input signal", "Output signal", "Signal offset"))
plot.show()

# Write out results
wav.write(x, sr, "wav/automute_input.wav")
wav.write(y, sr, "wav/automute_output.wav")

# plot.savefig("wav/test/Results/" + filename + ".pdf", dpi=600)
# wav.write(y, sr, "wav/test/Results/" + filename)
Ejemplo n.º 5
0
from numpy import *
import WAV as wav
from Oscillator import *

# Load sample input
[x, sr] = wav.read('wav/tomsawyer.wav')

# Make cos wave
osc = Oscillator(sr, 500.0)
f = osc.getBuffer(len(x))

# Shift frequency by f Hz
y = multiply(x, f)

# Write out results
wav.write(x, sr, "wav/freqshift_input.wav")
wav.write(y, sr, "wav/freqshift_output.wav")
Ejemplo n.º 6
0
filename = "tomsawyer.wav"

# Load sample input
x, sr = wav.read("wav/" + filename)

# Set VAD parameters
winSize = int(sr * 20e-3)  # in samples (fs*s)
hopSize = winSize  # in samples
smoothingGain = [0.3, 0.001]  # small numbers
triggerThresholds = [-25, -20]  # in dBFS

# Estimate silent frames
vadFlags = vad(x, winSize, hopSize, smoothingGain, triggerThresholds)

# Mute silent frames
y = mute(x, winSize, hopSize, vadFlags)

# Plot results
plot.figure()
plot.plot(x, "b")
plot.plot(y, "r")
plot.plot(range(0, len(y) - winSize + 1, hopSize), vadFlags[:, 1], "g--")
plot.legend(("Input signal", "Output signal", "Signal offset"))
plot.show()

# Write out results
wav.write(x, sr, "wav/automute_input.wav")
wav.write(y, sr, "wav/automute_output.wav")

# plot.savefig("wav/test/Results/" + filename + ".pdf", dpi=600)
# wav.write(y, sr, "wav/test/Results/" + filename)
Ejemplo n.º 7
0
filename = "tomsawyer.wav"

# Load sample input
x, sr = wav.read("wav/" + filename)

# Set VAD parameters
winSize = int(sr * 20e-3)  # in samples (fs*s)
hopSize = winSize  # in samples
smoothingGain = [0.3, 0.02]  # small numbers
triggerThresholds = [-25, -20]  # in dBFS

# Estimate silent frames
vadFlags = vad(x, winSize, hopSize, smoothingGain, triggerThresholds)

# Mute silent frames
y = mute(x, winSize, hopSize, vadFlags)

# Plot results
plot.figure()
plot.plot(x, "b")
plot.plot(y, "r")
plot.plot(range(0, len(y) - winSize, hopSize), vadFlags[:, 1], "g--")
plot.legend(("Input signal", "Output signal", "Signal offset"))
plot.show()

# Write out results
wav.write(x, sr, "wav/automute_input.wav")
wav.write(y, sr, "wav/automute_output.wav")

plot.savefig("wav/test/Results/" + filename + ".pdf", dpi=600)
wav.write(y, sr, "wav/test/Results/" + filename)