Author Topic: MML: What are people's actual complaints with the damn thing  (Read 7455 times)

Gredler

  • Guest
Re: MML: What are people's actual complaints with the damn thing
« Reply #90 on: December 09, 2016, 08:41:09 AM »
This one is really good too :


Very good, I love this

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: MML: What are people's actual complaints with the damn thing
« Reply #91 on: December 09, 2016, 09:18:20 AM »
Would a sample-based engine allow us to get more realistic sound effects? It'd be nice to have realistic sound effects, rather than trying to reproduce a cat meow or screech using musical notes.

Sample-base synthesis would allow you to get sounds (instruments) that you normally couldn't with the PCE chip.

 What you're referring to is just simple sample playback. Completely different thing and has nothing to do with music. You record a cat meowing, and then play the sample (think wave file) on the PCE... whenever. It's not really an engine. More like a driver in the simplest of terms. Such a driver can exist independent of any music engine.

DarkKobold

  • Hero Member
  • *****
  • Posts: 1200
Re: MML: What are people's actual complaints with the damn thing
« Reply #92 on: December 09, 2016, 09:50:39 AM »
Would a sample-based engine allow us to get more realistic sound effects? It'd be nice to have realistic sound effects, rather than trying to reproduce a cat meow or screech using musical notes.

Sample-base synthesis would allow you to get sounds (instruments) that you normally couldn't with the PCE chip.

 What you're referring to is just simple sample playback. Completely different thing and has nothing to do with music. You record a cat meowing, and then play the sample (think wave file) on the PCE... whenever. It's not really an engine. More like a driver in the simplest of terms. Such a driver can exist independent of any music engine.

Don't they use the same chip? I'm not sure how the sound chip works, but a sample would have to disrupt the music to play. Also, I'm not sure how I understand how you'd ever play a sample, since you'd have to recreate it with the various waveforms available on the PC Engine.
Hey, you.

TheOldMan

  • Hero Member
  • *****
  • Posts: 958
Re: MML: What are people's actual complaints with the damn thing
« Reply #93 on: December 09, 2016, 10:26:19 AM »
Quote
It'd be nice to have realistic sound effects, rather than trying to reproduce a cat meow or screech using musical notes.

If you can settle for low quality.....
Convert the effect down to 5 bits, split it into 32-byte chunks, assign a wave number to each, and cycle through them. (load wave n, play note, load wave n+1, etc) It's not gonna be high-quality, but someone else was trying to do this a few years ago.  I remember fixing squirrel to get it work.

BUT...
Quote
What you're referring to is just simple sample playback.
Quote
...a sample would have to disrupt the music to play.

Not necessarily. We haven't figured it out yet, but there are 2 channels on the psg that can be set to "direct-dda" mode. In theory, you could use those for sample playback. Would require a streamlined irq routine, I think.

Gredler

  • Guest
Re: MML: What are people's actual complaints with the damn thing
« Reply #94 on: December 09, 2016, 10:52:04 AM »
Thanks Old Man!

If you can settle for low quality.....
Convert the effect down to 5 bits, split it into 32-byte chunks, assign a wave number to each, and cycle through them. (load wave n, play note, load wave n+1, etc)

I'll take your question if we can settle for low quality as a compliment, because if you've seen my abilities so far to make this game I think it'd be a given that we have to settle with low quality ;)

Really though, I would be interested to at least try this and see what it sounds like, but have no idea where to start.

Is there documentation for loading wav files, and would you convert them to ascii then back to smaller wav files? I googled this a bit and it looked like a rats nest of reasoning and workflows for converting wav to 5bits.

Not necessarily. We haven't figured it out yet, but there are 2 channels on the psg that can be set to "direct-dda" mode. In theory, you could use those for sample playback. Would require a streamlined irq routine, I think.

This sounds promising, I can get us royalty free sound effects and wavs made by homies to use.

Thanks for the progress and further discussion, this and the huc thread are my favorite reading of the day lately :)

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: MML: What are people's actual complaints with the damn thing
« Reply #95 on: December 09, 2016, 11:10:29 AM »
Would a sample-based engine allow us to get more realistic sound effects? It'd be nice to have realistic sound effects, rather than trying to reproduce a cat meow or screech using musical notes.

Sample-base synthesis would allow you to get sounds (instruments) that you normally couldn't with the PCE chip.

 What you're referring to is just simple sample playback. Completely different thing and has nothing to do with music. You record a cat meowing, and then play the sample (think wave file) on the PCE... whenever. It's not really an engine. More like a driver in the simplest of terms. Such a driver can exist independent of any music engine.

