Advertisement
Guest User

Untitled

a guest
Feb 1st, 2017
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. nBurnFPS is the frames per second, for 60hz it would be 6000, for 58.97 it would be 5897
  2. find all occurences of chip->sample_rate = in the register writes, and change to:
  3. chip->sample_rate = chip->master_clock / (16 * (chip->active_voices + 1));
  4.  
  5. #define BURN_SND_CLIP(A) ((A) < -0x8000 ? -0x8000 : (A) > 0x7fff ? 0x7fff : (A))
  6.  
  7. void ES5506Update(INT16 *pBuffer, INT32 samples)
  8. {
  9. INT32 *lsrc = chip->scratch, *rsrc = chip->scratch;
  10.  
  11. #if MAKE_WAVS
  12. /* start the logging once we have a sample rate */
  13. if (chip->sample_rate)
  14. {
  15. if (!chip->wavraw)
  16. chip->wavraw = wav_open("raw.wav", chip->sample_rate, 2);
  17. }
  18. #endif
  19.  
  20. INT32 rate = (chip->sample_rate * 100) / nBurnFPS;
  21. samples = rate;
  22.  
  23. /* loop until all samples are output */
  24. while (samples)
  25. {
  26. INT32 length = (samples > MAX_SAMPLE_CHUNK) ? MAX_SAMPLE_CHUNK : samples;
  27. INT32 samp;
  28.  
  29. /* determine left/right source data */
  30. lsrc = chip->scratch;
  31. rsrc = chip->scratch + length;
  32. generate_samples(lsrc, rsrc, length);
  33.  
  34. /* copy the data */
  35. INT32 len = (length * samples) / rate;
  36.  
  37. for (samp = 0; samp < len; samp++)
  38. {
  39. INT32 k = (samp * rate) / samples;
  40.  
  41. pBuffer[0] = BURN_SND_CLIP((INT32)((lsrc[k] >> 4) * chip->volume[0]));
  42. pBuffer[1] = BURN_SND_CLIP((INT32)((rsrc[k] >> 4) * chip->volume[1]));
  43. pBuffer += 2;
  44. }
  45.  
  46. #if MAKE_WAVS
  47. /* log the raw data */
  48. if (chip->wavraw)
  49. wav_add_data_32lr(chip->wavraw, lsrc, rsrc, length, 4);
  50. #endif
  51.  
  52. /* account for these samples */
  53. samples -= length;
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement