Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Sound channel question — Gideros Forum

Sound channel question

Tom2012Tom2012 Guru
edited September 2015 in General questions
Hey guys :)

Been having crashes this past week with my game and tracked it back to sound channels.

I've since learned:

- You are limited to 32 channels, any over that will return nil.
- Using soundChannel:setPaused(true) still takes up a sound channel
- Using soundChannel:stop() and play() is better as it frees up the sound channel in between uses.

This might help other people. Just wanted to check it's correct. Thanks!

Comments

  • Yes exactly, Even for me sound didn't work after sometime. found that :stop() is disposing the channel. :pause() still keeps it alive.

    Likes: Tom2012

    +1 -1 (+1 / -0 )Share on Facebook
  • SinisterSoftSinisterSoft Maintainer
    edited September 2015
    New version out soon has an extra sound player (xmp) that may also allow sound injection to any one of 64 sound channels. Nico will know more about this.

    Likes: Tom2012

    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
    +1 -1 (+1 / -0 )Share on Facebook
  • Tom2012Tom2012 Guru
    edited September 2015
    Hmm still getting crashes,
    	self.spinnerSound = Sound.new("Sounds/spinner.wav")
     
    	self.channel1 = self.spinnerSound:play(0,true)
    	self.channel1:setVolume(0)
    And at the end of each level I use
    	if(self.channel1) then
    		self.channel1:stop()
    		self.channel1 = nil
    	end
    The crash only happens when restarting a level. Its as if the empty channels are not being collected, and are still present.

    EDIT: My mistake. I was running the following loop, which was setting the sound channels to nil, without stopping them.
    	if(self.scene.spritesWithVolume) then
    		for i,v in pairs(self.scene.spritesWithVolume) do
     
    			if(v.channel1) then
    				v.channel1:setVolume(0)
    				v.channel1 = nil
    			end
     
    			if(v.channel2) then
    				v.channel2:setVolume(0)
    				v.channel2 = nil
    			end
     
    			end
    		end
  • totebototebo Member
    edited September 2015
    To add to the mix, sometimes a sound can't be played for memory reasons and returns nil. That means it's good practice to check if the sound channel was actually created OK before using it.
    My Gideros games: www.totebo.com
    +1 -1 (+2 / -0 )Share on Facebook
Sign In or Register to comment.