Пример #1
0
    void __declspec(dllexport) DLL_StartPlayback(int sid, int track)
    {
      WaitForSingleObject(hMutex,INFINITE);
      SSid* result = (SSid*)sid;

      result->tune.selectSong(track);
      result->player.load(&result->tune);
      result->config.clockDefault = SID2_CLOCK_PAL;
      result->config.clockForced = false;
      result->config.clockSpeed = SID2_CLOCK_CORRECT;
      result->config.emulateStereo = true;
      result->config.environment = sid2_envR;
      result->config.forceDualSids = false;
      result->config.frequency = 48000;
      result->config.leftVolume = 255;
      result->config.optimisation = SID2_DEFAULT_OPTIMISATION;
      result->config.playback = sid2_stereo;
      result->config.powerOnDelay = SID2_DEFAULT_POWER_ON_DELAY;
      result->config.precision = 16;
      result->config.rightVolume = 255;
      result->config.sampleFormat = SID2_LITTLE_SIGNED;
      if (!result->config.sidEmulation)
      {
        ReSIDBuilder* rs = new ReSIDBuilder("Resid Builder");
        rs->create (result->player.info().maxsids);
        rs->filter(false);
        rs->sampling(48000);
        result->config.sidEmulation = rs;
      }

      result->player.config(result->config);
      result->player.fastForward(100*32);
      ReleaseMutex(hMutex);
    }
