Revision 6:fd0f9d0615b2 7-synthesize-stereo-sines-with-numpy.py
| 7-synthesize-stereo-sines-with-numpy.py | ||
|---|---|---|
| 1 | 1 |
import numpy as np |
| 2 |
import pylab as plt |
|
| 2 | 3 |
from scikits.audiolab import Sndfile |
| 3 | 4 |
from scikits.audiolab import Format |
| 4 | 5 |
|
| ... | ... | |
| 27 | 28 |
|
| 28 | 29 |
# generate tone and set volume for left and right |
| 29 | 30 |
tone[i][0] = np.sin(2*np.pi*freq*phaseVal)*amp |
| 30 |
tone[i][1] = np.sin(2*np.pi*freq*phaseVal)*amp
|
|
| 31 |
tone[i][1] = np.sin(2*np.pi*(freq*2)*phaseVal)*amp
|
|
| 31 | 32 |
|
| 32 | 33 |
|
| 33 | 34 |
################################################# |
| ... | ... | |
| 47 | 48 |
# close the audio file |
| 48 | 49 |
f.close() |
| 49 | 50 |
|
| 51 |
|
|
| 52 |
################################################# |
|
| 53 |
############### PLOT USING PYLAB ################ |
|
| 54 |
################################################# |
|
| 55 |
|
|
| 56 |
toneL = tone[:,0] |
|
| 57 |
toneR = tone[:,1] |
|
| 58 |
|
|
| 59 |
plt.subplot(211) |
|
| 60 |
plt.plot(toneL[0:200]) |
|
| 61 |
plt.subplot(212) |
|
| 62 |
plt.plot(toneR[0:200]) |
|
| 63 |
plt.show() |
|
Also available in: Unified diff