Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import streams as s
- const
- WAVFILE_SAMPLES_PER_SECOND = 44_100
- BITS_PER_SAMPLE = 16
- NUMBER_OF_CHANNELS = 1 # 1 for mono, 2 for stero
- type
- WAV = object
- rtag: string
- rlen: int
- wtag: string
- ftag: string
- flen: int
- afmt: int16
- nchl: int16
- srte: int
- brte: int
- baln: int16
- bsps: int16
- dtag: string
- dlen: int
- var
- wav: WAV
- wav.rtag = "RIFF"
- wav.rlen = 0
- wav.wtag = "WAVE"
- wav.ftag = "fmt "
- wav.flen = 16
- wav.afmt = 1
- wav.nchl = NUMBER_OF_CHANNELS
- wav.srte = WAVFILE_SAMPLES_PER_SECOND
- wav.brte = WAVFILE_SAMPLES_PER_SECOND*int(BITS_PER_SAMPLE/8)
- wav.baln = int16(BITS_PER_SAMPLE/8)
- wav.bsps = BITS_PER_SAMPLE
- wav.dtag = "data"
- wav.dlen = 0
- var fs = s.newFileStream("test.wav", fmWrite)
- if not isNil(fs):
- fs.write(wav)
- fs.close()
Advertisement
Add Comment
Please, Sign In to add comment