I currently use both Delphi XE6 and Delphi Seattle:
I am busy putting together a little app on Firemonkey that needs to play sound files (mp3, wav etc.). Adjusting the master volume is straight forward, but it seems that adjusting the left-to-right balance of a sound file playing is not.
This is the code that I have for achieving this feat, except, it will not be supported in FMX, as it calls mostly Windows API functions. Can anyone help with the API functions to call on the FMX platform instead? At this point I am hoping to support at least Android devices. If there is additional/alternative code (or compiler directive settings with alternative code) to cover for iOS devices as well, that would be greatly appreciated.
Thank you very much in advance!
Here is what I have so far...
function GetWaveVolume(var LVol: DWORD; var RVol: DWORD): Boolean;
var
WaveOutCaps: TWAVEOUTCAPS;
Volume: DWORD;
begin
Result := False;
if WaveOutGetDevCaps(WAVE_MAPPER, @WaveOutCaps, SizeOf(WaveOutCaps)) = MMSYSERR_NOERROR then
if WaveOutCaps.dwSupport and WAVECAPS_VOLUME = WAVECAPS_VOLUME then
begin
Result := WaveOutGetVolume(WAVE_MAPPER, @Volume) = MMSYSERR_NOERROR;
LVol := LoWord(Volume);
RVol := HiWord(Volume);
end;
end;
function SetWaveVolume(const AVolume: DWORD): Boolean;
var
WaveOutCaps: TWAVEOUTCAPS;
begin
Result := False;
if WaveOutGetDevCaps(WAVE_MAPPER, @WaveOutCaps, SizeOf(WaveOutCaps)) = MMSYSERR_NOERROR then
if WaveOutCaps.dwSupport and WAVECAPS_VOLUME = WAVECAPS_VOLUME then
Result := WaveOutSetVolume(WAVE_MAPPER, AVolume) = MMSYSERR_NOERROR;
end;