Author Topic: PCE PCM  (Read 10769 times)

spenoza

  • Hero Member
  • *****
  • Posts: 2751
Re: PCE PCM
« Reply #135 on: January 13, 2017, 03:39:39 PM »
.nsf is the format of NES music files.
<a href="http://www.pcedaisakusen.net/2/34/103/show-collection.htm" class="bbc_link" target="_blank">My meager PC Engine Collection so far.</a><br><a href="https://www.pcenginefx.com/forums/" class="bbc_link" target="_blank">PC Engine Software Bible</a><br><a href="http://www.racketboy.com/forum/" c

elmer

  • Hero Member
  • *****
  • Posts: 2153
Re: PCE PCM
« Reply #136 on: January 13, 2017, 03:44:13 PM »


and that's how we ended up with AKB48 on the MSX.   lol

CHECK OUT THE MML IN THE VIDEO.

Hahaha ... I thought that it was particuarly funny that the MSX player software crashed and random garbage text just started scrolling up the screen!  :lol:

...

...

...

Oh! That was the MML? Sorry!  :oops:  :wink:

Michirin9801

  • Hero Member
  • *****
  • Posts: 589
Re: PCE PCM
« Reply #137 on: January 13, 2017, 03:51:50 PM »
Okay so, here's a couple more examples of sampled FM basses at 7KHz on the NES
Carat Magical Blocks - BGM#5 with the bass from the exact same song on the PC-98
http://sta.sh/0i7cvoanj38

and CyberBlock Metal Orange - Stage 3 with the bass from Romancia's Opening theme
http://sta.sh/09472c9hxd4


Errr ... this will probably sound terribly ignorant ... but what's a .nsf file, and what plays it?  :oops:


.nsf is the format of NES music files.

Yeah, just try these files with your NES emulator of choice, but I had better results with FCEUX than Nestopia...
Chipamp can also play them, but it adds a fake stereo that the NES doesn't really have, and I find it to be unauthentic so I never use it for NES music...

I went with NES for these examples because it's the closest approximation that I can get to what the sampled FM basses at 7KHz might sound like on the PC engine as of right now...
They're most likely gonna sound noticeably better than this because the NES DPCM isn't exactly up to par with what the PCE can play sample-wise, but still, it's a rough idea of the kind of sampling I have in mind to use with Bonknuts' driver!
« Last Edit: January 13, 2017, 03:54:02 PM by Michirin9801 »

elmer

  • Hero Member
  • *****
  • Posts: 2153
Re: PCE PCM
« Reply #138 on: January 13, 2017, 05:03:13 PM »
.nsf is the format of NES music files.

Yeah, just try these files with your NES emulator of choice, but I had better results with FCEUX than Nestopia...

Thanks!  :)

Ahhh ... OK. I *never* run NES stuff, so I had no idea.

As usual, Mednafen comes to the rescue!  :clap:

BTW ... I know that you don't like command-line programs, but something like this is just a case of dragging-and-dropping the .nsf file onto the "mednafen.exe" icon in Windows Explorer and it fires right up and plays.

Mednafen is an outstanding-accurate emulator, and Rypheca and her team have done an amazing job with it.


I went with NES for these examples because it's the closest approximation that I can get to what the sampled FM basses at 7KHz might sound like on the PC engine as of right now...
They're most likely gonna sound noticeably better than this because the NES DPCM isn't exactly up to par with what the PCE can play sample-wise, but still, it's a rough idea of the kind of sampling I have in mind to use with Bonknuts' driver!

Yeah ... I think that we're going to need Bonknuts' expertise here.

A 7KHz sample rate should be fine for bass frequency samples, but getting a good result is going to require the 8-bit or 10-bit output that his driver provides. 8-bit should be plenty if it's reasonably linear instead of logarithmic.

The granularity of the volume stepping in the channel's regular 5-bit output is just too harsh for a good low-frequency waveform output (IMHO).

esteban

  • Hero Member
  • *****
  • Posts: 24063
