I think I have now worked out what to do.
Hopefully more comprehension will come with time.
Code:
#!/usr/bin/env python3import numpyimport soundfile as sfduration = 0.1 # base in secondsamplitude = 0.1 # range [0.0, 1.0]sampleRate = 44100 # integer sample rate, Hzfrequency = 440.0 # float sine frequency, Hz# generate sine sample, with float32 array conversiondit = (numpy.sin( numpy.arange(sampleRate * duration) * frequency / sampleRate \ * numpy.pi * 2 )).astype(numpy.float32)dah = numpy.concatenate((dit, dit, dit))dit = (amplitude * dit)dah = (amplitude * dah)gap = (0 * dit)r = numpy.concatenate((dit, gap, dah, gap, dit))sf.write('audio.flac', r, sampleRate)exit(0)
Statistics: Posted by tpyo kingg — Sat Feb 10, 2024 12:04 pm