Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Preset channel volumes & audio.play()
Started by Xorcist Jul 22 2019 07:41 PM

2 replies to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

Xorcist

[GLOBAL: userInfoPane.html]
Xorcist
  • Observer

  • 11 posts
  • Corona SDK

I have three channels that I want to reserve for music tracks (which I will use for cross-fading between scenes). The volumes of these tracks are set specifically before playing, and on scene destruction I audio.stop() the channel associated with the current scene.

 

My question is... any other sound effect, played with audio.play(), has a chance of grabbing one of the two stopped channels, whose volume has been preset. And since audio.play() just grabs a random channel, it's entirely possible to have, for instance, a laser sound come out at two different volumes.

 

What is the best practice way of avoiding this? Should I be using onComplete callback of audio.play() to reset the volume of the channels? Or is there some better way to reserve those channels so that audio.play() won't attempt to use them? I mean I could pool and manage the free channels myself, but that just seems like overkill.



[TOPIC: post.html]
#2

Appletreeman

[GLOBAL: userInfoPane.html]
Appletreeman
  • Contributor

  • 442 posts
  • Corona SDK

if in your main.lua you reserve the first three channels using

audio.reserveChannels(3)

then those channels will not be used by any other audio unless specified.  Just stopping the channel playing does not free it up from being reserved.



[TOPIC: post.html]
#3

Xorcist

[GLOBAL: userInfoPane.html]
Xorcist
  • Observer

  • 11 posts
  • Corona SDK

Oh wow... how did I totally miss that in the documentation.... thanks. 


  • Appletreeman likes this


[topic_controls]
[/topic_controls]