Пример #2
0
static int Open (vlc_object_t *obj)
{
    demux_t *demux = (demux_t *)obj;
    demux_sys_t *sys = NULL;
    es_format_t fmt;
    bool result = false;
    SidTune *tune = NULL;
    sidplay2 *player = NULL;
    ReSIDBuilder *builder = NULL;

    int64_t size = stream_Size (demux->s);
    if (size < 4 || size > LONG_MAX) /* We need to load the whole file for sidplay */
        return VLC_EGENERIC;

    const uint8_t *peek;
    if (vlc_stream_Peek (demux->s, &peek, 4) < 4)
        return VLC_EGENERIC;

    /* sidplay2 can read PSID and the newer RSID formats */
    if(memcmp(peek,"PSID",4)!=0 && memcmp(peek,"RSID",4)!=0)
        return VLC_EGENERIC;

    uint8_t *data = (uint8_t*) malloc(size);
    if (unlikely (data==NULL))
        goto error;

    if (vlc_stream_Read (demux->s,data,size) < size) {
        free (data);
        goto error;
    }

    tune = new (std::nothrow) SidTune(0);
    if (unlikely (tune==NULL)) {
        free (data);
        goto error;
    }

    result = tune->read (data, size);
    free (data);
    if (!result)
        goto error;

    player = new (std::nothrow) sidplay2();
    if (unlikely(player==NULL))
        goto error;

    sys = (demux_sys_t*) calloc (1, sizeof(demux_sys_t));
    if (unlikely(sys==NULL))
        goto error;

    sys->player = player;
    sys->tune = tune;

    tune->getInfo (sys->tuneInfo);

    sys->info = player->info();
    sys->config = player->config();

    builder = new (std::nothrow) ReSIDBuilder ("ReSID");
    if (unlikely(builder==NULL))
        goto error;

    builder->create (sys->info.maxsids);
    builder->sampling (sys->config.frequency);

    sys->config.sidEmulation = builder;
    sys->config.precision    = 16;
    sys->config.playback     = (sys->info.channels == 2 ? sid2_stereo : sid2_mono);

    player->config (sys->config);

    sys->bytes_per_frame = sys->info.channels * sys->config.precision / 8;
    sys->block_size = sys->config.frequency / 10 * sys->bytes_per_frame;

    es_format_Init (&fmt, AUDIO_ES, VLC_CODEC_S16N);

    fmt.audio.i_channels        = sys->info.channels;
    fmt.audio.i_bitspersample   = sys->config.precision;
    fmt.audio.i_rate            = sys->config.frequency;
    fmt.audio.i_bytes_per_frame = sys->bytes_per_frame;
    fmt.audio.i_frame_length    = fmt.audio.i_bytes_per_frame;
    fmt.audio.i_blockalign      = fmt.audio.i_bytes_per_frame;

    fmt.i_bitrate = fmt.audio.i_rate * fmt.audio.i_bytes_per_frame;

    sys->es = es_out_Add (demux->out, &fmt);

    date_Init (&sys->pts, fmt.audio.i_rate, 1);
    date_Set (&sys->pts, 0);

    sys->tune->selectSong (0);
    result = (sys->player->load (sys->tune) >=0 );
    sys->player->fastForward (100);
    if (!result)
        goto error;

    /* Callbacks */
    demux->pf_demux = Demux;
    demux->pf_control = Control;
    demux->p_sys = sys;

    return VLC_SUCCESS;

error:
    msg_Err (demux, "An error occurred during sid demuxing" );
    delete player;
    delete builder;
    delete tune;
    free (sys);
    return VLC_EGENERIC;
}
Пример #3
0
// Create the sid emulation
bool ConsolePlayer::createSidEmu (SIDEMUS emu)
{
    // Remove old driver and emulation
    if (m_engCfg.sidEmulation)
    {
        sidbuilder *builder   = m_engCfg.sidEmulation;
        m_engCfg.sidEmulation = NULL;
        m_engine.config (m_engCfg);
        delete builder;
    }

    // Now setup the sid emulation
    switch (emu)
    {
#ifdef HAVE_SIDPLAYFP_BUILDERS_RESIDFP_H
    case EMU_RESIDFP:
    {
#ifdef HAVE_EXCEPTIONS
        ReSIDfpBuilder *rs = new(std::nothrow) ReSIDfpBuilder( RESIDFP_ID );
#else
        ReSIDfpBuilder *rs = new ReSIDfpBuilder( RESIDFP_ID );
#endif
        if (rs)
        {
            m_engCfg.sidEmulation = rs;
            if (!rs->getStatus()) goto createSidEmu_error;
            rs->create ((m_engine.info ()).maxsids());
            if (!rs->getStatus()) goto createSidEmu_error;

            if (m_filter.filterCurve6581)
                rs->filter6581Curve(m_filter.filterCurve6581);
            if (m_filter.filterCurve8580)
                rs->filter8580Curve((double)m_filter.filterCurve8580);
        }
        break;
    }
#endif // HAVE_SIDPLAYFP_BUILDERS_RESIDFP_H

#ifdef HAVE_SIDPLAYFP_BUILDERS_RESID_H
    case EMU_RESID:
    {
#ifdef HAVE_EXCEPTIONS
        ReSIDBuilder *rs = new(std::nothrow) ReSIDBuilder( RESID_ID );
#else
        ReSIDBuilder *rs = new ReSIDfpBuilder( RESID_ID );
#endif
        if (rs)
        {
            m_engCfg.sidEmulation = rs;
            if (!rs->getStatus()) goto createSidEmu_error;
            rs->create ((m_engine.info ()).maxsids());
            if (!rs->getStatus()) goto createSidEmu_error;

            rs->bias(m_filter.bias);
        }
        break;
    }
#endif // HAVE_SIDPLAYFP_BUILDERS_RESID_H

#ifdef HAVE_SIDPLAYFP_BUILDERS_HARDSID_H
    case EMU_HARDSID:
    {
#ifdef HAVE_EXCEPTIONS
        HardSIDBuilder *hs = new(std::nothrow) HardSIDBuilder( HARDSID_ID );
#else
        HardSIDBuilder *hs = new HardSIDBuilder( HARDSID_ID );
#endif
        if (hs)
        {
            m_engCfg.sidEmulation = hs;
            if (!hs->getStatus()) goto createSidEmu_error;
            hs->create ((m_engine.info ()).maxsids());
            if (!hs->getStatus()) goto createSidEmu_error;
        }
        break;
    }
#endif // HAVE_SIDPLAYFP_BUILDERS_HARDSID_H

    default:
        // Emulation Not yet handled
        // This default case results in the default
        // emulation
        break;
    }

    if (!m_engCfg.sidEmulation)
    {
        if (emu > EMU_DEFAULT)
        {   // No sid emulation?
            displayError (ERR_NOT_ENOUGH_MEMORY);
            return false;
        }
    }

    if (m_engCfg.sidEmulation) {
        /* set up SID filter. HardSID just ignores call with def. */
        m_engCfg.sidEmulation->filter(m_filter.enabled);
    }

    return true;

createSidEmu_error:
    displayError (m_engCfg.sidEmulation->error ());
    delete m_engCfg.sidEmulation;
    m_engCfg.sidEmulation = NULL;
    return false;
}
Пример #4
0
  void *sidcxx_load(const void *data, int length, int subsong, char *errbuf, 
		    size_t errlen)
  {
    struct sidwrap *sw = new sidwrap();

    memset(&sw->conf, 0, sizeof(sid2_config_t));

    if(!sw->st.read((const uint_least8_t *)data, length)) {
      delete sw;
      snprintf(errbuf, errlen, "Unable to read data");
      return NULL;
    }

    sw->p.debug(true, stderr);

    sw->st.selectSong(subsong);
    if(sw->p.load(&sw->st)) {
      snprintf(errbuf, errlen, "Unable to load");
      return NULL;
    }



    ReSIDBuilder *rs = new ReSIDBuilder("ReSID");
    if(!rs || !*rs) {
      snprintf(errbuf, errlen, "Unable to create SID emulator");
      return NULL;
    }
    rs->create(sw->p.info().maxsids);
    if(!*rs) {
      snprintf(errbuf, errlen, "Unable to config SID emulator");
      return NULL;
    }
    rs->filter(false);
    if(!*rs) {
      snprintf(errbuf, errlen, "Unable to config SID emulator (filter)");
      return NULL;
    }
    rs->sampling(44100);
    if(!*rs) {
      snprintf(errbuf, errlen, "Unable to config SID emulator (samplerate)");
      return NULL;
    }

    sw->conf = sw->p.config();
    sw->conf.frequency    = 44100;
    sw->conf.precision    = 16;
    sw->conf.playback     = sid2_stereo;
    sw->conf.sampleFormat = SID2_LITTLE_SIGNED;

    /* These should be configurable ... */
    sw->conf.clockSpeed    = SID2_CLOCK_CORRECT;
    sw->conf.clockForced   = true;
    sw->conf.sidModel      = SID2_MODEL_CORRECT;
    sw->conf.optimisation  = SID2_DEFAULT_OPTIMISATION;
    sw->conf.sidSamples    = true;
    sw->conf.clockDefault  = SID2_CLOCK_PAL;
    sw->conf.sidDefault    = SID2_MOS6581;

    sw->conf.sidEmulation = rs;

    int r = sw->p.config(sw->conf);
    if(r) {
      snprintf(errbuf, errlen, "Unable to config SID player");
      return NULL;
    }
    return sw;
  }