Don't they use the same chip? I'm not sure how the sound chip works, but a sample would have to disrupt the music to play. Also, I'm not sure how I understand how you'd ever play a sample, since you'd have to recreate it with the various waveforms available on the PC Engine.

 Have you ever looked at a wave file? A just is 1D array. The axis is time. So, in principle, read in a sample from an array, write it to a port. Of course, PCs have code that does this for you (to put it simply). On the PCE, if you're not using someone else's code, what you need to do is find a way for the CPU to read the sample, in this case just a BYTE, and write it to a DAC (digital to analog device; a port).

 On some systems, there is hardware that grabs the byte it needs at whatever interval (time). The PCE doesn't have this. So you need to use the Timer Interrupt, which runs independent of the main cpu code. It grabs bytes from memory and writes it to a whatever channel DAC you choose. There are 6 channels on the PCE, you can stream up to 6 samples (wave files). It won't stop the music, but like sound FX - it will silence that channel while the sample is streaming. Think of the Timer interrupt routine like a second thread or additional core. Except it's not free. Overall it will take away from some cpu resource, but you won't ever need to incorporate it directly into your main code.

 If it's someone else writes it, then you can just simply interface with it: call function to tell the driver to play a sample. Simple as that. So yeah, it takes some overall cpu resource - but it doesn't "stop" your code to play a whole sample/stream.

 There are a lot of cool things you can do with interrupts. You know that point in your code where you want for the vsync() pass? Think about how much cpu resource is just going to waste. I've written a system on the PCE that has a main processing thread, and a background processing thread. The background processing thread runs during the wait loop part of a frame. I usually put decompression stuff there (or anytime I need data, but know that I need it X amount of frames ahead of time). On top of having an interrupt playing samples. And video interrupt doing full screen scanline effects. Interrupts are awesome.

 Just to note: You could do the main thread/background thread thingy in C. You need to move main loop to be called inside V-int. It gets a little tricky to setup, but it's doable. 

Quote
Not necessarily. We haven't figured it out yet, but there are 2 channels on the psg that can be set to "direct-dda" mode. In theory, you could use those for sample playback. Would require a streamlined irq routine, I think.
All channels, or any specific channel and any number of them, can be set to DDA mode. Or do you mean from the BIOS psg player?

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: MML: What are people's actual complaints with the damn thing
« Reply #96 on: December 09, 2016, 11:19:00 AM »
Is there documentation for loading wav files, and would you convert them to ascii then back to smaller wav files? I googled this a bit and it looked like a rats nest of reasoning and workflows for converting wav to 5bits.

 I only have like a bazillion and 1 converters and drivers for this sort of thing, for the PCE. If you guys end up using Squirrel, I can even hack the TRIQ for my own hook to play samples. Unless Old Man and team get this figured out in time when you need it, hit me up when you guys want to do sample streaming support.

 But if you do the hack method in squirrel that Old Man is talking about, it's not just lower sample quality - you'll also get a 60hz-120hz loud buzz/hum that accompanies it. You might not hear it on the SGX or CoreGrafx I models, but you'll hear it on other systems (Duo, TG16, original PCE, Coregrafx II, Duo-R, etc)

Punch

  • Hero Member
  • *****
  • Posts: 3278
Re: MML: What are people's actual complaints with the damn thing
« Reply #97 on: December 09, 2016, 11:19:50 AM »
Wait a second.

I thought that the channels 0-1 were the proper "sample" channels. Are you saying that it's possible to play them on any channel?

Does anyone have a proper doc for audio?

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: MML: What are people's actual complaints with the damn thing
« Reply #98 on: December 09, 2016, 11:21:15 AM »
Yes. All channels. Are people really ignorant of PCE audio stuffs??? Nobody reads the PCM threads I post either? I thought DDA mode was pretty common knowledge.

 PSG.txt from Magickit docs (I think it's in HuC PCEAS section too). Everything should be correct in that doc, except the LFO scaling part.
« Last Edit: December 09, 2016, 11:27:20 AM by Bonknuts »

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: MML: What are people's actual complaints with the damn thing
« Reply #99 on: December 09, 2016, 12:20:03 PM »
Just thinking out loud...

So I was looking over the TIRQ code for BIOS player. To hack in sample support, it seems that simply setting the PSG player tick to 1 and have the hook do the down counting and call the PSG player when that expires, for tempo control. Otherwise, outside the PSG player call - the main TIRQ hook outputs samples to whatever channel DAC.

 Those are just the small details. I'm not sure how much space the ripped player takes up in squirrel package, but I think it would be a better idea to keep using it instead of the built in one of the sys card (I assume it switches and uses that for CD projects - haven't looked that far ahead). That would easily solve how to introduce sample support into MML.

 The CD psg player (bios rom version) can be hacked for the hook that I described, but I'd need to know a few more details of how to optimally incorporate sample support for sound FX (aka not drum kits). Otherwise the unoptimal way would be to just reserve one channel for all sample playback. It's crude, but it should work. Again, this is for sound FX - not sample instruments (drumkits, orch-hits, etc).

Gredler

  • Guest
Re: MML: What are people's actual complaints with the damn thing
« Reply #100 on: December 09, 2016, 01:49:18 PM »
Are people really ignorant of PCE audio stuffs???

Yes

TheOldMan

  • Hero Member
  • *****
  • Posts: 958
Re: MML: What are people's actual complaints with the damn thing
« Reply #101 on: December 09, 2016, 01:51:53 PM »
Quote
All channels, or any specific channel and any number of them, can be set to DDA mode. Or do you mean from the BIOS psg player?
Yeah, i went and looked it up. All 6 channels can do DDA. Would probably be easiest to hack in on channels 5-6, since there's already support in the player to switch modes (ie, noise mode)

Quote
...To hack in sample support, it seems that simply setting the PSG player tick to 1 and have the hook do the down counting and call the PSG player when that expires, for tempo control.
I can sort of see how that might work.
The psg player doesn't really have a 'tick'; each call, from vsync/timer is used to count down values. That's easier to explain (to musicians used to midi) as 'ticks'. Wouldn't you have to run the timer at a high rate (ie, low count) to do that though?

Quote
I'm not sure how much space the ripped player takes up in squirrel package,
~8k for the player. Some more in the library page for the actual driver call. (ie. mapping things in, etc)
Same as bios. And yes, iirc, building a cd project changes how the psg setup stuff/driver is done; in a non-cd project, that code is in the library pages, while building a cd project substitutes the appropriate bios calls. Unless you removed it, the player code would still be compiled in, just never used. (My bad).

Quote
Are people really ignorant of PCE audio stuffs??? Nobody reads the PCM threads I post either?
Yes.
I read them. Sometimes I even sort of understand them. Once in a while, I even catch a glimpse of how they work. Not all of us are that into the actual audio processing/hardware operations. Or have studied it in that much detail.

Quote
Unless Old Man and team get this figured out in time when you need it, hit me up when you guys want to do sample streaming support.
Go for it. I have enough other things to do. (Like getting the player to work with the new Huc. Including timer irq support)
If you get it working, pick an unused bytecode to indicate sample playback, and I'll see about putting it in the mml compiler.
..........................
I figure if you pump out the sample values on hsync (assuming 262 hsync/frame) you could handle 12KHz at 5-bit resolution. Not exactly cd quality, but probably good enough for recognisable speech/sfx.
Also, when you re-sample for pce, are you scaling down and interpolating over time, or what?
I've read  some about it, but mostly have been using sox to do it...

DarkKobold

  • Hero Member
  • *****
  • Posts: 1200
Re: MML: What are people's actual complaints with the damn thing
« Reply #102 on: December 09, 2016, 02:15:36 PM »
Just thinking out loud...

So I was looking over the TIRQ code for BIOS player. To hack in sample support, it seems that simply setting the PSG player tick to 1 and have the hook do the down counting and call the PSG player when that expires, for tempo control. Otherwise, outside the PSG player call - the main TIRQ hook outputs samples to whatever channel DAC.

 Those are just the small details. I'm not sure how much space the ripped player takes up in squirrel package, but I think it would be a better idea to keep using it instead of the built in one of the sys card (I assume it switches and uses that for CD projects - haven't looked that far ahead). That would easily solve how to introduce sample support into MML.

 The CD psg player (bios rom version) can be hacked for the hook that I described, but I'd need to know a few more details of how to optimally incorporate sample support for sound FX (aka not drum kits). Otherwise the unoptimal way would be to just reserve one channel for all sample playback. It's crude, but it should work.

Honestly, this would be ideal for our project. Right now, cabbage built us some SFX in Squirrel/MML. They sound OK, but just reserving one channel for actual sampled SFX would be great, especially if it could be built into HuC. That said, it sounds like the overhead would be incredibly high, unless it was every vsync, which comes with its own issues, as Bonknuts pointed out.

EDIT: Also, what happens if my code has some library that does "soundplay(1)" and that overlaps "soundplay(2)"? Will the library be able to handle that?
Hey, you.

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: MML: What are people's actual complaints with the damn thing
« Reply #103 on: December 09, 2016, 02:52:04 PM »
Quote
All channels, or any specific channel and any number of them, can be set to DDA mode. Or do you mean from the BIOS psg player?

Yeah, i went and looked it up. All 6 channels can do DDA. Would probably be easiest to hack in on channels 5-6, since there's already support in the player to switch modes (ie, noise mode)

Quote
...To hack in sample support, it seems that simply setting the PSG player tick to 1 and have the hook do the down counting and call the PSG player when that expires, for tempo control.

I can sort of see how that might work.
The psg player doesn't really have a 'tick'; each call, from vsync/timer is used to count down values. That's easier to explain (to musicians used to midi) as 'ticks'. Wouldn't you have to run the timer at a high rate (ie, low count) to do that though?



 Yup. At full 7khz rate. By tick, I mean the interval of time between calls of the parsing routine (and control routine; envelopes, etc). Since the PSG resolution of a tick, interval, is however many TIMER values are used in the timer divider (written to TIMER interval port), those steps that make up the internal are exactly 1 point at 7khz (6991hz to be exact). When you use the timer unit in this way,  you're really just letting hardware do the down counter division for you. But if you set the timer to 0, and do the down counter yourself - the step resolution is exactly the same. The step resolution is always 1024 cpu cycles, whether it's a hardware counter or soft counter at max frequency.

So if you wanted 108hz tempo, set the TIMER to 6991 khz, set the software down counter to 108 (instead of writing it to the TIMER counter port), and on each TIRQ call decrement it. When it reaches 00, pass control to the PSG player. Otherwise, on each call you can now write a sample to any channel you like.

 Obvious you don't want the PSG player writing other stuff to it, but if the PSG player is writing frequency control while in DDA mode - it won't affect the output of the sample. If you can get the PSG player to play a "sound effect" on that same channel, and not touch the volume after an initial set (because volume reg is the same used to set DDA mode), then you can basically get the PSG player not to intervene on that channel while the sample is being streamed to it.

 You could probably take this one step further, by spying on the PSG player's pointer to a specific channel. And if it can read the byte code for notes, then it can interpret that note as a simple #. Even pull the volume control code value from it.

 Basically Air Zonk does all of this.   


Quote


Go for it. I have enough other things to do. (Like getting the player to work with the new Huc. Including timer irq support)
If you get it working, pick an unused bytecode to indicate sample playback, and I'll see about putting it in the mml compiler.
..........................
I figure if you pump out the sample values on hsync (assuming 262 hsync/frame) you could handle 12KHz at 5-bit resolution. Not exactly cd quality, but probably good enough for recognisable speech/sfx.
Also, when you re-sample for pce, are you scaling down and interpolating over time, or what?
I've read  some about it, but mostly have been using sox to do it...


 Some PCM demos I posted do this. It's higher than 12khz though. If you output a sample on every scanline per frame (H-int can be called on every scanline), that's 262 samples per frame or 15.73khz. I kept mine at 15.3khz output because 256 samples per frame allowed for alignment optimization (saved cycles in handling/check bank boundary crossings; it doesn't have to be done per instance of the sample fetch, but rather once per frame). I did 262 interrupts, but skipped playing a sample every so many lines (used a down counter).

 The downside to this method, is that there's a good amount of overhead just to do 262 h-int calls - nothing else. It's ~20% cpu resource just for the setup of the next line. Not bad if you already need to do a scanline interrupt every active display scanline for sinewave or similar effects, but not so great if you don't.

 Here's an example of 7khz vs 14khz: http://www.pcedev.net@ftp.pcedev.net/HuPCMDriver/7khz_vs_14khz.zip
 The 14khz is just the sample code being called twice inside the TIMER routine. Simple to do, but wasteful. I just wanted to see what the different in frequency would sound like. Apparently at this rare level though, bit depth matters more than sample rate.

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: MML: What are people's actual complaints with the damn thing
« Reply #104 on: December 09, 2016, 02:57:46 PM »
Honestly, this would be ideal for our project. Right now, cabbage built us some SFX in Squirrel/MML. They sound OK, but just reserving one channel for actual sampled SFX would be great, especially if it could be built into HuC. That said, it sounds like the overhead would be incredibly high, unless it was every vsync, which comes with its own issues, as Bonknuts pointed out.
The overhead isn't that high, it's just amount of work to set this up for someone. It would be something custom for you, if you needed it. As far as cpu overhead, you're looking at like something like 6% cpu resource for a single channel stream. That's not too high.