bool decode_run( audio_chunk & p_chunk, abort_callback & p_abort ) { if (!loop && m_info.musicTimeInMs == ymMusicGetPos(m_player)) return false; int nbSample = 500 / sizeof(ymsample); sample_buffer.grow_size( nbSample ); ymMusicCompute(m_player,sample_buffer.get_ptr(), nbSample); p_chunk.set_data_fixedpoint( sample_buffer.get_ptr(), nbSample * 2, 44100, 1, 16, audio_chunk::channel_config_mono ); return true; }
static void soundServerCallback(void *pBuffer,long size) { if (s_pMusic) { int nbSample = size / sizeof(ymsample); ymMusicCompute((void*)s_pMusic,(ymsample*)pBuffer,nbSample); } }
// The plugin host calls this when it wants a new audio frame DWORD YMPlugin::FillBuffer(void* pbuffer, DWORD length) { short *src = new short[length<<1]; short *dst = new short[length]; if(ymMusicCompute(m_ymMusic,(ymsample*)src,length<<2)) { for(DWORD i = 0, j = 0; i < length<<2; i++, j+=2) { dst[j] = src[i]; dst[j + 1] = src[i]; } memcpy(pbuffer,dst,length); } delete dst; delete src; return length; }