Author Topic: PCE PCM  (Read 10682 times)

elmer

  • Hero Member
  • *****
  • Posts: 2153
Re: PCE PCM
« Reply #60 on: December 23, 2016, 06:33:44 AM »
I found a few hucards games doing it, but specifically Street Fighter 2 (does it for two sample channels). It's faster than normal bitpacked sample that other PCE games tend to use. I've never seen the scheme touko used.

 End of sample is convenient if you have the free bit for it, but it's not necessary. But that is awesome that you fitted it in there. I still like the padded end of sample block method (whatever that block is - 116 samples is the block in this case), where you check in vsync int.

 I honestly thought the SF2 method would be faster. It looks simpler IMO (less steps/shifts).

Does SF2 do the unpacking during the TIRQ, of does it buffer up an entire 116-byte frame?  :-k

One of the things that I liked about the 3-in-2-bytes scheme was that it avoided the need to check for bank-overflow in the middle of a packet. With 8-samples-in-5-bytes, I don't think that you can do that.

That's not a problem if you're mapping in 2 banks to build the 116-byte buffer during vblank, but it's expensive to do in a TIRQ.

Plus ... I kinda like having that bit in there to mark the end-of-sample, or to signal a loop-point.  :wink:

Your double-buffered scheme is something that I'll need to look at seriously and compare the timings.


Quote
Quote
Mapping stuff into TAM #4 isn't needed, because Touko is already relying on his sample data being aligned on an even boundary, so I removed it, and got rid of the X and Y registers which were wasting cycles.
I didn't catch that he was doing that. I shaved the 6 sample buffer method down to 8.9%, but buffer difference isn't big enough for the overhead (have a pointer of playback buffer) to over come the non pointer method you did with a 3 sample cache system.

Ahhh ... I missed that you'd already tried the 6-sample-at-once method.

Yep, I was afraid that the overhead from keeping track of which sample you're playing would outweigh the savings in the bank switching.


Quote
A block comment in assembly! I never seen anyone do that - haha. Your code is clean, clear, and and easy to understand. And fast. I'm impressed :D

Thanks, that means something, coming from you!  :D

And Touko was right ... the overhead of the banking for every sample in the simple playback code that I posted earlier really *was* significant.

I'm very surprised to see it, but the packed playback code is actually a tiny bit faster than simple playback code.

Now I'm not sure if that will extend to multi-channel playback, but the idea of getting a 30% space-savings on sample size for no CPU playback cost is pretty amazing!


In other words, you expressed interest in the soft mix player I made - the only with 4 channels on two PCE channels. That wouldn't use any compression, because the sample depth is higher than 5bit. Would that mean you're not interested in it?

Well, *I'm* certainly interested in seeing the code.  :)

Having a high-quality sample alternative for use on Title Screens and places like that would be nice.

It all depends upon the CPU and memory costs.

The only thing that I don't overly like it losing stereo panning.

Having a drum-roll pan across the stereo field, or having a effect come from the left or right, are both common occurrences in games.
« Last Edit: December 23, 2016, 09:42:15 AM by elmer »

Arkhan

  • Hero Member
  • *****
  • Posts: 14142
  • Fuck Elmer.
    • Incessant Negativity Software
Re: PCE PCM
« Reply #61 on: December 23, 2016, 12:49:25 PM »
You could also just limit it to three channels or so, and let the user pick based off their own needs, really.

Id likely only need one channel for drum samples, leaving another noise channel open for crunchy sfx.   i cant imagine needing to tie both noise channels up.  Three channels of sampled percussion seems excessive, since even Amiga tunes dont really do that. 

it would be easy to throw errors at compile time if there is a non possible configuration.

The reason we suggest five and six is that they already support mode switching. 

I wouldnt use channel one, because its the only channel that supports lfo, as useless as some say it is.

Again, this is why maybe supporting three, and letting users pick is best.

Personally, the way  i set tunes up, i like putting rhythm at the bottom, or far right, depending on if were talking mml, piano rolls, or trackers.

Sticking drums in the middle of a piano roll setup or a tracker tune column thing bugs me personally, lol


Sent from my D6708 using Tapatalk

[Fri 19:34]<nectarsis> been wanting to try that one for awhile now Ope
[Fri 19:33]<Opethian> l;ol huge dong

I'm a max level Forum Warrior.  I'm immortal.
If you're not ready to defend your claims, don't post em.

