本文整理汇总了Python中renpy.audio.audio.get_channel函数的典型用法代码示例。如果您正苦于以下问题:Python get_channel函数的具体用法?Python get_channel怎么用?Python get_channel使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_channel函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: stop
def stop(channel="music", fadeout=None):
"""
This stops the music that is currently playing, and dequeues all
queued music. If fadeout is None, the music is faded out for the
time given in config.fade_music, otherwise it is faded for fadeout
seconds.
This sets the last queued file to None.
"""
if renpy.game.context().init_phase:
return
try:
c = get_channel(channel)
ctx = c.context
if fadeout is None:
fadeout = renpy.config.fade_music
c.fadeout(fadeout)
t = get_serial()
ctx.last_changed = t
c.last_changed = t
ctx.last_filenames = [ ]
ctx.last_tight = False
except:
if renpy.config.debug_sound:
raise
示例2: queue
def queue(filenames, channel="music", loop=None, clear_queue=True, fadein=0, tight=None):
"""
This queues the given filenames on the specified channel. If
clear_queue is True, then the queue is cleared, making these files
the files that are played when the currently playing file
finishes. If it is False, then these files are placed at the back of
the queue. In either case, if no music is playing these files
begin playing immediately.
Filenames may either be a single filename, or a list of filenames.
Fadein is the number of seconds to fade the music in for, on the
first loop only.
If loop is True, then this music will repeat as long as it is the
last element of the queue.
The filenames given becomes the last queued file if loop is
True. If loop is False, then the last queued file is set to None.
If tight is True, then fadeouts will span into the next-queued sound.
"""
if renpy.game.context().init_phase:
raise Exception("Can't play music during init phase.")
if filenames is None:
filenames = [ ]
loop = False
if isinstance(filenames, basestring):
filenames = [ filenames ]
try:
c = get_channel(channel)
ctx = c.context
if loop is None:
loop = c.default_loop
if clear_queue:
c.dequeue(True)
c.enqueue(filenames, loop=loop, fadein=fadein, tight=tight)
t = get_serial()
ctx.last_changed = t
c.last_changed = t
if loop:
ctx.last_filenames = filenames
ctx.last_tight = tight
else:
ctx.last_filenames = [ ]
ctx.last_tight = False
except:
if renpy.config.debug_sound:
raise
示例3: is_music
def is_music(channel):
"""
Returns true if "channel" will loop by default.
"""
c = get_channel(channel)
return c.default_loop
示例4: playable
def playable(filename, channel="music"):
"""
Return true if the given filename is playable on the channel. This
takes into account the prefix and suffix.
"""
c = get_channel(channel)
return renpy.loader.loadable(c.file_prefix + filename + c.file_suffix)
示例5: set_music
def set_music(channel, flag, default=False):
"""
Determines if channel will loop by default.
"""
c = get_channel(channel)
if default and c.default_loop_set:
return
c.default_loop = flag
c.default_loop_set = True
示例6: playable
def playable(filename, channel="music"):
"""
Return true if the given filename is playable on the channel. This
takes into account the prefix and suffix, and ignores a preceding
specifier.
"""
c = get_channel(channel)
filename, _, _ = c.split_filename(filename, False)
return renpy.loader.loadable(c.file_prefix + filename + c.file_suffix)
示例7: stop
def stop(channel="music", fadeout=None):
"""
:doc: audio
This stops the music that is currently playing, and dequeues all
queued music. If fadeout is None, the music is faded out for the
time given in config.fade_music, otherwise it is faded for fadeout
seconds.
This sets the last queued file to None.
`channel`
The channel to stop the sound on.
`fadeout`
If not None, this is a time in seconds to fade for. Otherwise the
fadeout time is taken from config.fade_music.
"""
if renpy.game.context().init_phase:
return
with renpy.audio.audio.lock:
try:
c = get_channel(channel)
ctx = c.context
if fadeout is None:
fadeout = renpy.config.fade_music
c.fadeout(fadeout)
t = get_serial()
ctx.last_changed = t
c.last_changed = t
ctx.last_filenames = [ ]
ctx.last_tight = False
except:
if renpy.config.debug_sound:
raise
示例8: play
def play(filenames, channel="music", loop=None, fadeout=None, synchro_start=False, fadein=0, tight=None, if_changed=False):
"""
This stops the music currently playing on the numbered channel, dequeues
any queued music, and begins playing the specified file or files. If loop
is True, the tracks will loop while they are the last thing in
the queue. If fadeout is None, the fadeout time is taken from
config.fade_music, otherwise it is a time in seconds to fade for.
Filenames may be a single file, or a list of files.
Fadein is the number of seconds to fade the music in for, on the
first loop only.
If synchro_start is given, all the channels that have had play
called on them with synchro_start set to True will be started at
the same time, in a sample accurate manner.
The filenames given becomes the last queued files if loop is
True. If loop is False, then there are no last queued files.
If tight is True, then fadeouts will span into the next-queued sound.
If if_changed is True, and the music file is currently playing,
then it will not be stopped/faded out and faded back in again, but
instead will be kept playing. (This will always queue up an additional
loop of the music.)
"""
if renpy.game.context().init_phase:
raise Exception("Can't play music during init phase.")
if filenames is None:
filenames = [ ]
loop = False
if isinstance(filenames, basestring):
filenames = [ filenames ]
try:
c = get_channel(channel)
ctx = c.context
if loop is None:
loop = c.default_loop
c.dequeue()
if fadeout is None:
fadeout = renpy.config.fade_music
if if_changed and c.get_playing() in filenames:
fadein = 0
else:
c.fadeout(fadeout)
c.enqueue(filenames, loop=loop, synchro_start=synchro_start, fadein=fadein, tight=tight)
t = get_serial()
ctx.last_changed = t
c.last_changed = t
if loop:
ctx.last_filenames = filenames
ctx.last_tight = tight
else:
ctx.last_filenames = [ ]
ctx.last_tight = False
except:
if renpy.config.debug_sound:
raise
示例9: play
def play(filenames, channel="music", loop=None, fadeout=None, synchro_start=False, fadein=0, tight=None, if_changed=False):
"""
:doc: audio
This stops the music currently playing on the numbered channel, dequeues
any queued music, and begins playing the specified file or files.
`filenames`
This may be a single file, or a list of files to be played.
`channel`
The channel to play the sound on.
`loop`
If this is True, the tracks will loop while they are the last thing
in the queue.
`fadeout`
If not None, this is a time in seconds to fade for. Otherwise the
fadeout time is taken from config.fade_music.
`synchro_start`
Ren'Py will ensure that all channels of with synchro_start set to true
will start playing at exactly the same time. Synchro_start should be
true when playing two audio files that are meant to be synchronized
with each other.
`fadein`
This is the number of seconds to fade the music in for, on the
first loop only.
`tight`
If this is True, then fadeouts will span into the next-queued sound.
`if_changed`
If this is True, and the music file is currently playing,
then it will not be stopped/faded out and faded back in again, but
instead will be kept playing. (This will always queue up an additional
loop of the music.)
"""
if renpy.game.context().init_phase:
raise Exception("Can't play music during init phase.")
if filenames is None:
return
if isinstance(filenames, basestring):
filenames = [ filenames ]
try:
c = get_channel(channel)
ctx = c.context
if loop is None:
loop = c.default_loop
c.dequeue()
if fadeout is None:
fadeout = renpy.config.fade_music
if if_changed and c.get_playing() in filenames:
fadein = 0
else:
c.fadeout(fadeout)
c.enqueue(filenames, loop=loop, synchro_start=synchro_start, fadein=fadein, tight=tight)
t = get_serial()
ctx.last_changed = t
c.last_changed = t
if loop:
ctx.last_filenames = filenames
ctx.last_tight = tight
else:
ctx.last_filenames = [ ]
ctx.last_tight = False
except:
if renpy.config.debug_sound:
raise
示例10: queue
def queue(filenames, channel="music", loop=None, clear_queue=True, fadein=0, tight=None):
"""
:doc: audio
This queues the given filenames on the specified channel.
`filenames`
This may be a single file, or a list of files to be played.
`channel`
The channel to play the sound on.
`loop`
If this is True, the tracks will loop while they are the last thing
in the queue.
`clear_queue`
If True, then the queue is cleared, making these files the files that
are played when the currently playing file finishes. If it is False,
then these files are placed at the back of the queue. In either case,
if no music is playing these files begin playing immediately.
`fadein`
This is the number of seconds to fade the music in for, on the
first loop only.
`tight`
If this is True, then fadeouts will span into the next-queued sound. If
None, this is true when loop is True, and false otherwise.
This clears the pause flag for `channel`.
"""
if renpy.game.context().init_phase:
raise Exception("Can't play music during init phase.")
if filenames is None:
filenames = [ ]
loop = False
if isinstance(filenames, basestring):
filenames = [ filenames ]
with renpy.audio.audio.lock:
try:
c = get_channel(channel)
ctx = c.context
if loop is None:
loop = c.default_loop
if (tight is None) and renpy.config.tight_loop_default:
tight = loop
if clear_queue:
c.dequeue(True)
c.enqueue(filenames, loop=loop, fadein=fadein, tight=tight)
t = get_serial()
ctx.last_changed = t
c.last_changed = t
if loop:
ctx.last_filenames = filenames
ctx.last_tight = tight
else:
ctx.last_filenames = [ ]
ctx.last_tight = False
ctx.pause = False
except:
if renpy.config.debug_sound:
raise