Hi,
i'm looking for a simple working FMOD example in the latest PB version.
Is it also possible to include the .dll inside the exe? Or how to deliver it to the user? IncludeBinary and put it into the Home folder or something?
Many thanks!
Wanted: working FMOD example
Re: Wanted: working FMOD example
like that?
https://github.com/pbcodex/FMODEX-MIN-UNICODE
https://github.com/pbcodex/FMODEX-MIN-UNICODE
Code: Select all
EnableExplicit
IncludeFile "fmodex.pbi"
Enumeration
#Mainform
#File
#OpenFile
#Play
#Pause
#Stop
#Volume
EndEnumeration
Define.l Event, GEvent, TiEvent
Global WindowStyle.i=#PB_Window_SystemMenu|#PB_Window_ScreenCentered
Global fmodsystem.i, Channel.i, Sound.i, Volume.f = 0.5, PauseStatus.b
Global File.s
Procedure Open_MainForm()
OpenWindow(#Mainform, 0, 0, 300, 100, "Play Mp3", WindowStyle)
StringGadget(#File, 10, 20, 230, 22, "", #PB_String_ReadOnly)
ButtonGadget(#OpenFile, 245, 20, 50, 22, "Select")
TextGadget(#PB_Any, 10, 50, 30, 20, "Vol")
TrackBarGadget(#Volume, 45, 45, 200, 24, 0, 100)
SetGadgetState(#Volume, 50)
ButtonGadget(#Play, 55, 70, 60, 22, "Start")
ButtonGadget(#Pause, 117, 70, 60, 22, "Pause")
ButtonGadget(#Stop, 183, 70, 60, 22, "Stop")
EndProcedure
Open_MainForm()
;Déclarer l'objet FMOD System
FMOD_System_Create(@fmodsystem)
;Initialiser le system (32 canaux) un seul suffirait pour cet exemple
FMOD_System_Init(fmodsystem, 32, #FMOD_INIT_NORMAL, 0)
Repeat
Event = WaitWindowEvent(100)
GEvent = EventGadget()
Select Event
Case #PB_Event_Gadget
Select GEvent
Case #OpenFile
;Décharge le son précédent
If Sound <> 0
FMOD_Sound_Release(Sound)
EndIf
File = OpenFileRequester("Sélectionner un fichier mp3","","Musique|*.mp3;*.wav;*.ogg;*.flac",0)
If File <> ""
SetGadgetText(#File, GetFilePart(File))
FMOD_System_CreateStream(fmodsystem, @File, #FMOD_SOFTWARE, 0, @sound)
EndIf
Case #Volume
Volume = GetGadgetState(#Volume)/100
FMOD_Channel_SetVolume(Channel, Volume)
Case #Play
;PlaySound va jouer le son sur un des canaux libre
;la variable Channel contiendra le handle du canal utilisé par le son.
FMOD_System_PlaySound(fmodsystem, #FMOD_CHANNEL_FREE, sound, 0, @channel)
;Et on ajuste le volume (le son est compris entre 0.0 et 1.0)
FMOD_Channel_SetVolume(Channel, Volume)
Case #Pause
;FMOD_Channel_GetPaused permet de savoir si le son sur le canal est en pause ou pas
FMOD_Channel_GetPaused(Channel, @PauseStatus)
If PauseStatus = #False
FMOD_Channel_SetPaused(Channel, #True) ;Pause
SetGadgetText(#Pause, "Reprendre")
Else
FMOD_Channel_SetPaused(Channel, #False) ;Reprise de la lecture
SetGadgetText(#Pause, "Pause")
EndIf
Case #Stop
FMOD_Channel_Stop(Channel)
EndSelect
Case #PB_Event_CloseWindow
FMOD_Channel_Stop(Channel)
FMOD_System_Release(fmodsystem)
End
EndSelect
ForEver
Re: Wanted: working FMOD example
Many thanks! That's a good basic example!
Any idea how to add these functions to the example?
Any idea how to add these functions to the example?
Code: Select all
Prototype.l FMOD_Channel_GetPosition_Prototype (channel.l, *Position, Postype.l)
Global FMOD_Channel_GetPosition.FMOD_Channel_GetPosition_Prototype = GetFunction(fmodLib, "FMOD_Channel_GetPosition")
Prototype.l FMOD_Channel_SetPosition_Prototype (channel.l, Position.l, Postype.l)
Global FMOD_Channel_SetPosition.FMOD_Channel_SetPosition_Prototype = GetFunction(fmodLib, "FMOD_Channel_SetPosition")
Prototype.l FMOD_Sound_GetLength_Prototype (sound.l, *Length, Lengthtype.l)
Global FMOD_Sound_GetLength.FMOD_Sound_GetLength_Prototype = GetFunction(fmodLib, "FMOD_Sound_GetLength")
Re: Wanted: working FMOD example
I created some Module for that.
Is this something you are looking for?
Code: Select all
DeclareModule FMODEX
#TAG_ALBUM_V2="TALB"
#TAG_ARTIST_V2="TPE1"
#TAG_TITLE_V2="TIT2"
#TAG_TRACK_V2="TRCK"
#TAG_LENGTH_V2="TLEN"
#TAG_GENRE_V2="TCON"
#TAG_YEAR_V2="TYER"
#TAG_COMMENT_v2="COMM"
#TAG_PICTURE_v2="APIC"
Interface FMODEXSystem
Free()
GetVersion.s()
GetLastError.s()
Update()
EndInterface
Interface FMODEXSound Extends FMODEXSystem
GetLength.l()
GetTags(Map tags.s(),Map bintags.i())
GetChannels()
GetBits()
GetFormat.s()
GetType.s()
EndInterface
Interface FMODEXChannel Extends FMODEXSound
Play()
IsPlaying.b()
SetPause(value.b)
IsPaused.b()
Stop()
SetVolume(Volume.f)
GetVolume.f()
SetPosition(Volume.l)
GetPosition.l()
SetMute(value.b)
IsMute.b()
EndInterface
Declare OpenFMODEXFile(file.s)
Declare OpenFMODEXMemory(*m,length)
Declare FreeFMODEx()
EndDeclareModule
Re: Wanted: working FMOD example
I'm far away from using this I'm (amateur) just trying to use/understand the basic functions...
I like the MP3 player example and would like to add a simple "position" feature:
- trackbar showing 00:00 -> actual position (of playing track) e.g. 01:40 -> total length e.g. 03:40 of the mp3
- possibility to change the position by using the slider of the trackbar gadget
I guess this makes use of these 3 functions or?
- FMOD_Sound_GetLength_Prototype (sound.l, *Length, Lengthtype.l)
FMOD_Channel_GetPosition_Prototype (channel.l, *Position, Postype.l)
FMOD_Channel_SetPosition_Prototype (channel.l, Position.l, Postype.l)
Re: Wanted: working FMOD example
Code: Select all
Procedure _SetVolume(*this.strFMODEXFile,value.f)
If *this\channel
Protected result.l=FMOD_Channel_SetVolume(*this\channel,value)
parseResult(*this,result)
EndIf
EndProcedure
Procedure.f _GetVolume(*this.strFMODEXFile)
If *this\channel
Protected vol.f=0
Protected result.l=FMOD_Channel_GetVolume(*this\channel,@vol)
parseResult(*this,result)
ProcedureReturn vol
EndIf
EndProcedure
Procedure _SetPosition(*this.strFMODEXFile,value.l)
If *this\channel
Protected result.l=FMOD_Channel_SetPosition(*this\channel,value,#FMOD_TIMEUNIT_MS)
parseResult(*this,result)
EndIf
EndProcedure
Procedure.l _GetPosition(*this.strFMODEXFile)
If *this\channel
Protected pos.l=0
Protected result.l=FMOD_Channel_GetPosition(*this\channel,@pos,#FMOD_TIMEUNIT_MS)
parseResult(*this,result)
ProcedureReturn pos
EndIf
EndProcedure
Procedure.l _GetLength(*this.strFMODEXFile)
If *this\sound
Protected length.l=0
Protected result.l=FMOD_Sound_GetLength(*this\sound,@length,#FMOD_TIMEUNIT_MS)
parseResult(*this,result)
ProcedureReturn length
EndIf
EndProcedure
Procedure.b parseResult(*this.strFMODEXFile,result.l)
*this\error=result
If Not result=#FMOD_OK
Debug FMOD_ErrorString(result)+"|"+*this\pfad,1
ProcedureReturn #False
EndIf
ProcedureReturn #True
EndProcedure
I think, it is easy to adapt. The structures are my internal structures. But it shouldn't be a problem.
Re: Wanted: working FMOD example
Hi Cyllceaux,
i've managed to add a Trackbargadget showing the actual position and which is able to jump to a specific position.
Some further questions:
1) I saw the spectrum.pb example, is there also a basic function to show the AMPLITUDE of left/right? Just a single bar, not like an equalizer-style in the spectrum-example.
2) Is it possible to PITCH UP an MP3? (don't change the speed)
3) Change the speed, but not the pitch.
Thanks!
i've managed to add a Trackbargadget showing the actual position and which is able to jump to a specific position.
Some further questions:
1) I saw the spectrum.pb example, is there also a basic function to show the AMPLITUDE of left/right? Just a single bar, not like an equalizer-style in the spectrum-example.
2) Is it possible to PITCH UP an MP3? (don't change the speed)
3) Change the speed, but not the pitch.
Thanks!