示例#1
0
void Music_Player::mute_voices( int mask )
{
	suspend();
	gme_mute_voices( emu_, mask );
	gme_ignore_silence( emu_, mask != 0 );
	resume();
}
示例#2
0
文件: cgme.c 项目: Tydus/deadbeef
static void
cgme_mutevoice (int voice, int mute) {
    cgme_voicemask &= ~ (1<<voice);
    cgme_voicemask |= ((mute ? 1 : 0) << voice);
    if (emu) {
        gme_mute_voices (emu, cgme_voicemask);
    }
}
示例#3
0
文件: cgme.c 项目: jubalh/deadbeef
static int
cgme_read (DB_fileinfo_t *_info, char *bytes, int size) {
    gme_fileinfo_t *info = (gme_fileinfo_t*)_info;
    float t = (size/4) / (float)_info->fmt.samplerate;
    if (_info->readpos + t >= info->duration) {
        t = info->duration - _info->readpos;
        if (t <= 0) {
            return 0;
        }
        // DON'T ajust size, buffer must always be po2
        //size = t * (float)info->samplerate * 4;
    }

    if (chip_voices_changed) {
        chip_voices = deadbeef->conf_get_int ("chip.voices", 0xff);
        chip_voices_changed = 0;
        gme_mute_voices (info->emu, chip_voices^0xff);
    }

    if (gme_play (info->emu, size/2, (short*)bytes)) {
        return 0;
    }
    if (conf_fadeout > 0 && info->duration >= conf_fadeout && info->reallength <= 0 && _info->readpos >= info->duration - conf_fadeout) {
        float fade_amnt =  (info->duration - _info->readpos) / (float)conf_fadeout;
        int nsamples = size/2;
        float fade_incr = 1.f / (_info->fmt.samplerate * conf_fadeout) * 256;
        const float ln10=2.3025850929940002f;
        float fade = exp(ln10*(-(1.f-fade_amnt) * 3));

        for (int i = 0; i < nsamples; i++) {
            ((short*)bytes)[i] *= fade;
            if (!(i & 0xff)) {
                fade_amnt += fade_incr;
                fade = exp(ln10*(-(1.f-fade_amnt) * 3));
            }
        }
    }

    _info->readpos += t;
    if (info->reallength == -1) {
        if (gme_track_ended (info->emu)) {
            return 0;
        }
    }
    return size;
}
示例#4
0
static int
cgme_read (DB_fileinfo_t *_info, char *bytes, int size) {
    gme_fileinfo_t *info = (gme_fileinfo_t*)_info;
    int playForever = conf_play_forever && info->can_loop;
    float t = (size/4) / (float)_info->fmt.samplerate;
    if (info->eof) {
        return 0;
    }
    if (!playForever && _info->readpos + t >= info->duration) {
        t = info->duration - _info->readpos;
        if (t <= 0) {
            return 0;
        }
        // DON'T ajust size, buffer must always be po2
        //size = t * (float)info->samplerate * 4;
    }

    if (chip_voices_changed) {
        chip_voices = deadbeef->conf_get_int ("chip.voices", 0xff);
        chip_voices_changed = 0;
        gme_mute_voices (info->emu, chip_voices^0xff);
    }

    if (playForever)
        gme_set_fade(info->emu, -1, 0);
    else
        gme_set_fade(info->emu, (int)(info->duration * 1000), conf_fadeout * 1000);

    if (gme_play (info->emu, size/2, (short*)bytes)) {
        return 0;
    }

    _info->readpos += t;
    if (gme_track_ended (info->emu)) {
        info->eof = 1;
    }
    return size;
}
示例#5
0
文件: cgme.c 项目: jubalh/deadbeef
static int
cgme_init (DB_fileinfo_t *_info, DB_playItem_t *it) {
    gme_fileinfo_t *info = (gme_fileinfo_t*)_info;
    int samplerate = deadbeef->conf_get_int ("synth.samplerate", 44100);

    gme_err_t res = "gme uninitialized";
    deadbeef->pl_lock ();
    {
        const char *fname = deadbeef->pl_find_meta (it, ":URI");
        const char *ext = strrchr (fname, '.');
        char *buffer;
        int sz;
        if (!read_gzfile (fname, &buffer, &sz)) {
            res = gme_open_data (fname, buffer, sz, &info->emu, samplerate);
            free (buffer);
        }
        if (res) {
            DB_FILE *f = deadbeef->fopen (fname);
            if (!f) {
                deadbeef->pl_unlock ();
                return -1;
            }
            int64_t sz = deadbeef->fgetlength (f);
            if (sz <= 0) {
                deadbeef->fclose (f);
                deadbeef->pl_unlock ();
                return -1;
            }
            char *buf = malloc (sz);
            if (!buf) {
                deadbeef->fclose (f);
                deadbeef->pl_unlock ();
                return -1;
            }
            int64_t rb = deadbeef->fread (buf, 1, sz, f);
            deadbeef->fclose(f);
            if (rb != sz) {
                free (buf);
                deadbeef->pl_unlock ();
                return -1;
            }

            res = gme_open_data (fname, buf, sz, &info->emu, samplerate);
            free (buf);
        }
    }
    deadbeef->pl_unlock ();

    if (res) {
        trace ("failed with error %d\n", res);
        return -1;
    }
    chip_voices = deadbeef->conf_get_int ("chip.voices", 0xff);
    gme_mute_voices (info->emu, chip_voices^0xff);
    gme_start_track (info->emu, deadbeef->pl_find_meta_int (it, ":TRACKNUM", 0));

    gme_info_t *inf;
    gme_track_info (info->emu, &inf, deadbeef->pl_find_meta_int (it, ":TRACKNUM", 0));

    _info->plugin = &plugin;
    _info->fmt.bps = 16;
    _info->fmt.channels = 2;
    _info->fmt.samplerate = samplerate;
    _info->fmt.channelmask = _info->fmt.channels == 1 ? DDB_SPEAKER_FRONT_LEFT : (DDB_SPEAKER_FRONT_LEFT | DDB_SPEAKER_FRONT_RIGHT);
    info->duration = deadbeef->pl_get_item_duration (it);
    info->reallength = inf->length;
    _info->readpos = 0;
    return 0;
}
示例#6
0
文件: glue.cpp 项目: Chaduke/bah.mod
void bmx_gme_mute_voices(MaxMusicEmu * emu, int mutingMask) {
	gme_mute_voices(emu->emu, mutingMask);
}