Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
fmodaudio [2019/03/08 10:40] – admin | fmodaudio [2019/08/13 09:16] – [Remarks] admin | ||
---|---|---|---|
Line 17: | Line 17: | ||
Supported platforms: Microsoft Windows (x86 and x86-64), macOS, iOS, Linux (x86 and x86-64), Android, BlackBerry, Wii, Wii U, 3DS, Nintendo Switch, Xbox, Xbox 360, Xbox One, PlayStation 2, PlayStation 3, PlayStation 4, PlayStation Portable, PlayStation Vita, and Google Native Client. | Supported platforms: Microsoft Windows (x86 and x86-64), macOS, iOS, Linux (x86 and x86-64), Android, BlackBerry, Wii, Wii U, 3DS, Nintendo Switch, Xbox, Xbox 360, Xbox One, PlayStation 2, PlayStation 3, PlayStation 4, PlayStation Portable, PlayStation Vita, and Google Native Client. | ||
+ | |||
+ | ===== Units ===== | ||
Gorilla3D provides the low level header declarations in Gorilla.Audio.FMOD.Lib.* units. | Gorilla3D provides the low level header declarations in Gorilla.Audio.FMOD.Lib.* units. | ||
Line 31: | Line 33: | ||
</ | </ | ||
- | To simplify usage of the massive amount of functions, Gorilla3D provides higher level structure declarations in Gorilla.Audio.FMOD.* units. | + | To simplify usage of the massive amount of functions, Gorilla3D provides higher level structure declarations in Gorilla.Audio.FMOD.Intf.* and Gorilla.Audio.FMOD.* units. |
+ | |||
+ | < | ||
+ | Gorilla.Audio.FMOD.Intf.System | ||
+ | Gorilla.Audio.FMOD.Intf.Channel | ||
+ | Gorilla.Audio.FMOD.Intf.ChannelGroup | ||
+ | Gorilla.Audio.FMOD.Intf.DSP | ||
+ | Gorilla.Audio.FMOD.Intf.Sound | ||
+ | Gorilla.Audio.FMOD.Intf.SoundGroup | ||
+ | Gorilla.Audio.FMOD.Intf.Reverb3D | ||
+ | Gorilla.Audio.FMOD.Intf.Geometry | ||
+ | </ | ||
< | < | ||
Line 51: | Line 64: | ||
</ | </ | ||
- | ===== To load an audio file at runtime | + | __**Remarks: |
+ | ===== Examples ===== | ||
+ | |||
+ | ==== To load an audio file at runtime ==== | ||
<file pascal Form1.pas> | <file pascal Form1.pas> | ||
Line 63: | Line 79: | ||
procedure TForm1.FormShow(Sender: | procedure TForm1.FormShow(Sender: | ||
var LPath : String; | var LPath : String; | ||
- | LSound : PGorillaFMODSound; | + | LSound : IGorillaFMODSound; |
begin | begin | ||
FFMOD := TGorillaFMODAudioManager.Create(Self); | FFMOD := TGorillaFMODAudioManager.Create(Self); | ||
Line 80: | Line 96: | ||
</ | </ | ||
- | ===== Output playback position | + | ==== Output playback position ==== |
Line 86: | Line 102: | ||
uses | uses | ||
Gorilla.Audio.FMOD, | Gorilla.Audio.FMOD, | ||
- | Gorilla.Audio.FMOD.Sound, | + | Gorilla.Audio.FMOD.Intf.Sound, |
- | Gorilla.Audio.FMOD.Channel; | + | Gorilla.Audio.FMOD.Intf.Channel; |
procedure TForm1.Timer1Timer(Sender: | procedure TForm1.Timer1Timer(Sender: | ||
- | var LSound : PGorillaFMODSound; | + | var LSound : IGorillaFMODSound; |
- | LMS, LLenMS : UInt32; | + | LMS, LLenMS : UInt32; |
begin | begin | ||
{...} | {...} | ||
- | LMS := FChannel^.Position[FMOD_TIMEUNIT_MS]; | + | LMS := FChannel.Position[FMOD_TIMEUNIT_MS]; |
- | LSound := PGorillaFMODSound(LChannel^.GetCurrentSound()); | + | LSound := LChannel.GetCurrentSound() |
if Assigned(LSound) then | if Assigned(LSound) then | ||
begin | begin | ||
- | LLenMS := LSound^.Length[FMOD_TIMEUNIT_MS]; | + | LLenMS := LSound.Length[FMOD_TIMEUNIT_MS]; |
Self.Caption := Format(' | Self.Caption := Format(' | ||
end; | end; | ||
Line 105: | Line 121: | ||
- | ===== Add a FadePoint | + | ==== Add a FadePoint ==== |
<file pascal Form1.pas> | <file pascal Form1.pas> | ||
Line 114: | Line 130: | ||
procedure TForm1.FormShow(Sender: | procedure TForm1.FormShow(Sender: | ||
- | var LSound : PGorillaFMODSound; | + | var LSound : IGorillaFMODSound; |
- | LChannel : PGorillaFMODChannel; | + | LChannel : IGorillaFMODChannel; |
- | LClock, LPClock : UInt64; | + | LClock, LPClock : UInt64; |
begin | begin | ||
{...} | {...} | ||
Line 122: | Line 138: | ||
if Assigned(LChannel) then | if Assigned(LChannel) then | ||
begin | begin | ||
- | LChannel^.GetDSPClock(LClock, | + | LChannel.GetDSPClock(LClock, |
- | LChannel^.AddFadePoint(LPClock, | + | LChannel.AddFadePoint(LPClock, |
- | LChannel^.AddFadePoint(LPClock + 48000, 1.0); | + | LChannel.AddFadePoint(LPClock + 48000, 1.0); |
end; | end; | ||
end; | end; | ||
Line 130: | Line 146: | ||
- | ===== Set 3D Listener Position | + | ==== Set 3D Listener Position ==== |
<file pascal Form1.pas> | <file pascal Form1.pas> | ||
Line 164: | Line 180: | ||
- | ===== Loop sample | + | ==== Loop sample ==== |
<file pascal Form1.pas> | <file pascal Form1.pas> | ||
Line 173: | Line 189: | ||
procedure TForm1.FormShow(Sender: | procedure TForm1.FormShow(Sender: | ||
- | var LSound : PGorillaFMODSound; | + | var LSound : IGorillaFMODSound; |
begin | begin | ||
{...} | {...} | ||
LSound := LFMOD.LoadSoundFromFile(' | LSound := LFMOD.LoadSoundFromFile(' | ||
- | LSound^.Mode := FMOD_LOOP_NORMAL; | + | LSound.Mode := FMOD_LOOP_NORMAL; |
end; | end; | ||
</ | </ | ||
- | ===== Usage ===== | + | ===== Android |
Using FMOD in Android needs some additional configuration. Because on Android the FMOD engine uses a Java library (fmod.jar), we need to attach those to our project. | Using FMOD in Android needs some additional configuration. Because on Android the FMOD engine uses a Java library (fmod.jar), we need to attach those to our project. | ||
To allow correct loading of this FMOD Java library, we created an extra Java library (Gorilla.jar). This library loads the FMOD library in the right context. | To allow correct loading of this FMOD Java library, we created an extra Java library (Gorilla.jar). This library loads the FMOD library in the right context. | ||
- | |||
Go to your project tree and select Android as destination platform. Then enter the library section and add these 2 files: fmod.jar, Gorilla.jar to your project. You can find them in the " | Go to your project tree and select Android as destination platform. Then enter the library section and add these 2 files: fmod.jar, Gorilla.jar to your project. You can find them in the " | ||
+ | |||
+ | {{ :: | ||
+ | |||
+ | Next step: [[assetsmanager|AssetsManager]] | ||
+ | |||
+ | ===== Remarks ===== | ||
+ | It is not allowed to release FMOD interfaces when the TGorillaFMODAudioManager component, especially the IGorillaFMODSystem interface inside of it, is already destroyed. | ||
+ | In this case you will receive an AccessViolation, | ||
+ | |||
+ | **WRONG:** | ||
+ | <file pascal> | ||
+ | var LFMOD : TGorillaFMODAudioManager; | ||
+ | LSound : IGorillaFMODSound; | ||
+ | | ||
+ | [...] | ||
+ | |||
+ | LFMOD := TGorillaFMODAudioManager.Create(nil); | ||
+ | try | ||
+ | LSound := LFMOD.LoadSoundFromFile(Common_MediaPathRaw(' | ||
+ | finally | ||
+ | FreeAndNil(LFMOD); | ||
+ | LSound := nil; // <<< | ||
+ | end; | ||
+ | </ | ||
+ | |||
+ | **CORRECT: | ||
+ | <file pascal> | ||
+ | var LFMOD : TGorillaFMODAudioManager; | ||
+ | LSound : IGorillaFMODSound; | ||
+ | | ||
+ | [...] | ||
+ | |||
+ | LFMOD := TGorillaFMODAudioManager.Create(nil); | ||
+ | try | ||
+ | LSound := LFMOD.LoadSoundFromFile(Common_MediaPathRaw(' | ||
+ | finally | ||
+ | LSound := nil; // !!! CORRECT! | ||
+ | FreeAndNil(LFMOD); | ||
+ | end; | ||
+ | </ |