FreeCalypso > hg > freecalypso-tools
annotate ringtools/imy/durations.c @ 901:2e6764022292
fc-shell tch record: add support for new TCH DL format
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 13 Dec 2022 03:24:36 +0000 |
parents | fd4c9bc7835d |
children |
rev | line source |
---|---|
882
fd4c9bc7835d
fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
fd4c9bc7835d
fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This module implements the step of precomputing various note durations |
fd4c9bc7835d
fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * in TDMA frames. |
fd4c9bc7835d
fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 */ |
fd4c9bc7835d
fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 |
fd4c9bc7835d
fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 extern unsigned beats_per_min; |
fd4c9bc7835d
fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 unsigned tdma_durations[6][4]; |
fd4c9bc7835d
fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 |
fd4c9bc7835d
fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 static float modifier_values[4] = {1.0f, 1.5f, 1.75f, 2.0f / 3.0f}; |
fd4c9bc7835d
fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 |
fd4c9bc7835d
fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 compute_note_durations() |
fd4c9bc7835d
fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 { |
fd4c9bc7835d
fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 float beat_ref, basic_ms[6], dur_ms; |
fd4c9bc7835d
fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 unsigned dur_tdma; |
fd4c9bc7835d
fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 int i, j; |
fd4c9bc7835d
fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 |
fd4c9bc7835d
fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 beat_ref = 60000.0f / beats_per_min; |
fd4c9bc7835d
fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 basic_ms[0] = beat_ref * 4.0f; |
fd4c9bc7835d
fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 basic_ms[1] = beat_ref * 2.0f; |
fd4c9bc7835d
fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 basic_ms[2] = beat_ref; |
fd4c9bc7835d
fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 basic_ms[3] = beat_ref / 2.0f; |
fd4c9bc7835d
fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 basic_ms[4] = beat_ref / 4.0f; |
fd4c9bc7835d
fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 basic_ms[5] = beat_ref / 8.0f; |
fd4c9bc7835d
fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 for (i = 0; i < 6; i++) { |
fd4c9bc7835d
fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 for (j = 0; j < 4; j++) { |
fd4c9bc7835d
fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 dur_ms = basic_ms[i] * modifier_values[j]; |
fd4c9bc7835d
fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 dur_tdma = dur_ms * 13.0f / 60.0f + 0.5f; |
fd4c9bc7835d
fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 tdma_durations[i][j] = dur_tdma; |
fd4c9bc7835d
fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 } |
fd4c9bc7835d
fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 } |
fd4c9bc7835d
fc-imy2pwt program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 } |