Question about Music Player and patches

This forum is for artists to post their music and graphics or discuss artistic matters that could be used in Uzebox games.
Post Reply
User avatar
Roukan
Posts: 113
Joined: Sat Oct 27, 2012 7:50 pm
Location: Lancashire / England

Question about Music Player and patches

Post by Roukan »

Hi All

I was wondering if it's possible to do the following things whilst a multi channel song is playing:

1) Mute a particular channel
2) Change the patch a particular channel is using

Without interrupting the flow of the music.


Cheers

Roukan / Jim
User avatar
uze6666
Site Admin
Posts: 4801
Joined: Tue Aug 12, 2008 9:13 pm
Location: Montreal, Canada
Contact:

Re: Question about Music Player and patches

Post by uze6666 »

There's currently no API or direct way to do this. Though it could be done in part using the sound engine internal structures. Muting could be simulated by setting a tracks's column to zero, though any volume controller used in the track later would "unmute". For the patch, it is the same thing, on the next patch change controller found it would restore to that one.

Code: Select all

extern struct TrackStruct tracks[];
tracks[channel].trackVol=0;
tracks[channel].patchNo=5;
User avatar
Roukan
Posts: 113
Joined: Sat Oct 27, 2012 7:50 pm
Location: Lancashire / England

Re: Question about Music Player and patches

Post by Roukan »

Just thought I'd link the reason I was asking about this - might shed a bit more light on the matter:

http://uzebox.org/forums/viewtopic.php? ... 798#p10378

Cheers

Roukan / Jim
User avatar
D3thAdd3r
Posts: 3221
Joined: Wed Apr 29, 2009 10:00 am
Location: Minneapolis, United States

Re: Question about Music Player and patches

Post by D3thAdd3r »

I'm replying to the other thread here, I think this is the best place?
Roukan wrote: 1) Though it's probably not doable due to the way it uses music as part of the game play :roll:
I am positive it would be possible to do something similar. I attached a demo where up,down,left, and right will change what instrument plays for channel 0(main melody). Now, distorting the timing or playing "out of tune" when the bad guys have the instrument would be a bit trickier. The patch that plays when you push right in the demo, seems like it would almost work for a warbled melody for baddies. Otherwise it would take a bit of work, but I think it would be possible to distort time only for channel0 fairly easy also.

Essentially this is how easy it is:

Code: Select all

	while(true){
		uint16_t pad = ReadJoypad(0);

		tracks[0].patchNo=0;//normal sound
		if(pad & BTN_UP)
			tracks[0].patchNo=1;
		if(pad & BTN_DOWN)
			tracks[0].patchNo=2;
		if(pad & BTN_LEFT)
			tracks[0].patchNo=3;
		if(pad & BTN_RIGHT)
			tracks[0].patchNo=4;
		WaitVsync(1);
	}
Attachments
musictest.hex
(113.9 KiB) Downloaded 748 times
User avatar
Roukan
Posts: 113
Joined: Sat Oct 27, 2012 7:50 pm
Location: Lancashire / England

Re: Question about Music Player and patches

Post by Roukan »

Hi Deathadder

Thanks very much for the reply.

I guess I should of tried something after Uze had replied - I just got it into my head that the original patch would be forced back into play for some reason. :oops:

I've now run some tests and yes it does work (not that I ever doubted you ;))

Whilst I'm at it, just wondering if any kind person out there could come up with patch settings for the following 3 instruments:

1) Saxophone
2) Trumpet
3) Electric Guitar


Cheers

Roukan / Jim
User avatar
uze6666
Site Admin
Posts: 4801
Joined: Tue Aug 12, 2008 9:13 pm
Location: Montreal, Canada
Contact:

Re: Question about Music Player and patches

Post by uze6666 »

The sound engine could easily be updated to support a track mute flag. On the other hand, detuning is harder to do because of the way the engine works with a fixed lookup table to derive the notes frequencies. Basically the reason why I never implemented the pitch bend controller.

Maybe you could achieve a similar effect using an out-of-tune chord arpegio? Though that would not sound like those instruments you are looking for.

@Lee: Great song convertion btw! Temping to update SuperMArio demo with it... 8-)
User avatar
Roukan
Posts: 113
Joined: Sat Oct 27, 2012 7:50 pm
Location: Lancashire / England

Re: Question about Music Player and patches

Post by Roukan »

uze6666 wrote:The sound engine could easily be updated to support a track mute flag.
On the mute side of things, could certain settings for a patch make it a silent patch, then when muting is required - one just changes the patch number to the silent one.

If so what might they be? :roll:
uze6666 wrote:On the other hand, detuning is harder to do because of the way the engine works with a fixed lookup table to derive the notes frequencies. Basically the reason why I never implemented the pitch bend controller.

Maybe you could achieve a similar effect using an out-of-tune chord arpegio? Though that would not sound like those instruments you are looking for.
I had also thought that just having a few dodgy sounding patches that can be switched in might suffice - If it sounds bad then it's doing the job ;)
uze6666 wrote:@Lee: Great song convertion btw! Temping to update SuperMArio demo with it... 8-)
Agree, it sounded pretty sweet.


Cheers

Roukan / Jim
User avatar
D3thAdd3r
Posts: 3221
Joined: Wed Apr 29, 2009 10:00 am
Location: Minneapolis, United States

Re: Question about Music Player and patches

Post by D3thAdd3r »

I had a simple idea and I've added an updated demo. Hold right to hear a very detuned playback. I think this is fully capable, and certainly the patches could be experimented to be more precise for your taste. The basic idea is this:

Code: Select all

	uint16_t lfsr = 26;//seed our random number generator
	while(true){
		uint16_t pad = ReadJoypad(0);

		tracks[0].patchNo=0;
		if(pad & BTN_UP)
			tracks[0].patchNo=1;
		if(pad & BTN_DOWN)
			tracks[0].patchNo=2;
		if(pad & BTN_LEFT)
			tracks[0].patchNo=3;
		if(pad & BTN_RIGHT)
			tracks[0].patchNo=4+(lfsr&5);
		WaitVsync(1);
		
		uint16_t bit;
  		/* taps: 16 14 13 11; characteristic polynomial: x^16 + x^14 + x^13 + x^11 + 1 */
		bit  = ((lfsr>>0)^(lfsr>>2)^(lfsr>>3)^(lfsr>>5))&1;
		lfsr = (lfsr>>1)|(bit<<15);
	}
Here I made 5 patches that are detuned something like this:

Code: Select all

const char patch11[] PROGMEM ={
0,PC_TREMOLO_LEVEL,60,     
0,PC_TREMOLO_RATE,24, 
0,PC_WAVE,4,
0,PC_ENV_VOL,0//here we can halt sound for a bit
14,PC_ENV_VOL,128,//and restore it some frames later causing "off time" playback
0,PC_NOTE_DOWN,15,//different values here mess up the pitches played
0,PC_ENV_VOL,87,
0,PC_ENV_SPEED,8,
1,PC_NOTE_HOLD,0,
0,PC_ENV_SPEED,-4,
60,PC_NOTE_CUT,0,
0,PATCH_END
};
Randomly choosing 1 of several patches with messed up notes and/or timing seems very similar to the original game.
Attachments
musicdemo.hex
(81.07 KiB) Downloaded 555 times
User avatar
Roukan
Posts: 113
Joined: Sat Oct 27, 2012 7:50 pm
Location: Lancashire / England

Re: Question about Music Player and patches

Post by Roukan »

D3thAdd3r wrote:Randomly choosing 1 of several patches with messed up notes and/or timing seems very similar to the original game.
Nice work DeathAdder, that seems to reproduce the effect quite well indeed :)


Cheers

Roukan / Jim
Post Reply