Example #1
0
def constantFrequencyExample(start=1.9, duration=0.5):
    filteredSignal = helpers.getSignal(start, duration, low_pass=100, high_pass=90, input_file="raw-epdf.wav")
    spectrum = helpers.getSpectrum(start, duration, low_pass=100, high_pass=90, input_file="raw-epdf.wav")

    segment = helpers.getSegment(start, duration, input_file="raw-epdf.wav")
    helpers.makeWavFromSpectrum(spectrum, segment, outputFile="recoveredWav.wav")
    # firstPeak = min([i[0] for i in spectrum.peaks()])
    helpers.plot(spectrum)
Example #2
0
def frequencyToAttenuation(absorbtionRate, baseF, f):
	return absorbtionRate*(f/1.0/baseF)**2

def attenuationFactor(distance, absorbtionRate, baseF, f):
	"""
	Distance is in units of Km
	"""
	return decibelToAmplitude(frequencyToAttenuation(distance*absorbtionRate, baseF, f))

def getBaseFrequency(signal):
	spectrum = signal.make_spectrum()
	return spectrum.fs[1]

def underWaterSpectrum(signal, distance, absorbtionRate):
	spectrum = signal.make_spectrum()
	originalSpectrum = signal.make_spectrum()
	baseFrequency = getBaseFrequency(signal)
	index = 0;

	for freq in spectrum.fs:
		attenuation = attenuationFactor(distance, absorbtionRate, baseFrequency, freq)
		spectrum.amps[index] = spectrum.amps[index]/attenuation
		index += 1
	helpers.plot(spectrum)
	return spectrum

segment = helpers.getSegment(input_file='92002__jcveliz__violin-origional.wav')
signal = helpers.getSignal(input_file='92002__jcveliz__violin-origional.wav', duration=2)
spectrum = underWaterSpectrum(signal, 10, 1)
helpers.makeWavFromSpectrum(spectrum, segment, 'underwater.wav')
Example #3
0
def periodic_signal_example(start=1.9, duration=4.8):
	filteredSignal = helpers.getSignal(start, duration, low_pass=100, high_pass=90, input_file="raw-epdf.wav")
	helpers.plot(filteredSignal)