shithub: choc

Download patch

ref: 02ccadefba97631c4779cc2e3d2b98259025d7f6
parent: 10ccadee87aee30e07b66606d9d155f8cc9d7a77
parent: 0609b476967da8db4987d1c44de7ab519271392b
author: Simon Howard <fraggle+github@gmail.com>
date: Thu Oct 8 09:45:01 EDT 2015

Merge pull request #619 from khokh2001/dmx-opl-volume-fix

opl: Minor fixes for last commit.

--- a/src/i_oplmusic.c
+++ b/src/i_oplmusic.c
@@ -670,10 +670,9 @@
     {
         for (j = 0; j < MIDI_CHANNELS_PER_TRACK; ++j)
         {
-            if (j == 9)
+            if (j == 15)
             {
-                SetChannelVolume(&tracks[i].channels[j],
-                                 volume, false);
+                SetChannelVolume(&tracks[i].channels[j], volume, false);
             }
             else
             {
@@ -1401,23 +1400,26 @@
 }
 
 static void ScheduleTrack(opl_track_data_t *track);
+static void InitChannel(opl_track_data_t *track, opl_channel_data_t *channel);
 
 // Restart a song from the beginning.
 
 static void RestartSong(void *unused)
 {
-    unsigned int i;
+    unsigned int i, j;
 
     running_tracks = num_tracks;
 
     start_music_volume = current_music_volume;
 
-    I_SetMusicVolume(current_music_volume);
-
     for (i = 0; i < num_tracks; ++i)
     {
         MIDI_RestartIterator(tracks[i].iter);
         ScheduleTrack(&tracks[i]);
+        for (j = 0; j < MIDI_CHANNELS_PER_TRACK; ++j)
+        {
+            InitChannel(&tracks[i], &tracks[i].channels[j]);
+        }
     }
 }
 
@@ -1489,7 +1491,11 @@
 
     channel->instrument = &main_instrs[0];
     channel->volume = current_music_volume;
-    channel->volume_base = 127;
+    channel->volume_base = 100;
+    if (channel->volume > channel->volume_base)
+    {
+        channel->volume = channel->volume_base;
+    }
     channel->pan = 0x30;
     channel->bend = 0;
 }