Sega Genesis Dev Kit (SGDK)

SGDK only sub forum

Moderator: Stef

bioloid
Very interested
Posts: 184
Joined: Fri May 18, 2012 8:22 pm

Post 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...
Chilly Willy
Very interested
Posts: 2994
Joined: Fri Aug 17, 2007 9:33 pm

Post 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.
bioloid
Very interested
Posts: 184
Joined: Fri May 18, 2012 8:22 pm

Post 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;
}
Last edited by bioloid on Sat Aug 04, 2012 5:21 pm, edited 2 times in total.
bioloid
Very interested
Posts: 184
Joined: Fri May 18, 2012 8:22 pm

Post by bioloid »

Is there a way to retrieve output amplitude as well ? (need to sync a sinus effect)
Chilly Willy
Very interested
Posts: 2994
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy »

I forget if the DAC register can be read, but if it can, that would give you the current amplitude playing.
TmEE co.(TM)
Very interested
Posts: 2452
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post 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.
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
Chilly Willy
Very interested
Posts: 2994
Joined: Fri Aug 17, 2007 9:33 pm

Post 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. :lol:
bioloid
Very interested
Posts: 184
Joined: Fri May 18, 2012 8:22 pm

Post by bioloid »

ok thanks, *cry*
Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post 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.
bioloid
Very interested
Posts: 184
Joined: Fri May 18, 2012 8:22 pm

Post by bioloid »

Thanks again. I will try to just read data in the music buffer, it may do the trick for that.
bioloid
Very interested
Posts: 184
Joined: Fri May 18, 2012 8:22 pm

Post 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...]
Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post 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.
bioloid
Very interested
Posts: 184
Joined: Fri May 18, 2012 8:22 pm

Post 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.
Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post 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.
bioloid
Very interested
Posts: 184
Joined: Fri May 18, 2012 8:22 pm

Post by bioloid »

Ok, as I just got, the compiler is doing weird stuff sometimes. No problem with the sgdk! thanks.
Post Reply