| 1 |
(* shift takes an input note, and shifts its render window: |
|---|
| 2 |
|
|---|
| 3 |
<-----------------note extent-------------------------> |
|---|
| 4 |
<------------------------shift amount-----------<---render request---> |
|---|
| 5 |
<---actual render---> |
|---|
| 6 |
*) |
|---|
| 7 |
|
|---|
| 8 |
let shift slength note initsound remix start render_extent = |
|---|
| 9 |
let raw_rstart, raw_rlength = Time.extent_to_raw_time remix render_extent in |
|---|
| 10 |
let raw_shift = Time.time_to_raw_time remix slength in |
|---|
| 11 |
note initsound remix start |
|---|
| 12 |
(Time.Samples (raw_rstart + raw_shift), Time.Samples raw_rlength);; |
|---|
| 13 |
|
|---|
| 14 |
(* repeat takes an input length and note, and duplicates the note with length |
|---|
| 15 |
as the size. e.g. |
|---|
| 16 |
|
|---|
| 17 |
<----------------------------------------> (input extent) |
|---|
| 18 |
<---length---><---length---><---length---> (actual note extents) |
|---|
| 19 |
|
|---|
| 20 |
For a render request within a single length, this is easy: |
|---|
| 21 |
|
|---|
| 22 |
<---length---><---length---><---length---> |
|---|
| 23 |
<ren-req> |
|---|
| 24 |
|
|---|
| 25 |
Simply use a note extent of |
|---|
| 26 |
(render_start - note_start)/length*length + note_start, length |
|---|
| 27 |
and the existing render request. |
|---|
| 28 |
|
|---|
| 29 |
For a render request that crosses multiple lengths, it's slightly harder: |
|---|
| 30 |
|
|---|
| 31 |
<---length---><---length---><---length---> |
|---|
| 32 |
<--render-request--> |
|---|
| 33 |
|
|---|
| 34 |
We'll use a layer, add three notes of full size: |
|---|
| 35 |
|
|---|
| 36 |
<---length---><---length---><---length---> |
|---|
| 37 |
|
|---|
| 38 |
then render the size of the render extent out as a new note |
|---|
| 39 |
|
|---|
| 40 |
*) |
|---|
| 41 |
let repeat length note initsound remix start render_extent = |
|---|
| 42 |
let raw_start, raw_length = Time.extent_to_raw_time remix render_extent in |
|---|
| 43 |
let raw_replength = Time.time_to_raw_time remix length in |
|---|
| 44 |
let reps = raw_start / raw_replength in |
|---|
| 45 |
let repe = (raw_start + raw_length - 1) / raw_replength in |
|---|
| 46 |
if reps = repe then ( |
|---|
| 47 |
note initsound remix |
|---|
| 48 |
(Time.Samples (reps * raw_replength)) render_extent |
|---|
| 49 |
) else ( |
|---|
| 50 |
let l = Layer.empty () in |
|---|
| 51 |
let add n s len = Layer.add_note l n (Time.Samples s, Time.Samples len) in |
|---|
| 52 |
for i = reps to repe do |
|---|
| 53 |
add note (i * raw_replength) raw_replength |
|---|
| 54 |
done; |
|---|
| 55 |
Layer.to_note l initsound remix start render_extent |
|---|
| 56 |
|
|---|
| 57 |
(* |
|---|
| 58 |
let first_seg_len = ((reps + 1) * raw_replength) - raw_start in |
|---|
| 59 |
let last_seg_start = repe * raw_replength in |
|---|
| 60 |
let last_seg_len = raw_start + raw_length - last_seg_start in |
|---|
| 61 |
|
|---|
| 62 |
let add n s len = Layer.add_note l n (Time.Samples s, Time.Samples len) in |
|---|
| 63 |
add (theshift (reps * raw_replength)) raw_start first_seg_len; |
|---|
| 64 |
add (theshift (repe * raw_replength)) last_seg_start last_seg_len; |
|---|
| 65 |
for i = reps + 1 to repe - 1 do |
|---|
| 66 |
add (theshift (i * raw_replength)) (i * raw_replength) raw_replength |
|---|
| 67 |
done; |
|---|
| 68 |
*) |
|---|
| 69 |
);; |
|---|