Re: PCE PCM
« Reply #139 on: January 14, 2017, 12:20:21 AM »


and that's how we ended up with AKB48 on the MSX.   lol

CHECK OUT THE MML IN THE VIDEO.

Hahaha ... I thought that it was particuarly funny that the MSX player software crashed and random garbage text just started scrolling up the screen!  :lol:

...

...

...

Oh! That was the MML? Sorry!  :oops:  :wink:

Hahahahahhaha.
  |    | 

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: PCE PCM
« Reply #140 on: January 14, 2017, 12:43:56 AM »

A 7KHz sample rate should be fine for bass frequency samples, but getting a good result is going to require the 8-bit or 10-bit output that his driver provides. 8-bit should be plenty if it's reasonably linear instead of logarithmic.

The granularity of the volume stepping in the channel's regular 5-bit output is just too harsh for a good low-frequency waveform output (IMHO).

 I can do a few driver versions (mixers). 4 channels at 7bit mixed to 9bit, scaled to 10bit is fastest. Or four channels at 8bit steams but saturation on paired streams, mixed to 9bit -> scaled 10bit. Actually, you could probably modify the mixer however you want once you see them. I did 16 steps of volume, linear, and it sounded pretty decent. You can do more, but the LUT will be bigger. 7bit streams makes the volume table twice as small as one for 8bit streams.

 The idea is pretty simple: 7bit unsigned samples -> volume LUT -> becomes 8bit 2's complement value -> add all four channels -> some flag checking and branch to 10bit decode LUT -> two 5bit values (in byte form) in two different buffers for the playback driver.

 I mean, I can write it - but something tells me you probably don't need me to ;)

Michirin9801

  • Hero Member
  • *****
  • Posts: 589
Re: PCE PCM
« Reply #141 on: January 14, 2017, 02:15:24 AM »
A 7KHz sample rate should be fine for bass frequency samples, but getting a good result is going to require the 8-bit or 10-bit output that his driver provides. 8-bit should be plenty if it's reasonably linear instead of logarithmic.

