Browse Source

loop music seamlessly

Thomas B 3 weeks ago
parent
commit
61296f13ae
2 changed files with 8 additions and 13 deletions
  1. 6
    1
      src/sound.c
  2. 2
    12
      src/sound_game.c

+ 6
- 1
src/sound.c View File

163
     }
163
     }
164
 
164
 
165
     START_ROM_BANK(bank) {
165
     START_ROM_BANK(bank) {
166
-
167
         uint16_t diff = timer_get() - last_t;
166
         uint16_t diff = timer_get() - last_t;
168
         if (diff >= music->duration) {
167
         if (diff >= music->duration) {
169
             if (music->notes) {
168
             if (music->notes) {
172
                 } else {
171
                 } else {
173
                     if (music->repeat != MUSIC_NO_REPEAT) {
172
                     if (music->repeat != MUSIC_NO_REPEAT) {
174
                         off = music->repeat;
173
                         off = music->repeat;
174
+                        snd_play();
175
+                        return;
175
                     } else {
176
                     } else {
176
                         music = NULL;
177
                         music = NULL;
177
                         goto end;
178
                         goto end;
185
                 } else {
186
                 } else {
186
                     if (music->repeat != MUSIC_NO_REPEAT) {
187
                     if (music->repeat != MUSIC_NO_REPEAT) {
187
                         off = music->repeat;
188
                         off = music->repeat;
189
+                        snd_play();
190
+                        return;
188
                     } else {
191
                     } else {
189
                         music = NULL;
192
                         music = NULL;
190
                         goto end;
193
                         goto end;
198
                 } else {
201
                 } else {
199
                     if (music->repeat != MUSIC_NO_REPEAT) {
202
                     if (music->repeat != MUSIC_NO_REPEAT) {
200
                         off = music->repeat;
203
                         off = music->repeat;
204
+                        snd_play();
205
+                        return;
201
                     } else {
206
                     } else {
202
                         music = NULL;
207
                         music = NULL;
203
                         goto end;
208
                         goto end;

+ 2
- 12
src/sound_game.c View File

34
 
34
 
35
 
35
 
36
 static const enum notes game_music[] = {
36
 static const enum notes game_music[] = {
37
-    NOTE_LOOP, NOTE_LOOP, NOTE_LOOP, NOTE_LOOP,
38
-    NOTE_LOOP, NOTE_LOOP, NOTE_LOOP, NOTE_LOOP,
39
-
40
-    SILENCE, SILENCE, SILENCE, SILENCE,
41
-    SILENCE, SILENCE, SILENCE, SILENCE,
42
-    SILENCE, SILENCE, SILENCE, SILENCE,
43
-    SILENCE, SILENCE, SILENCE, SILENCE,
37
+    NOTE_LOOP,
44
     END
38
     END
45
 };
39
 };
46
 
40
 
49
 dSn, dSI, dSn, dSI, dKi, dSI, dSI, dSI  \
43
 dSn, dSI, dSn, dSI, dKi, dSI, dSI, dSI  \
50
 
44
 
51
 static const enum drums game_drums[] = {
45
 static const enum drums game_drums[] = {
52
-    DRUM_LOOP, DRUM_LOOP, DRUM_LOOP, DRUM_LOOP,
53
-    DRUM_LOOP, DRUM_LOOP, DRUM_LOOP, DRUM_LOOP,
54
-
55
-    dSI, dSI, dSI, dSI, dSI, dSI, dSI, dSI,
56
-    dSI, dSI, dSI, dSI, dSI, dSI, dSI, dSI,
46
+    DRUM_LOOP,
57
     dEND
47
     dEND
58
 };
48
 };
59
 
49
 

Loading…
Cancel
Save