|
Revision 514, 0.7 kB
(checked in by shans, 5 years ago)
|
Modified sounds to only accept start (not length as well). Makes shift and
repeat easier, and makes more sense overall.
|
| Line | |
|---|
| 1 |
type volume = |
|---|
| 2 |
| Constant of float |
|---|
| 3 |
| Linear of Time.time * float * float;; |
|---|
| 4 |
|
|---|
| 5 |
exception AmplitudeTooHigh |
|---|
| 6 |
|
|---|
| 7 |
let constant v = if (v > 32767. || v < 0.) then raise AmplitudeTooHigh; |
|---|
| 8 |
Constant v;; |
|---|
| 9 |
|
|---|
| 10 |
let ramp l s e = if (s > 32767. || s < 0.) then raise AmplitudeTooHigh; |
|---|
| 11 |
if (e > 32767. || e < 0.) then raise AmplitudeTooHigh; |
|---|
| 12 |
Linear (l, s, e);; |
|---|
| 13 |
|
|---|
| 14 |
let amplitude remix volume position = |
|---|
| 15 |
match volume with |
|---|
| 16 |
| Constant v -> v |
|---|
| 17 |
| Linear (l, s, e) -> ( |
|---|
| 18 |
if l = Time.Forever then |
|---|
| 19 |
Printf.printf "I can't ramp forever\n"; |
|---|
| 20 |
let raw_length = Time.time_to_raw_time remix l in |
|---|
| 21 |
(float_of_int position /. float_of_int raw_length) *. (e -. s) +. s |
|---|
| 22 |
);; |
|---|