''' 2021-06-07 It made sense (to me) to look into sound files. I've done so much work with image files, The shift seemed natural. Unfortunately, I do not care as much about sound, So, the base file never grew. # # # Created on Jan 27, 2015 @author: Brett Paufler Copyright Brett Paufler Sound Check Brief foray into sound files reduce fidelity Open, resize, (if true, funky sound) wav_to_png visulation of sorts graph_test look at input and output not much to do with sound... ''' #scipy.io.wavfile.write from scipy.signal import resample #from scipy.misc import imresize from scipy.io.wavfile import read, write import numpy as np import skimage.io import matplotlib.pyplot as plt def reduce_fidelity(wavFileIn, fraction=2, speedUp=False): '''creates a doubletime copy of the waveFile for a,b in [(a,b) for a in [2,4,1000] for b in [True, False]]: reduce_fidelity(fraction=a, speedUp=b) True creates a chipmunk effect, I believe ''' r, d = read(wavFileIn) if not speedUp: r = int(r / fraction) sA = resample(d, len(d)/fraction) sA = np.int16(sA) eN = "_reduce_fidelity_speed_%d_%r" % (fraction, speedUp) sN = wavFileIn[:-4] + eN + wavFileIn[-4:] write(sN, r, sA) def wav_to_png(wav_file_in): '''Visualization of wav files, very simplistic''' r, d = read(wav_file_in) print r print d print d.shape sA = resample(d, 1000) print sA.shape b = np.copy(sA) for _ in range(999): b = np.vstack((b,sA)) v = np.copy(b) h = np.rot90(np.copy(b),1) m = v * h skimage.io.imsave("sound_check_horizontal.png",h) skimage.io.imsave("sound_check_vertical.png",v) skimage.io.imsave("sound_check_multiply.png",m) def graph_test(): '''Graph output on sin wave input''' sW = np.array(np.arange(0.0,100.0,0.01)) print sW plt.figure(figsize=(10,3)) plt.title("Test Title") plt.plot(sW,np.sin(sW)) plt.plot(sW,np.cos(sW)) #plt.show() plt.savefig("sound_check_test_graph.png") if __name__ == '__main__': sound_file = "sound_check_raw_wav_file.wav" reduce_fidelity(sound_file) wav_to_png(sound_file) graph_test() print 'Sound Check Finished'