示例#1
0
    def soundGenerationForFramePurpose(self, objects):

        tmp = time.clock() - self.t
        sample = []
        if tmp >= 1. / 24:  # for each frame we want the previous sound to be finished before lauching a new one
            self.totalTime = self.totalTime + tmp
            self.t = time.clock()

            sample = self.genSampleFromObjects(objects, tmp)

            #if (self.lastFrame[0][0] == sample[0][0]) :
            #    print ("same as last frame")
            #else :
            #    print ("diferent sample")

            if (len(sample) != 0):

                self.smoothenStart(sample, int(len(sample) / 50.))
                self.scale(sample[0], -1., 1.)
                self.scale(sample[1], -1., 1.)

                save_stdout = sys.stdout
                sys.stdout = open('trash', 'w')
                play(sample, self.fs)
                sys.stdout = save_stdout

            self.lastFrame = sample
        return sample
示例#2
0
from Vid.Aud.soundgenerator import SoundGenerator
import numpy as np
from scipy.io.wavfile import write as wavwrite
from scipy.io.wavfile import read as wavread
import matplotlib.pyplot as plt
from scipy import signal
from scipy import stats
import scipy.fftpack as fftp
import pylab as py
import math
from audiolab import play
import sys
import time

sound = SoundGenerator("ressources/lb_idle.wav")

fs, s = wavread("ressources/lb_idle.wav")

s = sound.scale(s, -1., 1)
s = sound.sound2ChanelsWlength(s, 2 * fs)

print(fs)

spb = sound.filtrePB(s, 100)
sph = sound.filtrePH(s, 100)

play(sph, fs)
示例#3
0
from audiolab import play, wavread

data, fs, enc = wavread('test.wav')
# There is a discrepency between wavread (one column per channel) and play
# convention (one row per channel). Audiolab will be fully converted to 'numpy
# conventions' (last axis per default) after version 0.9
play(data.T, fs)
示例#4
0
import audiolab
import scipy
from pylab import *

x, fs, nbits = audiolab.wavread('laser_resampled.wav')
audiolab.play(x, fs)
N = 4*fs    # four seconds of audio
X = scipy.fft(x[:N])
Xdb = 20*scipy.log10(scipy.absolute(X))
f = scipy.linspace(0, fs, N, endpoint=False)
pylab.plot(f, Xdb)
pylab.xlim(0, 5000)   # view up to 5 kHz

Y = X*H
y = scipy.real(scipy.ifft(Y))




"""import pymedia
import time
import matplotlib.pyplot as plt
import matplotlib.mlab as mlab
import numpy as np
import pylab as P

f = open('manybeeps_resampled.wav', 'rb')
s=f.read()

spa = pymedia.audio.sound.SpectrAnalyzer(1, 575, 1024)
bands= spa.asBands(5, s)
示例#5
0
import numpy as np
from audiolab import play

# output one second of stereo gaussian white noise at 48000 hz
play(0.05 * np.random.randn(2, 48000))