The granularity of the volume stepping in the channel's regular 5-bit output is just too harsh for a good low-frequency waveform output (IMHO).
I don't know, I think 5 bit would be plenty good enough >w>
If these basses already sound pretty good in 1 bit, then 5 bit should be A-OK, and you know what? Being 5 bit could actually make the sampled basses fit better with the PSG sounds! Or at least that's what I imagine, but then again what do I know? I have yet to hear them playing on the actual PCE...

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: PCE PCM
« Reply #142 on: January 14, 2017, 03:10:17 AM »
All this discussion about samples and soft drivers, reminds me of Nintendo's Sappy engine for GBA.
You can find the doc on RHDN; search for "sappy" in documents section.

 The driver is mixing 8bit PCM streams into a single 8bit DAC. But the driver doesn't support saturation, so too much amplitude (which translates into bit depth on a fixed system like this) causes wrap around. That means if you wanted something like 4 sampler channels, you'd have to use 6bit samples (or samples with amplitude that doesn't expand beyond 6bit levels). There are custom mixers for GBA, but a lot of games used this default Sappy engine.

 I also think I might investigate using the 10.5khz mode for 10bit DAC output. 44% cpu resource on even Timer calls and ~9% on odd calls. averaging overall 26% cpu for the driver. And what, 10% for the mixer? I could use that kind of setup.

 
 

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: PCE PCM
« Reply #143 on: January 14, 2017, 03:11:58 AM »
Or at least that's what I imagine, but then again what do I know? I have yet to hear them playing on the actual PCE...

 Make me a quick XM with just the bass or whatever type sampler instrument and I'll use my XM player to test it out and record it from the real console.

Michirin9801

  • Hero Member
  • *****
  • Posts: 589
Re: PCE PCM
« Reply #144 on: January 14, 2017, 04:14:21 AM »
All this discussion about samples and soft drivers, reminds me of Nintendo's Sappy engine for GBA.
You can find the doc on RHDN; search for "sappy" in documents section.

 The driver is mixing 8bit PCM streams into a single 8bit DAC. But the driver doesn't support saturation, so too much amplitude (which translates into bit depth on a fixed system like this) causes wrap around. That means if you wanted something like 4 sampler channels, you'd have to use 6bit samples (or samples with amplitude that doesn't expand beyond 6bit levels). There are custom mixers for GBA, but a lot of games used this default Sappy engine.
I really wish there was like a tracker or something for the GBA which used the Sappy engine, I've been struggling to get authentic-sounding GBA music done for a while now, and the closest that I could get was to run the samples that I wanted through the PCE to lower their bit depth to 5 bit, then record the samples and do an 8 channel song on openMPT and combine it with a Game Boy tune from Deflemask, and then I put the two together and try my best to make them not go out of sync (which always happens, every single time)
What I want to do with GBA audio is get a sound similar to that of Densetsu no Stafy or Mario Kart Super Circuit, which in my opinion sound absolutely gorgeous and are the perfect mix of sampled music and chiptunes~
So I have sampled leads, drums and maybe strings/choir/orch-hits, GB DAC bass, GB Noise Hi-Hats and GB Pulse harmonic support, and I think it's the lower bit depth of the GBA samples that make them blend so well with the GB chiptunes and make that perfect blend of the two~ ♥I LOVE IT♥

But unfortunately, I can't find any other way to intentionally lower the bit depth of samples to anything lower than 8 bit, much less a tracker that lets me use both a GB soundchip and an adjustable amount of sample channels at the same time with varying bit depths so I have to struggle to sync 2 songs from 2 trackers together which is a major pain in the arse...

Or at least that's what I imagine, but then again what do I know? I have yet to hear them playing on the actual PCE...

 Make me a quick XM with just the bass or whatever type sampler instrument and I'll use my XM player to test it out and record it from the real console.
Right on!
« Last Edit: January 14, 2017, 04:19:05 AM by Michirin9801 »

Michirin9801

  • Hero Member
  • *****
  • Posts: 589
Re: PCE PCM
« Reply #145 on: January 14, 2017, 06:32:52 AM »
Okay, here's a 1 channel XM with the 4 basses I've sampled thus far:
http://sta.sh/0hwn4lvw2hz
The order is Valkyrie Bass -> Romancia Bass -> Final Fight 3 Bass -> Carat Bass

And here's a 4 channel XM with the Carat Bass, Jackie Chan's Action Kung Fu Drums, a random SNES Choir and occasionally a vibraphone playing Carat BGM5:
http://sta.sh/02dmn2v53cvb
It lacks the leads and half of the harmonics because that would play on the remaining PSG channels, but still, I wanna hear this playing in a proper PCE rom!
« Last Edit: January 14, 2017, 06:35:17 AM by Michirin9801 »

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: PCE PCM
« Reply #146 on: January 14, 2017, 02:53:34 PM »
My XM player is just quick and dirty - it doesn't support finetune per instrument and doesn't support mapping multiple samples in a back to different notes (JCAKF instrument). The player was just something quick and dirty to test and show off the PCM driver. The driver does support fine tune, but I didn't implement it in the XM reader/parser for the player. It doesn't support the volume envelope format either. I literally wrote it in ~3 hours.

 In other words, if I converted these they'd probably sound like ass without that support.


 If you need an app to do bit depth reduction on wave files, I can adapt something I already have for that. Simple turnication of bits (shifting) - nothing fancy. (Edit) Also, Cool Edit Pro 2.1 does bitdepth reduction (though the results are still stored in 8bit or whatever format).
« Last Edit: January 14, 2017, 02:59:36 PM by Bonknuts »

Michirin9801

  • Hero Member
  • *****
  • Posts: 589
Re: PCE PCM
« Reply #147 on: January 14, 2017, 04:42:01 PM »
My XM player is just quick and dirty - it doesn't support finetune per instrument and doesn't support mapping multiple samples in a back to different notes (JCAKF instrument). The player was just something quick and dirty to test and show off the PCM driver. The driver does support fine tune, but I didn't implement it in the XM reader/parser for the player. It doesn't support the volume envelope format either. I literally wrote it in ~3 hours.

 In other words, if I converted these they'd probably sound like ass without that support.

 If you need an app to do bit depth reduction on wave files, I can adapt something I already have for that. Simple turnication of bits (shifting) - nothing fancy. (Edit) Also, Cool Edit Pro 2.1 does bitdepth reduction (though the results are still stored in 8bit or whatever format).

I see... Well, when you can actually convert these examples into something that will play on the PCE, please let me know...
Also, thanks! I'm gonna check Cool Edit Pro now, I don't mind it not actually 'being' lower bit depth, so long as it 'sounds' lower bit depth

elmer

  • Hero Member
  • *****
  • Posts: 2153
Re: PCE PCM
« Reply #148 on: January 15, 2017, 05:55:23 AM »
If you need an app to do bit depth reduction on wave files, I can adapt something I already have for that. Simple truncation of bits (shifting) - nothing fancy. (Edit) Also, Cool Edit Pro 2.1 does bitdepth reduction (though the results are still stored in 8bit or whatever format).

SOX is another tool that supports that kind of truncation ... I'm using it in the pre-processing stage for the PCE/PC-FX ADPCM conversion. But I know that Michirin9801 isn't a fan of command-line tools.

But ... do we know if the waveform data is in linear-space, or in logarithmic-space?  :-k

The amplitude levels in R1, R4 & R5 are all logarithmic, and I was finally curious-enough to look at the volume level number in excel.

Wow! I didn't realize that we were compressing down an approx 15-bit linear audio range into only 5-bits!  :shock:

If the waveform data uses a similar logarithmic-space ... then the simple bit-truncation method isn't going to give great results.

I think that you and ccovell and mednafen have already checked this kind of stuff with oscilliscopes.

Do you know whether it is linear or logarithmic?


The idea is pretty simple: 7bit unsigned samples -> volume LUT -> becomes 8bit 2's complement value -> add all four channels -> some flag checking and branch to 10bit decode LUT -> two 5bit values (in byte form) in two different buffers for the playback driver.

 I mean, I can write it - but something tells me you probably don't need me to ;)

Ahh ... but the devil-is-in-the-details, and it's always much nicer to use tried-and-tested code rather than having to write every darned thing by myself.  :wink:

I'd much rather be able to take what you've got, give you appropriate credit for all the hard work that you've done, and be able to concentrate my limited time on the other stuff that hasn't already been written!  :)

I should be able to update the dmf2pce project on github with the latest code this week, and I'll be adding in the work-in-progress version of the huzak driver at the same time.

I'm hoping that it will have a solid-enough foundation by then that it'll be a matter of making improvements, rather than the large-scale reorganization that's still going on right now.

The point, once again, is to make this stuff open source (like Uli's improvements to HuC), so that any programmer can take it and modify it for their own needs.

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: PCE PCM
« Reply #149 on: January 15, 2017, 06:23:47 AM »
But ... do we know if the waveform data is in linear-space, or in logarithmic-space?  :-k

The amplitude levels in R1, R4 & R5 are all logarithmic, and I was finally curious-enough to look at the volume level number in excel.

Wow! I didn't realize that we were compressing down an approx 15-bit linear audio range into only 5-bits!  :shock:

If the waveform data uses a similar logarithmic-space ... then the simple bit-truncation method isn't going to give great results.

I think that you and ccovell and mednafen have already checked this kind of stuff with oscilliscopes.

Do you know whether it is linear or logarithmic?

 Volume (channel, pan, global) for all channels is log, but waveform data is linear. The 10bit waveform data for paired channels for 10bit is linear as well; the second channel volume is set to be 1/32 that of channel 1, so it all lines up. You can do 12 or 13bit with three channels I believe, but it's not really worth it.

 I just ordered an Owon SDS1702 scope, so I can retest test stuff if you need. Probably gonna pickup a 100mhz 16 channel logic analyzer soon too.