int __declspec(dllexport) DLL_FillBuffer(int gym, char* szBuffer) { WaitForSingleObject(hMutex,INFINITE); GYMSong* song = (GYMSong*)gym; Seg_L = song->Seg_L; Seg_R = song->Seg_R; YM2612 = song->YM2612; PSG = song->PSG; song->gymPos = Play_GYM(szBuffer,song->gymStart,song->gymPos,song->gymSize,0); song->YM2612 = YM2612; song->PSG = PSG; ReleaseMutex(hMutex); if (!song->gymPos) return 0; return 1; }
int input_gym::get_samples_pcm(void ** buffer,int * size,int * srate,int * bps,int * nch) { *srate = playingSampleRate; *bps = 16; *nch = 2; // oslDebug("%x %x %x %x %x", sample_buffer.get_ptr(), gym_start, gym_pos, gym_size, gym_loop); unsigned char *new_gym_pos = Play_GYM(sample_buffer.get_ptr(), gym_start, gym_pos, gym_size, gym_loop); // oslDebug("%x %x %x %x %x", sample_buffer.get_ptr(), gym_start, gym_pos, gym_size, gym_loop); if (new_gym_pos == 0 || (gym_length_with_fade > 0 && gym_pos_ms > gym_length_with_fade)) { return 0; } gym_pos_ms += fnum(1000.0) / fnum(60.0); gym_pos = new_gym_pos; if (gym_loop && gym_length > 0 && gym_pos_ms > gym_length) { // this isn't as precise as it could be as it's not taking position // within this update into account but it's unlikely one will notice the // ramp down in volume in 60th-second-long steps short *foo = (short*)sample_buffer.get_ptr(); int fade_pos = (int)(gym_length_with_fade - gym_pos_ms);; for (int n = 0; n < Seg_Lenght << 2; n++) { *foo = *foo; foo++; // *foo++ = MulDiv(*foo, fade_pos, cfg_fade_length * 1000); } } *buffer = sample_buffer.get_ptr(); *size = Seg_Lenght << 2; return 1; }