|
Revision 514, 0.9 kB
(checked in by shans, 1 year ago)
|
Modified sounds to only accept start (not length as well). Makes shift and
repeat easier, and makes more sense overall.
|
| Line | |
|---|
| 1 |
(* middle A has a frequency of 440 Hz. at a samplerate of 44 kHz, that is |
|---|
| 2 |
a period of 100 samples *) |
|---|
| 3 |
|
|---|
| 4 |
let rate = float_of_string Sys.argv.(1);; |
|---|
| 5 |
let amp = float_of_string Sys.argv.(2);; |
|---|
| 6 |
let len = float_of_string Sys.argv.(3);; |
|---|
| 7 |
|
|---|
| 8 |
let r = Remix.create 44000 2 120.;; |
|---|
| 9 |
let four_second_A = Wave.sin (Volume.ramp (Time.Seconds len) 0. amp) rate;; |
|---|
| 10 |
let envelope = Envelope.adsr (Time.Seconds len) (Time.Seconds 0.1) |
|---|
| 11 |
(Time.Seconds 0.4) 0.8 (Time.Seconds 0.1);; |
|---|
| 12 |
|
|---|
| 13 |
let env_a = Envelope.apply envelope four_second_A;; |
|---|
| 14 |
|
|---|
| 15 |
(* |
|---|
| 16 |
let out = IO.output_channel (Unix.out_channel_of_descr (Unix.openfile "tst.wav" |
|---|
| 17 |
[Unix.O_TRUNC ; Unix.O_WRONLY ; Unix.O_CREAT] 0o644));; |
|---|
| 18 |
|
|---|
| 19 |
Sound.write r out env_a (Time.Seconds 0., Time.Seconds len);; |
|---|
| 20 |
*) |
|---|
| 21 |
Sound.preview r env_a (Time.Seconds 0.0) (Time.Seconds 0.0, Time.Seconds len);; |
|---|