Process.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #include "main.h"
  2. #include "Process.h"
  3. int ProcessReplayGain::Open(int _mode)
  4. {
  5. mode=_mode;
  6. if (mode != RG_INDIVIDUAL_TRACKS
  7. && mode != RG_ALBUM)
  8. return RG_MODE_NOT_SUPPORTED;
  9. context=CreateRG();
  10. if (!context)
  11. return RG_FAILURE;
  12. StartRG(context);
  13. return RG_SUCCESS;
  14. }
  15. int ProcessReplayGain::ProcessTrack(const wchar_t *filename)
  16. {
  17. int killSwitch=0;
  18. RGWorkFile workFile(filename);
  19. CalculateRG(context, workFile.filename, workFile.track_gain, workFile.track_peak, 0, &killSwitch, albumPeak);
  20. queue.push_back(workFile);
  21. return RG_SUCCESS;
  22. }
  23. int ProcessReplayGain::Write()
  24. {
  25. if (mode == RG_ALBUM)
  26. {
  27. wchar_t album_gain[64]=L"", album_peak[64]=L"";
  28. CalculateAlbumRG(context, album_gain, album_peak, albumPeak);
  29. CopyAlbumData(queue, album_gain, album_peak);
  30. }
  31. WriteAlbum(queue);
  32. return RG_SUCCESS;
  33. }
  34. void ProcessReplayGain::Close()
  35. {
  36. DestroyRG(context);
  37. }
  38. #define CBCLASS ProcessReplayGain
  39. START_DISPATCH;
  40. CB(OBJ_REPLAYGAIN_OPEN, Open)
  41. CB(OBJ_REPLAYGAIN_PROCESSTRACK, ProcessTrack)
  42. CB(OBJ_REPLAYGAIN_WRITE, Write)
  43. VCB(OBJ_REPLAYGAIN_CLOSE,Close)
  44. END_DISPATCH;