- """ create a pure tone """
- # samples indices
- _t = np.tile(np.arange(nframes), (nchannels, 1))
- # sine wave generation
- _x = 0.7 * np.sin(2. * np.pi * freq * _t / float(samplerate))
- # conversion to int and channel interleaving
- return (_x * 32767.).astype(np.int16).T.flatten()
+ """ create a pure tone (without numpy) """
+ _x = [0.7 * math.sin(2. * math.pi * freq * t / float(samplerate))
+ for t in range(nframes)]
+ _x = [int(a * 32767) for a in _x]
+ _x = b''.join([b''.join([struct.pack('h', v)
+ for _ in range(nchannels)])
+ for v in _x])
+ return _x