Exemple #1
0
# along with Pyospat.  If not, see <http://www.gnu.org/licenses/>.
"""
The SoundSource class
"""
from pyospat import introspection
from pyospat import logger
from pyospat import maths
from pyospat import plugins
from types import ModuleType
import os
import sys
import pyo

#from pyospat.plugins import SimpleSin

log = logger.start(name="sound_source", level="info")

class SoundSource(object):
    """
    A sound source node in the renderer
    """
    def __init__(self, outs):
        """
        @param outs: number of outputs
        @type outs: int
        """
        log.debug("instantiating a soundsource... ")
        self._source = None
        self._is_connected_to_listener = False
        self._number_of_outputs = outs
        self._uri = None
Exemple #2
0
# (at your option) any later version.
#
# Pyospat is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Pyospat.  If not, see <http://www.gnu.org/licenses/>.

from txosc import async
from txosc import dispatch
from twisted.internet import reactor
from pyospat import logger

log = logger.start(name="oscinterface", level="info")
    
def _type_tags_match(message, expected, verbose=False):
    """
    Checks that some typetags string matches the expected.
    """
    log.debug("type tags are: %s" % (message.getTypeTags()))
    if message.getTypeTags() == expected:
        return True
    else:
        if verbose:
            log.info("Bad type tags for message %s. Expected %s" % (message, expected))
        return False

def get_connection_id(message):
    """
Exemple #3
0
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Pyospat.  If not, see <http://www.gnu.org/licenses/>.

"""
The ServerWrapper and PrefParser classes.
"""
import pyo
import time
import os
from pyospat import logger
from xml.dom import minidom

log = logger.start(name="pyoserver")

def list_devices():
    pyo.pa_list_devices()

class PrefParser(object):
    """
    Parses ~/.pyorc and provides kwargs for pyo.Server
    """
    def __init__(self, file_name=None):
        """
        throws IOError if file is not found.
        """
        if file_name is None:
            file_name = os.path.expanduser("~/.pyorc")
        self._file_name = file_name
Exemple #4
0
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Pyospat.  If not, see <http://www.gnu.org/licenses/>.

"""
The Application class.
"""
from pyospat import renderer
from pyospat import speakerlayouts as layouts
from pyospat import logger
from pyospat import oscinterface as OSC
import math

log = logger.start(name="application", level="debug")


class Application(object):
    """
    Main class of this application.
    """

    def __init__(self, configuration):
        """
        @param configuration: Instance of a Configuration.
        """
        self._configuration = configuration
        log.debug("*** starting with configuration:")
        log.debug(self._configuration)
        self._speakers_angles = [[-math.pi / 4.0, 0.0, 1.0], [math.pi / 4.0, 0.0, 1.0]]  # each speaker has an aed
Exemple #5
0
# Pyospat is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Pyospat.  If not, see <http://www.gnu.org/licenses/>.
"""
PyoObjects introspection.
"""

import pyo
from pyospat import logger
#from pyospat import plugins

log = logger.start(name="introspection", level="debug")

def has_class(name):
    """
    @rtype: bool
    """
    if pyo.__dict__.has_key(name):
        klass = pyo.__dict__[name]
        return issubclass(klass, pyo.PyoObject)
    else:
        return False

def get_class(name):
    """
    @rtype: pyo object
    """
Exemple #6
0
#!/usr/bin/env python
# encoding: utf-8
"""
A copy of the Sine class for testing purposes.

"""
#import math
from pyo import *
from pyospat import logger

log = logger.start(name="plugins")

log.debug("plugins module imported")

class Sine2(PyoObject):
    """
    A simple sine wave oscillator.
    
    Parentclass: PyoObject
    
    Parameters:
    
    freq : float or PyoObject, optional
        Frequency in cycles per second. Defaults to 1000.
    phase : float or PyoObject, optional
        Phase of sampling, expressed as a fraction of a cycle (0 to 1).
        Defaults to 0.
        
    Methods:
    
    setFreq(x) : Replace the `freq` attribute.
Exemple #7
0
from pyo import *
from pyospat import logger

log = logger.start(name="SimpleSin")

class SimpleSin(PyoObject):
    """
    A simple sine wave oscillator.
    
    Parentclass: PyoObject
    
    Parameters:
    
    freq : float or PyoObject, optional
        Frequency in cycles per second. Defaults to 1000.
    phase : float or PyoObject, optional
        Phase of sampling, expressed as a fraction of a cycle (0 to 1).
        Defaults to 0.
        
    Methods:
    
    setFreq(x) : Replace the `freq` attribute.
    setPhase(x) : Replace the `phase` attribute.
    reset() : Resets the reading pointer to 0.
    
    Attributes:
    
    freq : float or PyoObject, Frequency in cycles per second.
    phase : float or PyoObject, Phase of sampling (0 -> 1).
    
    See also: Sine, Osc, Phasor
Exemple #8
0
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# Pyospat is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Pyospat.  If not, see <http://www.gnu.org/licenses/>.

from pyospat import sound_source
from pyospat import introspection
from pyospat import logger

log = logger.start(name="renderer", level="info")

PROPERTY_SPREAD = "setSpread"

class Renderer(object):
    """
    Actually renders audio.
    """
    def __init__(self, listener_id, speakers_angles):
        # speakers coordinates:
        self._speakers_angles = speakers_angles
        # ID
        self._listener_id = listener_id
        log.debug("New renderer instance with listener %s" % (self._listener_id))
        # sources:
        self._sources = {}
Exemple #9
0
def start_logging(level="debug"):
    global log
    print("setting level to {0}".format(level))
    log = logger.start(level=level)