Multiple PCM channels.

For anything related to sound (YM2612, PSG, Z80, PCM...)

Moderator: BigEvilCorporation

Post Reply
Toddo
Interested
Posts: 12
Joined: Thu Sep 12, 2013 5:08 am
Location: Australia

Multiple PCM channels.

Post by Toddo » Thu Dec 12, 2013 3:17 am

I've heard and seen some MD games that supposedly play multiple pcm samples at once. Some games I've heard of include: Street Fighter 2 CE, Mortal Kombat 2 and 3, Mega Turrican and apparently Probotector MD does it too.

I'm interested in how this is achieved, ways such as using 4-bit samples, interpolating and software sample mixing can be quite intriguing for someone slightly experienced in MD sound programming.
Tiido's sound driver also has 2 pcm channels, at the expense of FM4 and FM5 (the usual pcm channel).

So, does anyone else know of MD games that play more than one sample at the same time?

-Toddo
-Chill dude, the 68k can handle it.

Radaron
Newbie
Posts: 1
Joined: Fri Sep 06, 2013 10:47 am
Location: Novosibirsk, Russia

Post by Radaron » Thu Dec 12, 2013 11:42 am


TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Thu Dec 12, 2013 3:17 pm

You do software mixing on the hardware PCM channel. How many channels you can mix depends greatly on your code quality. My sound engine does not lose 2 FM channels, just the last one that does PCM. It is possible to play PCM on a FM channel but there's quite some technicalities involved and the logarithmic volume scale only gets like 4...5 bits of precision at most, more is possible but the code gets very ugly and complex so that normal PCB mixer would be a piece of cake to do.
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

Toddo
Interested
Posts: 12
Joined: Thu Sep 12, 2013 5:08 am
Location: Australia

Post by Toddo » Thu Jan 02, 2014 9:53 pm

http://oerg866.tototek.com/toy.html[/quote]


.Mod player, that's cool. From what I've heard very few games use polyphony on the 6th channel. However it may be possible with the use of 2x4-bit being mixed to 8-bit. The 68k has enough power to mix 8-bit samples. If I see a z80 driver (which is usually used for sound) with 2*pcm channels or more, then I'll be impressed.
-Chill dude, the 68k can handle it.

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Fri Jan 03, 2014 12:01 am

There's a thread around here somewhere where me and couple other regulars talk about some z80 code to do a resampling mixer via the z80. The 68000 would handle music score processing, as well as instrument handling, but pass the actual sample mixing vars to the z80. That simplified the z80 code enough that it should be able to mix four channels at 7 to 8 kHz per channel. That should leave enough 68000 power to play a game while playing a MOD, not just only during a title screen like Toy Story.

tomaitheous
Very interested
Posts: 256
Joined: Tue Sep 11, 2007 9:10 pm

Post by tomaitheous » Fri Jan 03, 2014 2:31 am

Why limit yourself to 4bit channels? 7bit+7bit=8bit. Or 6bit+6bit+6bit+6bit=8bit. I mean, that assumes you don't want to waste cycles on clipping detection. You're not multiplying a 4bit channel with another channel; you're accumulating them. Unless I missed something here, and you want to use 4bit specifically for some other reason (space/storage?).

Toddo
Interested
Posts: 12
Joined: Thu Sep 12, 2013 5:08 am
Location: Australia

Post by Toddo » Tue Jan 07, 2014 7:52 am

Unless I missed something here, and you want to use 4bit specifically for some other reason (space/storage?).[/quote]

4 bit samples use less space than the 7 or 6 bit samples, I'd also hope to save some reasonable amount of cpu power for things such as sound effects and voices.

A single digital audio channel can have sample mixing done by a 7.68mhz cpu from 1979, that in it's self is impressive
-Chill dude, the 68k can handle it.

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Tue Jan 07, 2014 8:38 am

4bit will certainly not save any CPU power, you spend extra in separating the samples from one another. It would take 2x less space but also sounds 16 times worse (noise fest).
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

kubilus1
Very interested
Posts: 237
Joined: Thu Aug 16, 2012 2:25 am
Contact:

Post by kubilus1 » Tue Jan 07, 2014 6:55 pm

Stef has a 4 channel PCM player that runs on the z80 and plays 16khz files in SGDK. This uses the just the one FM channel.

The mixing macro consists of the following:

Code: Select all

; doEnvAndMix
; = 35 --> 49 cycles

            macro doEnvAndMix

            LD      A, (BC)         ; compute volume            ' 7     |
            ADD     (HL)            ; mix                       ' 7     | 24
            JP      PO, .ok         ; check overflow            ' 10    |

            LD      A, $7F          ; fix overflow              ' 7     |
            ADC     $0              ; A = $7F/$80               ' 7     | +14

.ok
            LD      (HL), A         ; write sample in buffer    ' 7     | 11 (35)
            INC     L               ; next                      ' 4     |

            endm

tomaitheous
Very interested
Posts: 256
Joined: Tue Sep 11, 2007 9:10 pm

Post by tomaitheous » Wed Jan 08, 2014 3:30 am

Toddo wrote: 4 bit samples use less space than the 7 or 6 bit samples, I'd also hope to save some reasonable amount of cpu power for things such as sound effects and voices.
Assuming you nibble pack the 4bit samples to save space, you're gonna eat up more processor time separating those nibbles than just using a single byte and wasting a couple of bits.
A single digital audio channel can have sample mixing done by a 7.68mhz cpu from 1979, that in it's self is impressive
How about an 8bit cpu from 1978? http://www.youtube.com/watch?v=49uB068i3ZU (frequency scaling, applying voluming, AND mixing all 4 channels in realtime). Still has processor power left over to display a player screen with waveform monitor! That video is the 6309 version, but there's a 6809 version just the same (minus a few areas of the screen that don't have stats). 2mhz. The CoCo has no acceleration. Not for audio, not for video. Just a brute force cpu, some interrupts, single dac, and a bitmap display (no tiles or sprites).

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Wed Jan 08, 2014 5:29 am

The biggest hindrance to pcm on the MD is the damn serial bank register. It takes 9 writes with the associated shifts to set the next bank to access. The MD would have been much easier to do pcm on if they'd used a parallel bank register.

Mask of Destiny
Very interested
Posts: 615
Joined: Thu Nov 30, 2006 6:30 am

Post by Mask of Destiny » Wed Jan 15, 2014 11:22 pm

With some help from Google I found the thread

I'm currently working on a sound driver that supports 2 PCM channels with resampling and a 12KHz output frequency. It runs entirely on the Z80, but scheduling of bank switches and sample buffering is encoded on the command stream which makes it complicated to work with. I'm currently working on a script to deal with that complexity so that you can write the command stream in a more sane format. I'll hopefully have something demoable in a few days.

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Thu Jan 16, 2014 7:30 pm

Mask of Destiny wrote:With some help from Google I found the thread

I'm currently working on a sound driver that supports 2 PCM channels with resampling and a 12KHz output frequency. It runs entirely on the Z80, but scheduling of bank switches and sample buffering is encoded on the command stream which makes it complicated to work with. I'm currently working on a script to deal with that complexity so that you can write the command stream in a more sane format. I'll hopefully have something demoable in a few days.
Yeah, that's the thread and code I was talking about. The last mixer loop code was in this post in that thread: viewtopic.php?p=17741#17741

I really need to work on that idea some more. Maybe after Doom...

Post Reply