audio :: EXCEPTION_ACCESS_VIOLATION :: Solved
BlitzMax Forums/BlitzMax Beginners Area/audio :: EXCEPTION_ACCESS_VIOLATION :: Solved
| ||
| No problem in Debug MODE But when I make a Release and try run the Application I get: "EXCEPTION_ACCESS_VIOLATION"
SuperStrict
Framework brl.System
Import maxgui.Drivers
Import brl.EventQueue
Import brl.audio
Local MyWindow:TGadget=CreateWindow("Sound", 40,40,400,400)
Global Snd:TSound = LoadSound("sound/Plopp.wav")
Global Ch:TChannel
Ch = CueSound(Snd) ' This make the VIOLATION
Ch.SetVolume .25
Ch.SetPaused False
Repeat
WaitEvent()
Select EventID()
Case EVENT_WINDOWCLOSE End
End Select
ForeverWhat I do wrong? |
| ||
| You can check if Snd is Null or not. If it's Null, CueSound() will probably break. You may also wish to import BRL.WAVLoader. |
| ||
| Import brl.WAVLoader FIX the EXCEPTION_ACCESS_VIOLATION Snd is Not Null (it's work fine in Debug MODE, but still quiet in the final Release .exe)
SuperStrict
Framework brl.System
Import maxgui.Drivers
Import brl.EventQueue
Import brl.audio
Import brl.WAVLoader
Local Wello:TGadget=CreateWindow("Sound", 400, 200, 400, 400)
Global Snd:TSound = LoadSound("LEVER2.wav")
Global Ch:TChannel
If Snd = Null Then
SetStatusText Wello, "No Sound"
Else
SetStatusText Wello, "OK Sound" ' Snd is not Null
End If
Ch = CueSound(Snd)
Ch.SetVolume .25
Ch.SetPaused False
Repeat
WaitEvent()
Select EventID()
Case EVENT_WINDOWCLOSE End
End Select
Forever
I try put sound in root directory and change to another sound still quiet |
| ||
| Try importing BRL.FreeAudioAudio instead of BRL.Audio. |
| ||
I had intermittent problems with audio - I think it was on Mac, but anyway. I found this to be the best way of playing sounds as it cured the problem I was having (sound not playing).
Global Ch:TChannel = AllocChannel()
Global Snd:TSound = LoadSound("LEVER2.wav")
CueSound(Snd, Ch)
Ch.SetVolume(0.25)
Ch.SetPaused(False) |
| ||
| If I remove SuperStrict and only use: Import maxgui.Drivers it was working but the .exe file become 5.5 times bigger I import 1 at a time until I find the True Love.. Import brl.WAVLoader Import brl.directsoundaudio was the magical SuperStrict
Framework brl.System
Import maxgui.Drivers
Import brl.EventQueue
Import brl.WAVLoader
Import brl.directsoundaudio
Local Wello:TGadget = CreateWindow("Sound Test", 400, 200, 400, 400)
Local MOBii:TGadget
Global Ch:TChannel
Global Snd:TSound = LoadSound("LEVER2.wav")
If Snd = Null Then
SetStatusText Wello, "No Sound"
Else
SetStatusText Wello, "Sound Loaded" ' Snd is not Null
End If
MOBii = CreateMenu("&MOBii", 0, WindowMenu(Wello))
CreateMenu "Sound &A", 1, MOBii, KEY_F5
CreateMenu "Sound &B", 2, MOBii, KEY_F6
CreateMenu "Sound &C", 3, MOBii, KEY_F7
CreateMenu "E&xit", 0, MOBii, KEY_ESCAPE ' , MODIFIER_COMMAND
UpdateWindowMenu Wello
'PlaySound(Snd).SetVolume(.1)
Repeat
WaitEvent()
Select EventID()
Case EVENT_WINDOWCLOSE End
Case EVENT_MENUACTION
Select EventData()
Case 0 End
Case 1
Ch = CueSound(Snd)
Ch.SetVolume .25
Ch.SetPaused(False)
SetStatusText Wello, "1 >>" + Ch.toString()
Case 2
Local C:TChannel = CueSound(Snd)
C.SetVolume .25
C.SetPaused(False)
SetStatusText Wello, "2 >>" + C.toString()
Case 3
PlaySound(Snd).SetVolume(.1)
SetStatusText Wello, "3 >>"
End Select
End Select
ForeverCh = CueSound(Snd, Ch) Look like it play on one Channel only!Ch = CueSound(Snd) automatically allocates Snd on a new channel. I learned that PlaySound allocates a new channel when start playing + I can set the sound volume ^^ PlaySound(Snd).SetVolume(.1) |
| ||
| Since importing all modules does make it work for you, it sounds like there still a missing import somewhere -- you may want to try Framework Assistant to help you determine which modules are necessary for your program. |
| ||
| thanks |