| 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 s n = Time.Seconds n;; |
|---|
| 5 |
|
|---|
| 6 |
let note = Note.from_sound (Wave.sin (Volume.constant 30000.) 440.);; |
|---|
| 7 |
let envelope = Note.from_envelope |
|---|
| 8 |
(Envelope.adsr (s 0.75) (s 0.1) (s 0.4) 0.8 (s 0.1));; |
|---|
| 9 |
let envelope2 = Note.from_envelope |
|---|
| 10 |
(Envelope.adsr (s 0.8) (s 0.2) (s 0.2) 0.9 (s 0.3));; |
|---|
| 11 |
let envelope3 = Note.from_envelope |
|---|
| 12 |
(Envelope.adsr (s 0.85) (s 0.3) (s 0.3) 0.9 (s 0.2));; |
|---|
| 13 |
|
|---|
| 14 |
let continuous = (Time.Seconds 0.0, Time.Forever);; |
|---|
| 15 |
|
|---|
| 16 |
let sound_layer = Layer.empty ();; |
|---|
| 17 |
Layer.add_note sound_layer note continuous;; |
|---|
| 18 |
|
|---|
| 19 |
let env_layer = Layer.empty ();; |
|---|
| 20 |
Layer.add_note env_layer |
|---|
| 21 |
(NoteUtil.repeat (Time.Seconds 0.75) envelope) continuous;; |
|---|
| 22 |
Layer.add_transparency env_layer (Transparency.constant 0.5) continuous;; |
|---|
| 23 |
|
|---|
| 24 |
let env_layer2 = Layer.empty ();; |
|---|
| 25 |
Layer.add_note env_layer2 |
|---|
| 26 |
(NoteUtil.repeat (Time.Seconds 0.8) envelope2) continuous;; |
|---|
| 27 |
Layer.add_transparency env_layer2 (Transparency.constant 0.33) continuous;; |
|---|
| 28 |
|
|---|
| 29 |
let env_layer3 = Layer.empty ();; |
|---|
| 30 |
Layer.add_note env_layer3 |
|---|
| 31 |
(NoteUtil.repeat (Time.Seconds 0.85) envelope3) continuous;; |
|---|
| 32 |
Layer.add_transparency env_layer3 (Transparency.constant 0.5) continuous;; |
|---|
| 33 |
|
|---|
| 34 |
let track = Track.empty ();; |
|---|
| 35 |
Track.add_layer track env_layer3;; |
|---|
| 36 |
Track.add_layer track env_layer2;; |
|---|
| 37 |
Track.add_layer track env_layer;; |
|---|
| 38 |
Track.add_layer track sound_layer;; |
|---|
| 39 |
|
|---|
| 40 |
let r = Remix.create 44000 2 120.;; |
|---|
| 41 |
Sound.preview r (Track.to_note track Sound.silence) (s 0.) continuous;; |
|---|