BPython:
- Blender.Window: added function GetPerspMatrix() (Tom Musgrave's patch, thanks);
- added Chris Want's patch to tell argc, argv to the Python interpreter (thanks, Hos);
- Blender.Image: added image.glFree() to free textures bound by the recently added
image.glLoad() (both suggested by Campbell Barton -- thanks, with these Blender can
be used to load textures for scripts);
- Blender.Sound: removed for now at least a few get/set methods of vars that can't be
accessed via interface;
- renamed Get/makeActive to Get/setCurrent in Blender.World (actually added alias for
now), same in Blender.Sound: renamed makeActive to setCurrent. Stephen Swaney
pointed this some weeks ago, we should stick to one naming convention.
- added documentation for Sound and Window.Theme modules and the other added
functions, made other small updates.
- Blender.Object: made 'worldspace' become the default output of .getMatrix and .mat/.matrix:
after reading a discussion on blender.org's Python forum where eeshlo mentioned the
pre 2.34 default was worldspace, I took a better look at Blender's relevant code,
confirmed, talked to Theeth about this and as he suggested am changing the default
back to 'worldspace'.
2004-10-20 05:51:24 +00:00
|
|
|
# Blender.Sound module and the Sound PyType object
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
The Blender.Sound submodule.
|
|
|
|
|
|
|
|
|
|
Sound
|
|
|
|
|
=====
|
|
|
|
|
|
|
|
|
|
This module provides access to B{Sound} objects in Blender.
|
|
|
|
|
|
|
|
|
|
Example::
|
2007-02-27 10:23:24 +00:00
|
|
|
import Blender
|
|
|
|
|
from Blender import Sound
|
|
|
|
|
#
|
|
|
|
|
sound = Sound.Load("/path/to/my/sound.wav") # load a sound file
|
|
|
|
|
print "Sound from", sound.filename,
|
|
|
|
|
print "loaded to obj", sound.name
|
|
|
|
|
print "All Sounds available now:", Sound.Get()
|
2005-09-14 11:04:13 +00:00
|
|
|
|
|
|
|
|
No way to get the actual audio data is provided by this library,
|
|
|
|
|
but it is included in the Python standard library (module audioop).
|
|
|
|
|
Note that using that module requires a full/normal Python installation.
|
BPython:
- Blender.Window: added function GetPerspMatrix() (Tom Musgrave's patch, thanks);
- added Chris Want's patch to tell argc, argv to the Python interpreter (thanks, Hos);
- Blender.Image: added image.glFree() to free textures bound by the recently added
image.glLoad() (both suggested by Campbell Barton -- thanks, with these Blender can
be used to load textures for scripts);
- Blender.Sound: removed for now at least a few get/set methods of vars that can't be
accessed via interface;
- renamed Get/makeActive to Get/setCurrent in Blender.World (actually added alias for
now), same in Blender.Sound: renamed makeActive to setCurrent. Stephen Swaney
pointed this some weeks ago, we should stick to one naming convention.
- added documentation for Sound and Window.Theme modules and the other added
functions, made other small updates.
- Blender.Object: made 'worldspace' become the default output of .getMatrix and .mat/.matrix:
after reading a discussion on blender.org's Python forum where eeshlo mentioned the
pre 2.34 default was worldspace, I took a better look at Blender's relevant code,
confirmed, talked to Theeth about this and as he suggested am changing the default
back to 'worldspace'.
2004-10-20 05:51:24 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
def Load (filename):
|
2007-02-27 10:23:24 +00:00
|
|
|
"""
|
|
|
|
|
Load the sound called 'filename' into a Sound object.
|
|
|
|
|
@type filename: string
|
|
|
|
|
@param filename: The full path to the sound file.
|
|
|
|
|
@rtype: Blender Sound
|
|
|
|
|
@return: A Blender Sound object with the data from I{filename}.
|
|
|
|
|
"""
|
BPython:
- Blender.Window: added function GetPerspMatrix() (Tom Musgrave's patch, thanks);
- added Chris Want's patch to tell argc, argv to the Python interpreter (thanks, Hos);
- Blender.Image: added image.glFree() to free textures bound by the recently added
image.glLoad() (both suggested by Campbell Barton -- thanks, with these Blender can
be used to load textures for scripts);
- Blender.Sound: removed for now at least a few get/set methods of vars that can't be
accessed via interface;
- renamed Get/makeActive to Get/setCurrent in Blender.World (actually added alias for
now), same in Blender.Sound: renamed makeActive to setCurrent. Stephen Swaney
pointed this some weeks ago, we should stick to one naming convention.
- added documentation for Sound and Window.Theme modules and the other added
functions, made other small updates.
- Blender.Object: made 'worldspace' become the default output of .getMatrix and .mat/.matrix:
after reading a discussion on blender.org's Python forum where eeshlo mentioned the
pre 2.34 default was worldspace, I took a better look at Blender's relevant code,
confirmed, talked to Theeth about this and as he suggested am changing the default
back to 'worldspace'.
2004-10-20 05:51:24 +00:00
|
|
|
|
|
|
|
|
def Get (name = None):
|
2007-02-27 10:23:24 +00:00
|
|
|
"""
|
|
|
|
|
Get the Sound object(s) from Blender.
|
|
|
|
|
@type name: string
|
|
|
|
|
@param name: The name of the Sound object.
|
|
|
|
|
@rtype: Blender Sound or a list of Blender Sounds
|
|
|
|
|
@return: It depends on the I{name} parameter:
|
|
|
|
|
- (name): The Sound object called I{name}, None if not found;
|
|
|
|
|
- (): A list with all Sound objects in the current scene.
|
|
|
|
|
"""
|
BPython:
- Blender.Window: added function GetPerspMatrix() (Tom Musgrave's patch, thanks);
- added Chris Want's patch to tell argc, argv to the Python interpreter (thanks, Hos);
- Blender.Image: added image.glFree() to free textures bound by the recently added
image.glLoad() (both suggested by Campbell Barton -- thanks, with these Blender can
be used to load textures for scripts);
- Blender.Sound: removed for now at least a few get/set methods of vars that can't be
accessed via interface;
- renamed Get/makeActive to Get/setCurrent in Blender.World (actually added alias for
now), same in Blender.Sound: renamed makeActive to setCurrent. Stephen Swaney
pointed this some weeks ago, we should stick to one naming convention.
- added documentation for Sound and Window.Theme modules and the other added
functions, made other small updates.
- Blender.Object: made 'worldspace' become the default output of .getMatrix and .mat/.matrix:
after reading a discussion on blender.org's Python forum where eeshlo mentioned the
pre 2.34 default was worldspace, I took a better look at Blender's relevant code,
confirmed, talked to Theeth about this and as he suggested am changing the default
back to 'worldspace'.
2004-10-20 05:51:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class Sound:
|
2007-02-27 10:23:24 +00:00
|
|
|
"""
|
|
|
|
|
The Sound object
|
|
|
|
|
================
|
|
|
|
|
This object gives access to Sounds in Blender.
|
|
|
|
|
@ivar filename: The filename (path) to the sound file loaded into this Sound
|
|
|
|
|
@ivar packed: Boolean, True when the sample is packed (readonly).
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
def getName():
|
|
|
|
|
"""
|
|
|
|
|
Get the name of this Sound object.
|
|
|
|
|
@rtype: string
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
def getFilename():
|
|
|
|
|
"""
|
|
|
|
|
Get the filename of the sound file loaded into this Sound object.
|
|
|
|
|
@rtype: string
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
def setName():
|
|
|
|
|
"""
|
|
|
|
|
Set the name of this Sound object.
|
|
|
|
|
@rtype: None
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
def setFilename():
|
|
|
|
|
"""
|
|
|
|
|
Set the filename of the sound file loaded into this Sound object.
|
|
|
|
|
@rtype: None
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
def setCurrent():
|
|
|
|
|
"""
|
|
|
|
|
Make this the active sound in the sound buttons window (also redraws).
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
def play():
|
|
|
|
|
"""
|
|
|
|
|
Play this sound.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
def getVolume():
|
|
|
|
|
"""
|
|
|
|
|
Get this sound's volume.
|
|
|
|
|
rtype: float
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
def setVolume(f):
|
|
|
|
|
"""
|
|
|
|
|
Set this sound's volume.
|
|
|
|
|
@type f: float
|
|
|
|
|
@param f: the new volume value in the range [0.0, 1.0].
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
def getAttenuation():
|
|
|
|
|
"""
|
|
|
|
|
Get this sound's attenuation value.
|
|
|
|
|
rtype: float
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
def setAttenuation(f):
|
|
|
|
|
"""
|
|
|
|
|
Set this sound's attenuation.
|
|
|
|
|
@type f: float
|
|
|
|
|
@param f: the new attenuation value in the range [0.0, 5.0].
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
def getPitch():
|
|
|
|
|
"""
|
|
|
|
|
Get this sound's pitch value.
|
|
|
|
|
rtype: float
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
def setPitch(f):
|
|
|
|
|
"""
|
|
|
|
|
Set this sound's pitch.
|
|
|
|
|
@type f: float
|
|
|
|
|
@param f: the new pitch value in the range [-12.0, 12.0].
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
def pack():
|
|
|
|
|
"""
|
|
|
|
|
Packs the sound into the current blend file.
|
|
|
|
|
@note: An error will be raised if the sound is already packed or the filename path does not exist.
|
|
|
|
|
@returns: nothing
|
|
|
|
|
@rtype: none
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
def unpack(mode):
|
|
|
|
|
"""
|
|
|
|
|
Unpacks the sound to the samples filename.
|
|
|
|
|
@param mode: One of the values in Blender.Unpackmodes dict.
|
|
|
|
|
@note: An error will be raised if the sound is not packed or the filename path does not exist.
|
|
|
|
|
@returns: nothing
|
|
|
|
|
@rtype: none
|
|
|
|
|
@type mode: int
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
import id_generics
|
|
|
|
|
Sound.__doc__ += id_generics.attributes
|