Arkhan

  • Hero Member
  • *****
  • Posts: 14142
  • Fuck Elmer.
    • Incessant Negativity Software
Re: PCE PCM
« Reply #62 on: December 23, 2016, 02:56:58 PM »

A block comment in assembly! I never seen anyone do that - haha. Your code is clean, clear, and and easy to understand. And fast. I'm impressed :D

Really? ....  block comments are... pretty normal lol.  Im surprised youve not seen them in asm code before...

 Theyre all over Atlantean, Inferno, and Squirrel stuff!

I guess that might be the difference between professional backgrounds, and tinkering backgrounds.

They used Apple 2 assembly on screen for Terminator, lol.   You can see like floppy drive code. 


« Last Edit: December 23, 2016, 07:26:58 PM by Arkhan »
[Fri 19:34]<nectarsis> been wanting to try that one for awhile now Ope
[Fri 19:33]<Opethian> l;ol huge dong

I'm a max level Forum Warrior.  I'm immortal.
If you're not ready to defend your claims, don't post em.

Windcharger

  • Newbie
  • *
  • Posts: 44
Re: PCE PCM
« Reply #63 on: December 23, 2016, 07:14:08 PM »
Windcharger: Maybe I should make page 3 of the PCE Cribsheets; audio stuffs. Sometimes it's a lot to keep track of, especially if you're not always working with the hardware directly.

Yep, that would be useful.

Sorry for late response.  Holidays in full swing.   :)

touko

  • Hero Member
  • *****
  • Posts: 953
Re: PCE PCM
« Reply #64 on: December 23, 2016, 09:49:59 PM »
Quote
Touko: Do you need compression?
Not really!

Quote
Or are you just using compression on the samples because it's a waste not to?
Yes, i think 33% lesser with only 30 cycles is not negligible  :wink:
Of course, without compression, the code is faster and well suited IMO for SCD-rom .

Quote
Would that mean you're not interested in it?
for now i have only hucard project, this why space is important, but i'll try with no compression to see how fast it is vs compression.

Quote
but your code is a bit clearer to follow.
Yes  :P

Quote
My point was that you don't need to waste 6 cycles by doing a test for sample-still-playing at the start of every one of the 116/117 interrupts ... it wastes 696/702 cycles-per-frame during normal playback.
It's a first try, i'll see now with a better code organisation if i can do it better .
May be without compression .

elmer

  • Hero Member
  • *****
  • Posts: 2153
Re: PCE PCM
« Reply #65 on: December 25, 2016, 05:30:07 AM »
You could also just limit it to three channels or so, and let the user pick based off their own needs, really.

Id likely only need one channel for drum samples, leaving another noise channel open for crunchy sfx.   i cant imagine needing to tie both noise channels up.  Three channels of sampled percussion seems excessive, since even Amiga tunes dont really do that.

Yeah, I can't really see the practical *need* for more than 3 channels of samples, and honestly, 2 would probably be enough.

What you're saying is why I was suggesting putting the samples on channels 4 & 5, and leaving channel 6 open for regular PSG-drums or PSG-sfx.

The question is mainly one of "freedom", and programmers don't like it ... flexibility costs CPU cycles.

The sound driver itself doesn't care, and I suppose that it would be possible to provide a couple of different interrupt handlers for different channel selections.


Really? ....  block comments are... pretty normal lol.  Im surprised youve not seen them in asm code before...

Theyre all over Atlantean, Inferno, and Squirrel stuff!

Yep, I'm originally used to them from things like the FigForth source code and the Atari 400/800 ROM listings.

I don't always put them in my own code when I'm just hacking something up, but it's important (IMHO) to document utility code and functions that might be used by someone else, or that you expect to use for a long time (because you'll forget how it works and why you made certain choices).

So, for these "public" displays of code, which is something that I'd like to see more of here, I believe that it's good to take a bit of extra time.


for now i have only hucard project, this why space is important, but i'll try with no compression to see how fast it is vs compression.

...

It's a first try, i'll see now with a better code organisation if i can do it better .
May be without compression.

I look forward to seeing your results!  :)

If you drop that initial test, and optimize the flow for the most-common case, then I suspect that you'll get to very-close-to or faster-than my example.

Arkhan

  • Hero Member
  • *****
  • Posts: 14142
  • Fuck Elmer.
    • Incessant Negativity Software
