Last active
October 3, 2017 04:14
-
-
Save catfact/fd5ae70744363c6a94a6f729b597163f to your computer and use it in GitHub Desktop.
simple waveform audio files in supercollider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// function to make a sine | |
var export_sine = { | |
arg hz, dur, amp = 0.5, sr = 48000; | |
var sf, path; | |
var cycles = dur * hz; | |
var samplesPerCycle = sr / hz; | |
// specify some other array of harmonics here for richer waveforms | |
var signal = Signal.sineFill(samplesPerCycle, [1.0]) * amp; | |
// { signal.plot; }.defer; | |
path = PathName(Document.current.path).pathOnly ; | |
path = path ++ "sine_" ++ hz.asString ++ "hz.wav"; | |
path.postln; | |
sf = SoundFile.new | |
.headerFormat_("WAV") | |
.sampleFormat_("int16") | |
.sampleRate_(sr) | |
.numChannels_(1); | |
sf.openWrite(path); | |
cycles.do({ sf.writeData(signal); }); | |
sf.close; | |
}; | |
// make some sines | |
4.do({ arg i; | |
export_sine.value(110 * (i+1), 10.0); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment