Пример #1
0
void audio_init(int rate)
{
    /* Clear sound context */
    memset(&snd, 0, sizeof(t_snd));

    /* Reset logging data */
    snd.log = 0;
    snd.callback = NULL;

    /* Oops.. sound is disabled */
    if(!rate) return;

    /* Calculate buffer size in samples */
    snd.bufsize = 2048;

    /* Sound output */
#ifdef _3DS

    snd.buffer[0] = (signed short int *)linearAlloc(snd.bufsize * 2);
    snd.buffer[1] = (signed short int *)linearAlloc(snd.bufsize * 2);
#else
    snd.buffer[0] = (signed short int *)malloc(snd.bufsize * 2);
    snd.buffer[1] = (signed short int *)malloc(snd.bufsize * 2);
#endif
    if(!snd.buffer[0] || !snd.buffer[1]) return;
    memset(snd.buffer[0], 0, snd.bufsize * 2);
    memset(snd.buffer[1], 0, snd.bufsize * 2);

    /* YM2413 sound stream */
    snd.fm_buffer = (signed short int *)malloc(snd.bufsize * 2);
    if(!snd.fm_buffer) return;
    memset(snd.fm_buffer, 0, snd.bufsize * 2);

    /* SN76489 sound stream */
    snd.psg_buffer[0] = (signed short int *)malloc(snd.bufsize * 2);
    snd.psg_buffer[1] = (signed short int *)malloc(snd.bufsize * 2);
    if(!snd.psg_buffer[0] || !snd.psg_buffer[1]) return;
    memset(snd.psg_buffer[0], 0, snd.bufsize * 2);
    memset(snd.psg_buffer[1], 0, snd.bufsize * 2);

    /* Set up SN76489 emulation */
    SN76496_init(0, MASTER_CLOCK, 255, rate);

    /* Set up YM2413 emulation */
    OPLL_init(3579545, rate) ;
    opll = OPLL_new() ;
    OPLL_reset(opll) ;
    OPLL_reset_patch(opll,0) ;            /* if use default voice data. */

    /* Inform other functions that we can use sound */
    snd.enabled = 1;
}
Пример #2
0
void FM_Init(void)
{
    switch(snd.fm_which)
    {
        case SND_EMU2413:
            OPLL_init(snd.fm_clock, snd.sample_rate);
            opll = OPLL_new();
            OPLL_reset(opll);
            OPLL_reset_patch(opll, 0);
            break;

        case SND_YM2413:
            YM2413Init(1, snd.fm_clock, snd.sample_rate);
            YM2413ResetChip(0);
            break;
    }
}