All is not fine. The sounds are wrong now, but it's an easy fix—you actually made the exact same mistake that I did when trying to optimize things.uze6666 wrote:Take two. Fixed and pushed. Let me know if all is fine.
You can't move the:
Code: Select all
if(track->flags & TRACK_FLAGS_PLAYING){
Code: Select all
if(track->patchPlayingTime<0xff){
track->patchPlayingTime++;
}
Code: Select all
if(track->patchCommandStreamPos!=NULL && ((track->flags & TRACK_FLAGS_HOLD_ENV)==0)){
Code: Select all
( (PatchCommand)pgm_read_word(&patchCommands[c1]) )(track,c2);
Edit: Here is a diff of what I mean:
Code: Select all
diff --git a/kernel/uzeboxSoundEngine.c b/kernel/uzeboxSoundEngine.c
index b56e2af..5bddbf5 100644
--- a/kernel/uzeboxSoundEngine.c
+++ b/kernel/uzeboxSoundEngine.c
@@ -778,10 +778,9 @@ void ProcessMusic(void){
for(unsigned char trackNo=0;trackNo<CHANNELS;trackNo++){
track=&tracks[trackNo];
- if(track->flags & TRACK_FLAGS_PLAYING){
//process patch command stream
- if(track->patchCommandStreamPos!=NULL && ((track->flags & TRACK_FLAGS_HOLD_ENV)==0)){ //patchEnvelopeHold==false
+ if((track->flags & TRACK_FLAGS_PLAYING) && (track->patchCommandStreamPos!=NULL) && ((track->flags & TRACK_FLAGS_HOLD_ENV)==0)){ //patchEnvelop
//process all simultaneous events
while(track->patchCurrDeltaTime==track->patchNextDeltaTime){
@@ -808,6 +807,7 @@ void ProcessMusic(void){
}
+ if(track->flags & TRACK_FLAGS_PLAYING){
if(track->patchPlayingTime<0xff){
track->patchPlayingTime++;
}