1 (* Copyright (C) Doom 2D: Forever Developers
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, version 3 of the License ONLY.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 {$IFDEF USE_MEMPOOL}mempool,{$ENDIF}
28 envvars, e_log, SysUtils;
40 TBasicSound = class{$IFDEF USE_MEMPOOL}(TPoolObject){$ENDIF}
42 FChanNum: Integer; // <0: no channel allocated
50 function RawPlay(Pan: Single; Volume: Single; aPos: DWORD): Boolean;
51 function GetChan (): Integer;
53 property Channel: Integer read GetChan;
57 destructor Destroy(); override;
58 procedure SetID(ID: DWORD);
59 procedure FreeSound();
60 function IsPlaying(): Boolean;
62 function IsPaused(): Boolean;
63 procedure Pause(Enable: Boolean);
64 function GetVolume(): Single;
65 procedure SetVolume(Volume: Single);
66 function GetPan(): Single;
67 procedure SetPan(Pan: Single);
68 function IsMuted(): Boolean;
69 procedure Mute(Enable: Boolean);
70 function GetPosition(): DWORD;
71 procedure SetPosition(aPos: DWORD);
72 procedure SetPriority(priority: Integer);
76 NO_SOUND_ID = DWORD(-1);
78 function e_InitSoundSystem(NoOutput: Boolean = False): Boolean;
80 function e_LoadSound(FileName: string; var ID: DWORD; isMusic: Boolean; ForceNoLoop: Boolean = False): Boolean;
81 function e_LoadSoundMem(pData: Pointer; Length: Integer; var ID: DWORD; isMusic: Boolean; ForceNoLoop: Boolean = False): Boolean;
83 // returns channel number or -1
84 function e_PlaySound(ID: DWORD): Integer;
85 function e_PlaySoundPan(ID: DWORD; Pan: Single): Integer;
86 function e_PlaySoundVolume(ID: DWORD; Volume: Single): Integer;
87 function e_PlaySoundPanVolume(ID: DWORD; Pan, Volume: Single): Integer;
89 procedure e_ModifyChannelsVolumes(SoundMod: Single; setMode: Boolean);
90 procedure e_MuteChannels(Enable: Boolean);
91 procedure e_StopChannels();
93 procedure e_DeleteSound(ID: DWORD);
94 procedure e_RemoveAllSounds();
95 procedure e_ReleaseSoundSystem();
96 procedure e_SoundUpdate();
99 e_SoundsArray: array of TSoundRec = nil;
101 e_TimidityDecoder: Boolean; (* sdl_mixer special *)
110 N_MUSCHAN = N_CHANNELS+42;
114 id: DWORD; // sound id
116 oldvol: Integer; // for muted
121 SoundMuted: Boolean = False;
122 SoundInitialized: Boolean = False;
123 ChanSIds: array[0..N_CHANNELS] of TChanInfo;
124 MusVolume: Integer = MIX_MAX_VOLUME;
127 procedure chanFinished (chan: Integer); cdecl;
129 //e_WriteLog(Format('chanFinished: %d', [chan]), TMsgType.Notify);
130 if (chan >= 0) and (chan < N_CHANNELS) then
132 if ChanSIds[chan].id <> NO_SOUND_ID then
134 if (ChanSIds[chan].id <= High(e_SoundsArray)) and (e_SoundsArray[ChanSIds[chan].id].nRefs > 0) then
136 Dec(e_SoundsArray[ChanSIds[chan].id].nRefs);
138 ChanSIds[chan].id := NO_SOUND_ID;
144 procedure dumpMusicType (ms: PMix_Music);
148 e_WriteLog('MUSIC FORMAT: NONE', TMsgType.Notify);
152 case Mix_GetMusicType(ms^) of
153 TMix_MusicType.MUS_NONE:
154 e_WriteLog('MUSIC FORMAT: NONE', TMsgType.Notify);
155 TMix_MusicType.MUS_CMD:
156 e_WriteLog('MUSIC FORMAT: CMD', TMsgType.Notify);
157 TMix_MusicType.MUS_WAV:
158 e_WriteLog('MUSIC FORMAT: WAV', TMsgType.Notify);
159 TMix_MusicType.MUS_MOD:
160 e_WriteLog('MUSIC FORMAT: MOD', TMsgType.Notify);
161 TMix_MusicType.MUS_MID:
162 e_WriteLog('MUSIC FORMAT: MID', TMsgType.Notify);
163 TMix_MusicType.MUS_OGG:
164 e_WriteLog('MUSIC FORMAT: OGG', TMsgType.Notify);
165 TMix_MusicType.MUS_MP3:
166 e_WriteLog('MUSIC FORMAT: MP3', TMsgType.Notify);
167 TMix_MusicType.MUS_MP3_MAD:
168 e_WriteLog('MUSIC FORMAT: MP3_MAD', TMsgType.Notify);
169 TMix_MusicType.MUS_FLAC:
170 e_WriteLog('MUSIC FORMAT: FLAC', TMsgType.Notify);
171 TMix_MusicType.MUS_MODPLUG:
172 e_WriteLog('MUSIC FORMAT: MODPLUG', TMsgType.Notify);
174 e_WriteLog('MUSIC FORMAT: UNKNOWN', TMsgType.Notify);
179 function e_InitSoundSystem(NoOutput: Boolean = False): Boolean;
187 if SoundInitialized then begin Result := true; Exit end;
190 SoundInitialized := False;
193 // HACK: shit this into env and hope for the best
194 SetEnvVar('SDL_AUDIODRIVER', 'dummy');
197 if NoOutput then begin Result := true; Exit end;
199 // wow, this is actually MIDI player!
200 // we need module player
201 flags := MIX_INIT_FLAC or MIX_INIT_MOD or MIX_INIT_MP3 or MIX_INIT_OGG or MIX_INIT_FLUIDSYNTH;
203 flags := flags or MIX_INIT_MODPLUG;
205 res := Mix_Init(flags);
206 e_WriteLog(Format('SDL: res=0x%x', [res]), TMsgType.Notify);
207 if (res and MIX_INIT_FLAC) <> 0 then e_WriteLog('SDL: FLAC playback is active', TMsgType.Notify);
208 if (res and MIX_INIT_MOD) <> 0 then e_WriteLog('SDL: MOD playback is active', TMsgType.Notify);
210 if (res and MIX_INIT_MODPLUG) <> 0 then e_WriteLog('SDL: MODPLUG playback is active', TMsgType.Notify);
212 if (res and MIX_INIT_MP3) <> 0 then e_WriteLog('SDL: MP3 playback is active', TMsgType.Notify);
213 if (res and MIX_INIT_OGG) <> 0 then e_WriteLog('SDL: OGG playback is active', TMsgType.Notify);
214 if (res and MIX_INIT_FLUIDSYNTH) <> 0 then e_WriteLog('SDL: FLUIDSYNTH playback is active', TMsgType.Notify);
216 e_WriteLog(Format('SDL: initializing mixer at %d with buffer %d', [gsSDLSampleRate, gsSDLBufferSize]), TMsgType.Notify);
217 res := Mix_OpenAudio(gsSDLSampleRate, MIX_DEFAULT_FORMAT, 2, gsSDLBufferSize);
220 e_WriteLog('Error initializing SDL mixer:', TMsgType.Fatal);
221 e_WriteLog(Mix_GetError(), TMsgType.Fatal);
225 if Mix_QuerySpec(@rfreq, @rformat, @rchans) > 0 then
227 e_WriteLog(Format('SDL: frequency=%d; format=%u; channels=%d', [rfreq, rformat, rchans]), TMsgType.Notify);
230 for i := 0 to Mix_GetNumChunkDecoders()-1 do
232 e_WriteLog(Format('SDL: chunk decoder %s is avalable', [Mix_GetChunkDecoder(i)]), TMsgType.Notify);
235 e_TimidityDecoder := false;
236 for i := 0 to Mix_GetNumMusicDecoders()-1 do
238 case AnsiString(Mix_GetMusicDecoder(i)) of
239 'TIMIDITY': e_TimidityDecoder := true;
241 e_WriteLog(Format('SDL: music decoder %s is avalable', [Mix_GetMusicDecoder(i)]), TMsgType.Notify);
244 Mix_AllocateChannels(N_CHANNELS);
245 Mix_ChannelFinished(chanFinished);
247 for i := 0 to N_CHANNELS-1 do
249 ChanSIds[i].id := NO_SOUND_ID;
250 ChanSIds[i].muted := SoundMuted;
251 ChanSIds[i].oldvol := MIX_MAX_VOLUME;
252 ChanSIds[i].pan := 1.0;
254 MusVolume := MIX_MAX_VOLUME;
256 SoundInitialized := True;
260 function e_isMusic (id: DWORD): Boolean;
263 if (e_SoundsArray <> nil) and (id <= High(e_SoundsArray)) then
265 Result := (e_SoundsArray[id].Music <> nil);
269 function e_isSound (id: DWORD): Boolean;
272 if (e_SoundsArray <> nil) and (id <= High(e_SoundsArray)) then
274 Result := (e_SoundsArray[id].Sound <> nil);
278 function FindESound(): DWORD;
282 if e_SoundsArray <> nil then
284 for i := 0 to High(e_SoundsArray) do
285 if (e_SoundsArray[i].Sound = nil) and (e_SoundsArray[i].Music = nil) then
291 if e_SoundsArray = nil then
293 SetLength(e_SoundsArray, 16);
298 Result := High(e_SoundsArray) + 1;
299 SetLength(e_SoundsArray, Length(e_SoundsArray) + 16);
301 for i := Result to High(e_SoundsArray) do
303 e_SoundsArray[i].Sound := nil;
304 e_SoundsArray[i].Music := nil;
305 e_SoundsArray[i].Data := nil;
306 e_SoundsArray[i].isMusic := False;
307 e_SoundsArray[i].nRefs := 0;
311 function e_LoadSound(FileName: String; var ID: DWORD; isMusic: Boolean; ForceNoLoop: Boolean = False): Boolean;
317 if not SoundInitialized then Exit;
319 if isMusic then e_WriteLog('Loading music '+FileName+'...', TMsgType.Notify)
320 else e_WriteLog('Loading sound '+FileName+'...', TMsgType.Notify);
325 e_WriteLog('IGNORING MUSIC FROM FILE', TMsgType.Warning);
330 find_id := FindESound();
332 e_SoundsArray[find_id].Data := nil;
333 e_SoundsArray[find_id].isMusic := isMusic;
334 e_SoundsArray[find_id].Loops := isMusic and not ForceNoLoop;
335 e_SoundsArray[find_id].nRefs := 0;
339 e_WriteLog(Format(' MUSIC SLOT: %u', [find_id]), TMsgType.Notify);
340 e_SoundsArray[find_id].Music := Mix_LoadMUS(PAnsiChar(FileName));
341 if e_SoundsArray[find_id].Music = nil then
343 e_WriteLog(Format('ERROR LOADING MUSIC:', [find_id]), TMsgType.Warning);
344 e_WriteLog(Mix_GetError(), TMsgType.Warning);
347 dumpMusicType(e_SoundsArray[find_id].Music);
351 e_SoundsArray[find_id].Sound := Mix_LoadWAV(PAnsiChar(FileName));
352 if e_SoundsArray[find_id].Sound = nil then Exit;
360 function e_LoadSoundMem(pData: Pointer; Length: Integer; var ID: DWORD; isMusic: Boolean; ForceNoLoop: Boolean = False): Boolean;
369 if not SoundInitialized then Exit;
375 e_WriteLog('IGNORING MUSIC FROM MEMORY', TMsgType.Warning);
380 //FIXME: correctly skip ID3
383 if (Length > $400) and (pc[0] = 'I') and (pc[1] = 'D') and (pc[2] = '3') then
387 pData := Pointer(pc);
389 e_WriteLog('MUSIC: MP3 ID3 WORKAROUND APPLIED!', TMsgType.Warning);
393 rw := SDL_RWFromConstMem(pData, Length);
394 if rw = nil then Exit;
396 find_id := FindESound();
398 e_SoundsArray[find_id].Data := pData;
399 if isid3 then e_SoundsArray[find_id].Data := nil;
400 e_SoundsArray[find_id].isMusic := isMusic;
401 e_SoundsArray[find_id].Loops := isMusic and not ForceNoLoop;
402 e_SoundsArray[find_id].nRefs := 0;
406 e_WriteLog(Format(' MUSIC SLOT: %u', [find_id]), TMsgType.Notify);
408 e_SoundsArray[find_id].Music := Mix_LoadMUS_RW(rw);
410 e_SoundsArray[find_id].Music := Mix_LoadMUS_RW(rw, 0);
412 if e_SoundsArray[find_id].Music = nil then
414 e_WriteLog(Format('ERROR LOADING MUSIC:', [find_id]), TMsgType.Warning);
415 e_WriteLog(Mix_GetError(), TMsgType.Warning);
419 dumpMusicType(e_SoundsArray[find_id].Music);
423 if e_SoundsArray[find_id].Music <> nil then
425 Mix_FreeMusic(e_SoundsArray[find_id].Music);
427 e_SoundsArray[find_id].Music := nil;
433 e_SoundsArray[find_id].Sound := Mix_LoadWAV_RW(rw, 0);
435 //SDL_FreeRW(rw); // somehow it segfaults...
436 if (e_SoundsArray[find_id].Sound = nil) and (e_SoundsArray[find_id].Music = nil) then
438 e_SoundsArray[find_id].Data := nil;
447 function e_PlaySound (ID: DWORD): Integer;
453 if not SoundInitialized then Exit;
455 if e_isSound(ID) then
457 if e_SoundsArray[ID].nRefs >= gMaxSimSounds then Exit;
458 Inc(e_SoundsArray[ID].nRefs);
459 if e_SoundsArray[ID].Loops then loops := -1;
460 res := Mix_PlayChannel(-1, e_SoundsArray[ID].Sound, loops);
463 ChanSIds[res].id := ID;
464 ChanSIds[res].muted := SoundMuted;
465 if SoundMuted then Mix_Volume(res, 0) else Mix_Volume(res, ChanSIds[res].oldvol);
467 if e_SoundsArray[ID].isMusic then
468 res := Mix_PlayChannel(-1, e_SoundsArray[ID].Sound, -1)
470 res := Mix_PlayChannel(-1, e_SoundsArray[ID].Sound, 0);
476 if not e_isMusic(ID) then Exit;
478 if e_SoundsArray[ID].Loops then loops := -1;
479 res := Mix_PlayMusic(e_SoundsArray[ID].Music, loops);
480 if res >= 0 then res := N_MUSCHAN;
481 if SoundMuted then Mix_VolumeMusic(0) else Mix_VolumeMusic(MusVolume);
488 function e_chanSetPan (chan: Integer; Pan: Single): Boolean;
493 if chan = N_MUSCHAN then
495 // no panning for music
497 else if chan >= 0 then
499 if Pan < -1.0 then Pan := -1.0 else if Pan > 1.0 then Pan := 1.0;
500 Pan := Pan+1.0; // 0..2
501 l := trunc(127.0*(2.0-Pan));
502 r := trunc(127.0*Pan);
503 Mix_SetPanning(chan, l, r);
504 ChanSIds[chan].pan := Pan;
512 function e_chanSetVol (chan: Integer; Volume: Single): Boolean;
517 if Volume < 0 then Volume := 0 else if Volume > 1 then Volume := 1;
518 vol := trunc(Volume*MIX_MAX_VOLUME);
519 if chan = N_MUSCHAN then
522 if SoundMuted then Mix_VolumeMusic(0) else Mix_VolumeMusic(vol);
524 else if chan >= 0 then
526 ChanSIds[chan].oldvol := vol;
527 if ChanSIds[chan].muted then Mix_Volume(chan, 0) else Mix_Volume(chan, vol);
535 function e_PlaySoundPan(ID: DWORD; Pan: Single): Integer;
540 chan := e_PlaySound(ID);
541 e_chanSetPan(chan, Pan);
545 function e_PlaySoundVolume(ID: DWORD; Volume: Single): Integer;
550 chan := e_PlaySound(ID);
551 e_chanSetVol(chan, Volume);
555 function e_PlaySoundPanVolume(ID: DWORD; Pan, Volume: Single): Integer;
560 chan := e_PlaySound(ID);
561 e_chanSetPan(chan, Pan);
562 e_chanSetVol(chan, Volume);
566 procedure e_DeleteSound(ID: DWORD);
570 if ID > High(e_SoundsArray) then Exit;
571 if (e_SoundsArray[ID].Sound = nil) and (e_SoundsArray[ID].Music = nil) then Exit;
573 for i := 0 to N_CHANNELS-1 do
575 if ChanSIds[i].id = ID then
577 ChanSIds[i].id := NO_SOUND_ID;
582 if e_SoundsArray[ID].Sound <> nil then Mix_FreeChunk(e_SoundsArray[ID].Sound);
583 if e_SoundsArray[ID].Music <> nil then Mix_FreeMusic(e_SoundsArray[ID].Music);
584 if e_SoundsArray[ID].Data <> nil then FreeMem(e_SoundsArray[ID].Data);
586 e_SoundsArray[ID].Sound := nil;
587 e_SoundsArray[ID].Music := nil;
588 e_SoundsArray[ID].Data := nil;
589 e_SoundsArray[ID].nRefs := 0;
592 procedure e_ModifyChannelsVolumes(SoundMod: Single; setMode: Boolean);
598 for i := 0 to N_CHANNELS-1 do
600 ovol := ChanSIds[i].oldvol;
607 vol := (MIX_MAX_VOLUME+0.0)/ovol;
610 if vol < 0 then vol := 0 else if vol > 1 then vol := 1;
611 ChanSIds[i].oldvol := trunc(vol*MIX_MAX_VOLUME);
612 //if i = 0 then e_WriteLog(Format('modifying volumes: vol=%f; newvol=%d', [vol, ChanSIds[i].oldvol]), TMsgType.Warning);
613 if ChanSIds[i].muted then Mix_Volume(i, 0) else Mix_Volume(i, ChanSIds[i].oldvol);
615 ovol := Mix_VolumeMusic(-1);
624 vol := (MIX_MAX_VOLUME+0.0)/ovol;
625 vol := vol * SoundMod;
627 if vol < 0 then vol := 0 else if vol > 1 then vol := 1;
628 MusVolume := trunc(vol*MIX_MAX_VOLUME);
629 if SoundMuted then Mix_VolumeMusic(0) else Mix_VolumeMusic(MusVolume);
633 procedure e_MuteChannels(Enable: Boolean);
637 //if Enable = SoundMuted then Exit;
638 SoundMuted := Enable;
639 for i := 0 to N_CHANNELS-1 do
641 if ChanSIds[i].muted <> SoundMuted then
643 ChanSIds[i].muted := SoundMuted;
644 //e_WriteLog(Format('gmuting sound for channel %d', [i]), TMsgType.Warning);
645 if ChanSIds[i].muted then Mix_Volume(i, 0) else Mix_Volume(i, ChanSIds[i].oldvol);
648 //if SoundMuted then e_WriteLog('muting music', TMsgType.Notify) else e_WriteLog(Format('unmuting music (%d)', [MusVolume]), TMsgType.Notify);
649 if SoundMuted then Mix_VolumeMusic(0) else Mix_VolumeMusic(MusVolume);
652 procedure e_StopChannels();
658 for i := 0 to High(e_SoundsArray) do e_SoundsArray[i].nRefs := 0;
659 for i := 0 to N_CHANNELS-1 do ChanSIds[i].id := NO_SOUND_ID;
662 procedure e_RemoveAllSounds();
666 if SoundInitialized then e_StopChannels();
667 for i := 0 to High(e_SoundsArray) do e_DeleteSound(i);
668 SetLength(e_SoundsArray, 0);
669 e_SoundsArray := nil;
672 procedure e_ReleaseSoundSystem();
675 if SoundInitialized then
678 SoundInitialized := False;
682 procedure e_SoundUpdate();
684 //FMOD_System_Update(F_System);
690 constructor TBasicSound.Create();
699 destructor TBasicSound.Destroy();
705 function TBasicSound.GetChan (): Integer;
707 if (FID <> NO_SOUND_ID) and (FChanNum >= 0) and (FChanNum < N_CHANNELS) then
709 if ChanSIds[FChanNum].id <> FID then FChanNum := -1;
711 else if e_isMusic(FID) then
713 FChanNum := N_MUSCHAN;
718 procedure TBasicSound.FreeSound();
720 if FID = NO_SOUND_ID then Exit;
729 function TBasicSound.RawPlay(Pan: Single; Volume: Single; aPos: DWORD): Boolean;
732 if (FID = NO_SOUND_ID) or not SoundInitialized then Exit;
733 FChanNum := e_PlaySoundPanVolume(FID, Pan, Volume);
734 Result := (FChanNum >= 0);
735 //if e_isMusic(FID) then e_WriteLog(Format('playing music (%u)', [FID]), TMsgType.Notify);
739 procedure TBasicSound.SetID(ID: DWORD);
743 if ID <> NO_SOUND_ID then
745 FMusic := e_SoundsArray[ID].isMusic;
750 function TBasicSound.IsPlaying(): Boolean;
755 if e_isSound(FID) then
757 //e_WriteLog(Format('IsPlaying: FID=%u; FChanNum=%d', [FID, FChanNum]), TMsgType.Warning);
761 //e_WriteLog(Format('IsPlaying: FID=%u; ONA', [FID]), TMsgType.Warning);
764 //Result := (Mix_Playing(chan) > 0)
765 //e_WriteLog(Format('IsPlaying: FID=%u; TAN', [FID]), TMsgType.Warning);
768 else if e_isMusic(FID) then
770 Result := (Mix_PlayingMusic() > 0);
774 procedure TBasicSound.Stop();
778 if e_isSound(FID) then
784 Mix_HaltChannel(chan);
787 else if e_isMusic(FID) then
794 function TBasicSound.IsPaused(): Boolean;
799 if e_isSound(FID) then
802 if chan < 0 then Exit;
803 Result := (Mix_Paused(chan) > 0);
805 else if e_isMusic(FID) then
807 Result := (Mix_PausedMusic() > 0);
811 procedure TBasicSound.Pause(Enable: Boolean);
816 Enable := not Enable; // fuckin' double negation
817 if e_isSound(FID) then
820 if chan < 0 then Exit;
821 pl := not (Mix_Paused(chan) > 0);
824 if Enable then Mix_Resume(chan) else Mix_Pause(chan);
827 else if e_isMusic(FID) then
829 pl := not (Mix_PausedMusic() > 0);
832 if Enable then Mix_ResumeMusic() else Mix_PauseMusic();
838 res := FMOD_Channel_GetPosition(FChanNum, FPosition, FMOD_TIMEUNIT_MS);
839 if res <> FMOD_OK then
846 function TBasicSound.GetVolume(): Single;
851 if e_isSound(FID) then
854 if chan < 0 then Exit;
855 Result := (ChanSIds[chan].oldvol+0.0)/(MIX_MAX_VOLUME+0.0);
857 else if e_isMusic(FID) then
859 Result := (MusVolume+0.0)/(MIX_MAX_VOLUME+0.0);
863 procedure TBasicSound.SetVolume(Volume: Single);
867 if e_isSound(FID) then
870 if chan < 0 then Exit;
871 //e_WriteLog(Format('SetVolume: chan=%d; Volume=%f', [chan, Volume]), TMsgType.Warning);
872 e_chanSetVol(chan, Volume);
874 else if e_isMusic(FID) then
876 //e_WriteLog(Format('SetVolume: chan=MUSIC; Volume=%f', [Volume]), TMsgType.Warning);
877 e_chanSetVol(N_MUSCHAN, Volume);
881 function TBasicSound.GetPan(): Single;
886 if e_isSound(FID) then
889 if chan < 0 then Exit;
890 Result := ChanSIds[chan].pan;
894 procedure TBasicSound.SetPan(Pan: Single);
898 if e_isSound(FID) then
901 if chan < 0 then Exit;
902 e_chanSetPan(chan, Pan);
906 function TBasicSound.IsMuted(): Boolean;
911 if e_isSound(FID) then
914 if chan < 0 then Exit;
915 Result := ChanSIds[chan].muted;
917 else if e_isMusic(FID) then
919 Result := SoundMuted;
923 procedure TBasicSound.Mute(Enable: Boolean);
927 if e_isSound(FID) then
930 if chan < 0 then Exit;
931 if ChanSIds[chan].muted <> Enable then
933 //e_WriteLog(Format('muting sound for channel %d', [cnan]), TMsgType.Warning);
934 ChanSIds[chan].muted := Enable;
935 if ChanSIds[chan].muted then Mix_Volume(chan, 0) else Mix_Volume(chan, ChanSIds[chan].oldvol);
938 else if e_isMusic(FID) then
940 if Enable then Mix_VolumeMusic(0) else Mix_VolumeMusic(MusVolume);
945 function TBasicSound.GetPosition(): DWORD;
949 if FChanNum < 0 then Exit;
950 res := FMOD_Channel_GetPosition(FChanNum, FPosition, FMOD_TIMEUNIT_MS);
951 if res <> FMOD_OK then
960 procedure TBasicSound.SetPosition(aPos: DWORD);
964 if FChanNum < 0 then Exit;
965 res := FMOD_Channel_SetPosition(FChanNum, FPosition, FMOD_TIMEUNIT_MS);
966 if res <> FMOD_OK then
973 procedure TBasicSound.SetPriority(priority: Integer);
976 if (FChanNum <> nil) and (FPriority <> priority) and
977 (priority >= 0) and (priority <= 256) then
979 FPriority := priority;
980 res := FMOD_Channel_SetPriority(FChanNum, priority);
981 if res <> FMOD_OK then