Inline Mixer - saving clocks

Topics related to the API, programming discussions & questions, coding tips, bugs, etc. should go here.
User avatar
uze6666
Site Admin
Posts: 4487
Joined: Tue Aug 12, 2008 9:13 pm
Location: Montreal, Canada
Contact:

Re: Inline Mixer - saving clocks

Post by uze6666 » Mon Feb 29, 2016 1:05 am

Music is process a 60hz, so once per field. I guess a JMP could be used yes since it should be the only place that calls that subroutine. But the latter is in C and I never tried that in C. Why would you like to do that?

CunningFellow
Posts: 1192
Joined: Mon Feb 11, 2013 8:08 am
Location: Brisbane, Australia

Re: Inline Mixer - saving clocks

Post by CunningFellow » Sun Apr 17, 2016 4:54 am

THIS ONE has my new noise method in it. Does it sound like noise? They sound the same to me, but I have poor hearing.

It only is 3 clocks less than my best LFSR to date, but I have not tried to optimize it yet.
Attachments
NewNoiseTest.hex
(35.84 KiB) Downloaded 96 times

User avatar
D3thAdd3r
Posts: 2422
Joined: Wed Apr 29, 2009 10:00 am
Location: Minneapolis, United States

Re: Inline Mixer - saving clocks

Post by D3thAdd3r » Sun Apr 17, 2016 2:37 pm

The 2 sound very close and I can't hear anything that doesn't sound perfectly LFSR like. The only difference I can detect is a slightly lower pitch to the one triggered by the 'A' button which seems consistent across effects.

CunningFellow
Posts: 1192
Joined: Mon Feb 11, 2013 8:08 am
Location: Brisbane, Australia

Re: Inline Mixer - saving clocks

Post by CunningFellow » Sun Apr 17, 2016 10:51 pm

OK - in that case I think I can have

4 normal wave channels
1 wave channel that can also do dumb PCM
2 noise channels

That will mean I can have 3 wave + 1 noise exclusive for music
2 wave + 1 noise exclusive for sfx

If it is useful for more general purpose games - I THINK I have now saved enough clocks that you could squeeze in an extra wave channel without touching the PCM channel. (do many people use the PCM channel to play back samples at different pitch anyway ?)

User avatar
D3thAdd3r
Posts: 2422
Joined: Wed Apr 29, 2009 10:00 am
Location: Minneapolis, United States

Re: Inline Mixer - saving clocks

Post by D3thAdd3r » Mon Apr 18, 2016 6:02 am

Damn cool however you are pulling this off.

AFAIK only games are Gorillas(fixed frequency sample), Columns(multiple frequency sample), and TQ(kernel waves, like T2K) using PCM channel. Personally I plan to use the same music-immune PCM/kernel waves method like T2K for as much as possible in the future but the possibility of another wave is a rather enticing option if it can be worked in at compile time.

Do you think there is a possibility to squeeze UART buffers in with normal PCM channel(which currently you can't have both) with the extra cycles you achieved?

CunningFellow
Posts: 1192
Joined: Mon Feb 11, 2013 8:08 am
Location: Brisbane, Australia

Re: Inline Mixer - saving clocks

Post by CunningFellow » Mon Apr 18, 2016 7:08 am

I see that the current UART code is 47 clocks.

Keeping the full featured PCM channel I have only save 24 clocks.

So you would have to do some serious optimizing of the UART code to do that.

I have not looked at it. Maybe if you did an odds/evens for TX and RX you would be OK.

User avatar
Jubatian
Posts: 1406
Joined: Thu Oct 01, 2015 9:44 pm
Location: Hungary
Contact:

Re: Inline Mixer - saving clocks

Post by Jubatian » Thu Sep 21, 2017 5:20 pm

I created an experimental branch with an optimized mixer:

https://github.com/Jubatian/uzebox/tree/mixer_boost

This incorporates techniques I used for Flight of a Dragon, and CunningFellow's optimizations on the noise channel. It is (was) difficult to determine what to use and how since a very substantial improvement comes from reducing the count of register used (push & pop overhead), in a later kernel, maybe even r18 will not be present in the inline mixer (I plan to later use GPIOR0 for a few important kernel flags like I did in Flight of a Dragon which can improve performance and could add capabilities, such as an option to set display mode - see the temporal interference topic).

Currently this mixer saves 23 clocks compared to the original, which gives some improvement in VBlank time available for user code. Not that much like the kernel boost (57 cycles per scanline), but still substantial (when using the UART, you get 26 clocks).

Games and stuff in the master repo seem to work. Test! If it is OK, I will merge in.

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

Re: Inline Mixer - saving clocks

Post by uze6666 » Wed Nov 01, 2017 1:50 am

Well, I'm pretty impressed by those optimizations. I looked so many times at ways to reduce the cycles count on that code! Specially the saturation bit, so simple and elegant...kudos! :P

CunningFellow
Posts: 1192
Joined: Mon Feb 11, 2013 8:08 am
Location: Brisbane, Australia

Re: Inline Mixer - saving clocks

Post by CunningFellow » Wed Nov 01, 2017 3:59 am

Oh - I forgot about this.

I don't think I ever posted the next big speed gain I made. Using a common counter for the wave channels.

I'll dig up that code.

User avatar
Jubatian
Posts: 1406
Joined: Thu Oct 01, 2015 9:44 pm
Location: Hungary
Contact:

Re: Inline Mixer - saving clocks

Post by Jubatian » Wed Nov 01, 2017 8:02 am

CunningFellow wrote:
Wed Nov 01, 2017 3:59 am
Oh - I forgot about this.

I don't think I ever posted the next big speed gain I made. Using a common counter for the wave channels.

I'll dig up that code.
Wish to see that! I don't see how it is supposed to work though as for me it seems like there is nothing which could be made common between the channels (they may run at arbitrarily differing frequency).
uze6666 wrote:
Wed Nov 01, 2017 1:50 am
Well, I'm pretty impressed by those optimizations. I looked so many times at ways to reduce the cycles count on that code! Specially the saturation bit, so simple and elegant...kudos! :P
Well, Flight of a Dragon is slowly creeping in the mainline :D It is almost at the point where you could use the UART together with 5 channels with Mode 3, it is just a few cycles short of this point.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest