Page 30 of 57
Posted: Fri Aug 03, 2012 9:38 pm
by bioloid
Another one : is there a way to retrieve some kind of timeframe from the sound buffer, when using SND_startPlayXXX functions ? (audio - video sync)
Ok, answer: no, annoying...
Posted: Sat Aug 04, 2012 12:15 am
by Chilly Willy
It would depend on which driver you're referring to. For example, the PCM driver has an internal wave address you could read using the 68000. As long as you know what the start address is (and you should), you could figure out how much has been played. I suggest reading the source for the drivers.
Posted: Sat Aug 04, 2012 3:32 pm
by bioloid
Ok, got it, thanks.
returns PCM time in millisecond :
Code: Select all
u32 SND_getTime_PCM()
{
static const u32 rts[6] = { 32000, 22050, 16000, 13400, 11025, 8000 };
Z80_loadDriver(Z80_DRIVER_PCM, 1);
Z80_requestBus(1);
vu8 *pb = (u8*)(Z80_DRV_PARAMS+0x10);
u32 cr = (u32)pb[0]<<8|(u32)pb[1]<<16;
pb = (u8*)Z80_DRV_PARAMS;
cr -= (u32)pb[0]<<8|(u32)pb[1]<<16;
cr *= 1000;
cr /= rts[pb[4]];
Z80_releaseBus();
return cr;
}
Posted: Sat Aug 04, 2012 5:07 pm
by bioloid
Is there a way to retrieve output amplitude as well ? (need to sync a sinus effect)
Posted: Sat Aug 04, 2012 7:05 pm
by Chilly Willy
I forget if the DAC register can be read, but if it can, that would give you the current amplitude playing.
Posted: Sat Aug 04, 2012 7:21 pm
by TmEE co.(TM)
No register in the YM is readable, all reads will return status register. Registers can only be read back on some variations of OPL3.
Posted: Sun Aug 05, 2012 12:05 am
by Chilly Willy
TmEE co.(TM) wrote:No register in the YM is readable, all reads will return status register. Registers can only be read back on some variations of OPL3.
Ah, thanks! I knew there was a reason it wouldn't be so simple.

Posted: Sun Aug 05, 2012 12:20 pm
by bioloid
ok thanks, *cry*
Posted: Sun Aug 05, 2012 3:16 pm
by Stef
bioloid wrote:Is there a way to retrieve output amplitude as well ? (need to sync a sinus effect)
Again if you look at the driver source you can try to retrieve sample data from the internal sound mix buffer. If you do that you have to take care about doing short Z80 interruption as it affect playback quality.
Posted: Sun Aug 05, 2012 4:02 pm
by bioloid
Thanks again. I will try to just read data in the music buffer, it may do the trick for that.
Posted: Sun Aug 05, 2012 6:56 pm
by bioloid
"More importantly": are you sure Mem_Free is working ? I guess so, but when I do reset on the real console, something goes wrong : looks plainly like a Mem_Alloc is failing. As you know I'm not a "mega vaudou", I really dont know what reset does. Its not a big problem to have this behavior, but if it can't be solved I need, at least, a way to know if the console has been reset...
[it doesnt crash but missed stuff...]
Posted: Mon Aug 06, 2012 8:58 am
by Stef
bioloid wrote:"More importantly": are you sure Mem_Free is working ? I guess so, but when I do reset on the real console, something goes wrong : looks plainly like a Mem_Alloc is failing. As you know I'm not a "mega vaudou", I really dont know what reset does. Its not a big problem to have this behavior, but if it can't be solved I need, at least, a way to know if the console has been reset...
[it doesnt crash but missed stuff...]
Mem_Free should work but maybe there is something incorrect with the reset handler... i just had a look in sources and cannot find something wrong but some tests may clarify that.
Posted: Tue Aug 07, 2012 7:42 pm
by bioloid
Ok got the demo looping, indeed Mem_Free works, I kind of notice slowdown after some loops but I guess it comes from something in my code. I'll retry the reset thing, and maybe share you the whole stuff if you wanna take a look (or even use stuff after the release). Glad to be helped! (and help if I may).
Ok, I've some strange things happening sometimes... I'll live with it (and even try to use it as features, and I'll give the whole thing after the release). Thanks.
Posted: Tue Aug 07, 2012 8:20 pm
by Stef
The memory allocation can take a bit of time, specially when free memory is fragmented and i repack it.. but still, that should not take that much time.
Posted: Tue Aug 07, 2012 8:42 pm
by bioloid
Ok, as I just got, the compiler is doing weird stuff sometimes. No problem with the sgdk! thanks.