git.lirion.de

Of git, get, and gud

summaryrefslogtreecommitdiffstats
path: root/sounds/helrunar-vanitas-vanitatum.rsc
blob: 1a8a31e42d81d2e57bdff8a9305f09232a22b36b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# 
# MIDI player by MikroTourette 2017
# with enhancements by jgro 2022
# notes/music part by lirion 2022
# ---WiP---
#
# notes is array of MIDI notes with optional length: note/length
# Length is number of ticks. If omitted, length will be set to $defaultTicks.
# Use 0 for rests.

:local notes 62/8,62/4,64/4,65/4,67/4,69/16,62/8,74/8,74/4,72/4,70/4,72/4,69/16,62/8,58/8,58/4,62/4,70/8,57/8,57/4,61/4,69/8,64/8,69/8,64/8,62/16,0/8,62/8,62/4,64/4,65/4,67/4,69/16,62/8,74/8,74/4,72/4,70/4,72/4,69/16,62/8,58/8,58/4,62/4,70/8,57/8,57/4,61/4,69/8,64/8,65/8,64/8,62/16,0/8,62/8,62/4,64/4,65/4,67/4,69/16,62/8,74/8,74/4,72/4,70/4,72/4,69/16,62/8,58/8,58/4,62/4,70/8,57/8,57/4,61/4,69/8,64/8,69/8,64/8,62/16,0/8,62/8,62/4,64/4,65/4,67/4,69/16,62/8,74/8,74/4,72/4,70/4,72/4,69/16,62/8,58/8,58/4,62/4,70/8,57/8,57/4,61/4,69/8,64/8,65/8,64/8,62/16,0/2,57/2,61/2,64/2,65/2,61/2,57/4,61/4,57/4,61/4,57/4,62/4,57/4,61/4,57/4,61/4,57/4,61/4,57/4,61/4,57/4,61/4,57/4,62/4,57/4,61/4,57/4,61/4,57/4,61/4,57/4,61/4,57/4,61/4,57/4,62/4,57/4,61/4,57/4,61/4,57/4,61/4,57/4,61/4,57/4,61/4,57/4,62/4,57/4,61/4,57/4,61/4,57/4,65/4,57/4,65/4,57/4,65/4,57/4,62/4,57/4,65/4,57/4,65/4,57/4,65/4,57/4,65/4,57/4,65/4,57/4,62/4,57/4,65/4,57/4,65/4,57/4,64/4,57/4,64/4,57/4,64/4,57/4,62/4,57/4,64/4,57/4,64/4,57/4,64/4,57/4,64/4,57/4,64/4,57/4,62/4,57/4,64/4,57/4,64/4,57/4,65/4,57/4,65/4,57/4,65/4,57/4,62/4,57/4,65/4,57/4,65/4,57/4,65/4,57/4,65/4,57/4,65/4,57/4,69/4,57/4,69/4,57/4,69/4,57/4,64/4,57/4,64/4,57/4,64/4,57/4,62/4,57/4,64/4,57/4,64/4,57/4,61/4,57/4,61/4,57/4,61/4,57/4,61/4,57/4,61/4,57/4,61/4,57/4,65/4,57/4,65/4,57/4,65/4,57/4,62/4,57/4,65/4,57/4,65/4,57/4,65/4,57/4,65/4,57/4,65/4,57/4,69/4,57/4,69/4,57/4,69/4,57/4,64/4,57/4,64/4,57/4,64/4,57/4,62/4,57/4,64/4,57/4,64/4,57/4,61/4,57/4,61/4,57/4,61/4,57/4,58/4,57/4,58/4,57/4,58/4,57/4,65/4,57/4,65/4,57/4,65/4,57/4,62/4,57/4,65/4,57/4,65/4,57/4,65/4,57/4,65/4,57/4,65/4,57/4,69/4,57/4,69/4,57/4,69/4,57/4,64/4,57/4,64/4,57/4,64/4,57/4,62/4,57/4,64/4,57/4,64/4,57/4,61/4,57/4,61/4,57/4,61/4,57/4,58/4,57/4,58/4,57/4,58/4,57/4,65/72,69/24,64/48,61/24,58/24,65/72,69/24,64/48,61/24,58/24;

# Tempo
# Because clock resolution is only 10ms, you need much longer ticks than standard MIDI
:local tick 50ms;      # length of a tick
:local defaultTicks 4; # default number of ticks for a note
:local stacc 10ms;     # length of break between notes
:local transpose 0;    # number to add to or subtract from each note (12 is 1 octave)

# MIDI player
# Frequencies from C9 (MIDI 120) through B9 (beyond MIDI top note of 127)
:local frqtab 8372,8869,9397,9956,10548,11175,11839,12543,13288,14080,14916,15804;
:local n0; :local n;
:local d0; :local d;
:local l;
:local midi;
:local i;
:local octa;
:local frq;
:local tones;
:local durations;
:for i from=0 to= ([:len $notes]-1) do={
  :local entry [:pick $notes $i];
  :local div [:find $entry "/"];
  :if ([:typeof $div] = "nil") do={
    :set tones ($tones, $entry);
    :set durations ($durations, $defaultTicks);
  } else={
    :set tones ($tones, [:pick $entry 0 $div]);
    :set durations ($durations, [:pick $entry ($div + 1) [:len $entry]]);
  }
}
  
:for i from=0 to= ([:len $notes]-1) do={
  :set midi [:pick $tones $i];
  :set midi ($midi + $transpose);
  :set octa 0;
  :while ($midi < 120) do={:set midi ($midi + 12); :set octa ($octa + 1); };
  :set midi ($midi % 12);
  :set frq [:tonum [:pick $frqtab $midi]];
  :set frq ($frq>>($octa));
  :set d0 [:pick $durations $i];
  
  :set d ($d0 * $tick );
  :set l ($d0 * ($tick - $stacc));
  # :put $midi;
  # :put $frq;
  # :put $octa;
  if ($frq >= 20) do={
    :beep frequency=$frq length=$l;
  }
  :delay $d;
}