Re: PCE PCM
« Reply #66 on: December 25, 2016, 08:19:39 AM »
I always put block comments.  They make me hard.


Id see about just letting users define which channels.   Im not sure how youll be writing it, but you should be able to make it a bit dynamic and error out if someone sets up 4+ sample channels.



Sent from my D6708 using Tapatalk

[Fri 19:34]<nectarsis> been wanting to try that one for awhile now Ope
[Fri 19:33]<Opethian> l;ol huge dong

I'm a max level Forum Warrior.  I'm immortal.
If you're not ready to defend your claims, don't post em.

touko

  • Hero Member
  • *****
  • Posts: 953
Re: PCE PCM
« Reply #67 on: December 27, 2016, 04:39:10 AM »
Error .., i solved my sound problem  8)
« Last Edit: December 27, 2016, 09:28:05 PM by touko »

touko

  • Hero Member
  • *****
  • Posts: 953
Re: PCE PCM
« Reply #68 on: January 05, 2017, 10:39:27 PM »
Quote
The clicking, if you play the second example, is just me not initializing the driver before sending anything to it (I just haven't got around to it).
How really avoiding the clicking ??
« Last Edit: January 05, 2017, 11:56:27 PM by touko »

Michirin9801

  • Hero Member
  • *****
  • Posts: 589
Re: PCE PCM
« Reply #69 on: January 07, 2017, 03:12:29 PM »
Umm, sorry for butting in the conversation of experts, a lot of what you've said went way over my head but let me see how much I understand:
You're taking 2 of the PCE's hardware channels, which are 5 bit, and putting them together to get a single 10 bit PCM, right?
And then you're soft-mixing 4 8 bit samples into that single 10 bit channel...
But apparently, the PCE can't natively do different pitches for the same sample, right?
But those examples you've shown have the PCE doing different sampled notes...
First question: Are those different notes all different samples or are they pitch-shifted notes? And if the latter is the case, how much freedom do you have for pitch-shifting?

When I fire up one of your example ROMs I see the names "XM file" and "MilkyTracker" so apparently I could use OpenMPT to make music for this sound driver, I mean, OpenMPT is XM compatible, in fact, that's the format I use by default because that's the format I can export SNES samples to...
Second question: Do you have any idea of when and how will I be able to make music for this sound driver and take advantage of all 8 sound channels? I mean, just the thought of having 8 channels on the PCE already fills me with ideas!
I know I'll have my sample-usage limited because of the low memory and all, but Batman did sampled bass, orch-hits and drums on a HuCard, and I'd want to have at least those things sampled, the rest of the instruments can be (and would probably be better off as) regular wavetables, but having a deeper and more dynamic bass sampled from FM playing alongside 2 channels of good'ol sampled drums to make more interesting drums, and still have 4 channels worth of wavetables to compose my melody and harmony and one more PCM for sound effects on top of that would be very welcome!

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: PCE PCM
« Reply #70 on: January 07, 2017, 05:50:44 PM »
The rom link that shows XM and milkytracker; that's playing modified XM files. In those files, you have full note range from octave 0 to octave 6, and fine-stepping of 32 units in between each note (XM files only do 16 IIRC). The fine-steps are linear, not period base, so they are the same "weight" regardless of the octave (the opposite case is something that always bothered me with period based systems; nes, pce (native), amiga, etc).

 So yeah. It's doing frequency scaling in software, and not a set of prescaled notes. Think SNES, but nearest neighbor instead of filtered. And at 7kz (or 14khz, or 16khz.. depending on the driver). The demo roms that show "xm", are not 8bit samples mixed in 10bit mode. They are just normal 5bit samples. I haven't made a public mixture for the 10bit mode one that does realtime frequency scaling. heh - I worked on this stuff at my leisure because I know the probably of people using the PCM driver, in support of their own music engine or homebrew stuff.. is about null. 

 The "driver" just gives a programmer an interface/capability to a pseudo hardware function. It's not the music engine itself. The example roms with music, is just a quick hack job to play XM files (it only supports a few FX) - to demo the driver.

 What you were trying to do with wave-form phasing, you could just do normally like in an XM file, on the PCE with this driver. But like I stated earlier in the thread; there are different flavors and versions of the driver. The fastest version is the 5bit version @7khz. The 5bit @ 14khz didn't really improve much at all over the 7khz version. So I'm working on setting up a 8bit @ 7khz version (4 channels mixed into 10bit output.. but all those channels will be mono).

Michirin9801

  • Hero Member
  • *****
  • Posts: 589
Re: PCE PCM
« Reply #71 on: January 08, 2017, 04:17:18 AM »
The rom link that shows XM and milkytracker; that's playing modified XM files. In those files, you have full note range from octave 0 to octave 6, and fine-stepping of 32 units in between each note (XM files only do 16 IIRC). The fine-steps are linear, not period base, so they are the same "weight" regardless of the octave (the opposite case is something that always bothered me with period based systems; nes, pce (native), amiga, etc).

 So yeah. It's doing frequency scaling in software, and not a set of prescaled notes. Think SNES, but nearest neighbor instead of filtered. And at 7kz (or 14khz, or 16khz.. depending on the driver). The demo roms that show "xm", are not 8bit samples mixed in 10bit mode. They are just normal 5bit samples. I haven't made a public mixture for the 10bit mode one that does realtime frequency scaling. heh - I worked on this stuff at my leisure because I know the probably of people using the PCM driver, in support of their own music engine or homebrew stuff.. is about null. 

 The "driver" just gives a programmer an interface/capability to a pseudo hardware function. It's not the music engine itself. The example roms with music, is just a quick hack job to play XM files (it only supports a few FX) - to demo the driver.

 What you were trying to do with wave-form phasing, you could just do normally like in an XM file, on the PCE with this driver. But like I stated earlier in the thread; there are different flavors and versions of the driver. The fastest version is the 5bit version @7khz. The 5bit @ 14khz didn't really improve much at all over the 7khz version. So I'm working on setting up a 8bit @ 7khz version (4 channels mixed into 10bit output.. but all those channels will be mono).
Oh I see... Being 5 bit explains why the samples sound so delightfully scratchy, kinda like they came from the GBA or something, (which is something I've been wanting actually)
And honestly, I'd rather have Mono than the Amiga-style hard-panning... (Btw, was that a limitation or was it intentional?)

To be honest, if I were to make a soundtrack for a real PCE game I wouldn't really use any samples... Well actually, I'd have 2 versions of the soundtrack, one for the regular PCE/TG16 units without the CD add-on, with just the 6 regular channels and wave + noise percussion, and the other for the units with the CD add-on, which would play sampled drums on the ADPCM channel of the CD unit (on a HuCard game btw) and free up an extra channel to play something like another chord note or a delay/reverb effect...
I'd want the music to take as little CPU time as possible so that more of it would be available to cram as much parallax scrolling on the backgrounds as humanly possible! ;3

But still, I'd love to use this driver when it's 'ready' to see just how much I can get out of the PC engine's sound, heck, I'd totally port over some GBA songs to the system using the PCM channels to emulate the GBA's direct audio and the remaining wavetable channels to emulate the Game Boy soundchip! Or something like that... If anything, this driver could be used to make a really awesome demo kinda like the ones people do for the C64 and stuff!

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: PCE PCM
« Reply #72 on: January 08, 2017, 06:22:03 AM »
Oh I see... Being 5 bit explains why the samples sound so delightfully scratchy, kinda like they came from the GBA or something, (which is something I've been wanting actually)
And honestly, I'd rather have Mono than the Amiga-style hard-panning... (Btw, was that a limitation or was it intentional?)

 Honestly, it was kind of an experiment to see what kind of samples sounded fine in 5bit. Some sound great, and some not so great. The hard panning was just from the songs I pulled; 5bit sample mode has full stereo space as normal PCE channels. There's a trick that can clean up some "lead" style samples in 5bit mode though - pairing the sample with a normal PCE channel helps mask the lower resolution artifacts. The human ear can't hear "noise" artifacts in loud sounds like it can in lower amplitude waveforms (one of the reasons why old telephone systems would use non linear compression for audio over lines; analog versions a-law and u-law). Blazing Lazers samples for voices on power ups sound horrible by themselves (4bit audio), but in game while the music is playing - they sound more clear. Loudness is key.



Quote
I'd want the music to take as little CPU time as possible so that more of it would be available to cram as much parallax scrolling on the backgrounds as humanly possible! ;3

 Who's doing the programming? Parallax tricks, in assembly, aren't very cpu resource hungry if done right. I could see maybe if you're going to extreme ends for parallax (wasting 50% cpu or more for insane stuffs), but I doubt it'd have much impact on a typical PCE game, in assembly, with samples. The HuPCM driver is customizable: if you only need 1 or 2 channels with "frequency scaling" (aka sample-based synth), then the rest as fixed frequency (1 or 2) won't eat up as much as doing all 4 using software sample-based synth. Stuff like that.

 I just want an expansion of the PCE sound. I don't want to necessarily replace the PCE sound, but something that works with it. 8bit mixing allows some bass to the PCE (thump/bump), and software samplebased synth gives it much more range with bass style instruments - as well as others (imagine using that orch hit in batman, but at any note/octave).

 To give an idea on the 5bit sample-based synth one:
Quote
The original one, if you played all 4 XM channels AND 2 regular sample channels (6 total) all at the same time - it would take 35.7% cpu resource.
Air Zonk sound engine takes up 30% and that's just one sample. So 6% more, and you have all 6 channels playing samples (4 with frequency scaling!). The less channels you want to do for sample-based synth, the less cpu resource you would need.
« Last Edit: January 08, 2017, 06:28:52 AM by Bonknuts »

Michirin9801

  • Hero Member
  • *****
  • Posts: 589
Re: PCE PCM
« Reply #73 on: January 08, 2017, 08:58:04 AM »
Quote
I'd want the music to take as little CPU time as possible so that more of it would be available to cram as much parallax scrolling on the backgrounds as humanly possible! ;3

 Who's doing the programming? Parallax tricks, in assembly, aren't very cpu resource hungry if done right. I could see maybe if you're going to extreme ends for parallax (wasting 50% cpu or more for insane stuffs), but I doubt it'd have much impact on a typical PCE game, in assembly, with samples. The HuPCM driver is customizable: if you only need 1 or 2 channels with "frequency scaling" (aka sample-based synth), then the rest as fixed frequency (1 or 2) won't eat up as much as doing all 4 using software sample-based synth. Stuff like that.
Umm, nobody, It's a hypothetical situation in case I'd end up working on a PCE game >w>
Which I really want to, but first I need to finish this Mega Drive game that I've started before I got into PCE music, after that I have no further plans to work on the MD, it took a really long time to get the system sounding the way I want to, and now that I did get it sounding the way I like I can't change the songs that were already done because the programmer doesn't want them to change...
Oh well, all of my future ideas are for the PC engine, the Super Nintendo and the PC-98, but the PC-98 has pretty much no English-speaking market and even fewer dedicated devs than the PCE, so I'll probably end up making just a regular PC game that runs at 640 x 400 at 16 colours and has an OPN/OPNA soundtrack...
(Btw, I'm also the one doing the grafx and the level design...)

I just want an expansion of the PCE sound. I don't want to necessarily replace the PCE sound, but something that works with it.
So do I!
I'd never want to replace the PCE sound, I couldn't live without dem 5 bit waves~
But I welcome the idea of expansion, especially if it means that I can use sampled basses, drums and orch hits!

Arkhan

  • Hero Member
  • *****
  • Posts: 14142
  • Fuck Elmer.
    • Incessant Negativity Software
Re: PCE PCM
« Reply #74 on: January 08, 2017, 05:51:43 PM »
Paula is hard panned L/R out of stupidity, kind of like how they voluntarily picked that shit tier palette for the C64.   They chose those colors willingly.    Someone sat down and said "yes, we need two shades of olive, and 3 shades of gray.  that is what will make this f*cker look great!"



Amiga music with headphones SUCKED: 
   

What kind of MD game are you making?  That sounds interesting.

I don't even think the PC-98 really has a Japanese speaking market for anything other than music, last I checked.  I think people just realize you could do a PC game, as you've mentioned.   It's kind of like trying to make a DOS game now.   Just pretend.  It's all supposed to be compatible (ish)

There's PC 6001 stuff, and MSX, though.

I can't imagine you'd want to make PC-6001 tunes.    Maybe MSX, though.   

There's trackers on MSX



Suck on that shit, Amiga. 

lol.
[Fri 19:34]<nectarsis> been wanting to try that one for awhile now Ope
[Fri 19:33]<Opethian> l;ol huge dong

I'm a max level Forum Warrior.  I'm immortal.
If you're not ready to defend your claims, don't post em.