def __init__(self, device, latency=None, buffer_size=None): """Create a MIDI output. Parameters ---------- device : int or str id or name of the MIDI device latency : int, optional delay in ms applied to timestamp buffer_size : int, optional number of events to be buffered """ import types if type(_midi) is not types.ModuleType: raise ImportError("""Sorry, MIDI output is not supported on this computer.""") if not expyriment._active_exp.is_initialized: raise RuntimeError( "Cannot create MidiOut before expyriment.initialize()!") _midi.init() Output.__init__(self) self._id = device if buffer_size is None: buffer_size = defaults.midiout_buffer_size self._buffer_size = buffer_size if latency is None: latency = defaults.midiout_latency self._latency = latency self.output = _midi.Output(device, latency, buffer_size)
def __init__(self, host, port, timeout=2000, connect=True): """Create a TurbosatoriNetworkInterface. Parameters: ----------- host : str The hostname or IPv4 address of the TBV server to connect to. port : int The port on the Turbo-Satori server to connect to. timeout : int, optional The maximal time to wait for a response from the server for each request (default=2000). connect : bool, optional If True, connect immediately (default=True). """ Input.__init__(self) Output.__init__(self) self._host = host self._port = port self._is_connected = False self._turbosatori_plugin_version = None self._tcp = TcpClient(host, port, None, False) self._timeout = timeout if connect: self.connect()
def __init__(self, host, port, default_package_size=1024, connect=True): """Create a TcpClient. Parameters: ----------- host : str The hostname or IPv4 address of the server to connect to. port : int The port to connect to. default_package_size : int, optional The default size of the packages to be received (default=1024). connect : bool, optional If True, connect immediately (default=True). """ Input.__init__(self) Output.__init__(self) self._host = host self._port = port self._default_package_size = default_package_size self._socket = None self._is_connected = False if connect: self.connect()
def __init__(self, device, latency=0, buffer_size=1024): """Create a MIDI output. Parameters ---------- device : int or str id or name of the MIDI device latency : int, optional delay in ms applied to timestamp (default=0) buffer_size : int, optional number of events to be buffered (default=1024) """ if not isinstance(_midi,ModuleType): raise ImportError("""Sorry, MIDI output is not supported on this computer.""") if not _internals.active_exp.is_initialized: raise RuntimeError( "Cannot create MidiOut before expyriment.initialize()!") _midi.init() Output.__init__(self) self._id = device self._buffer_size = buffer_size self._latency = latency self.output = _midi.Output(device, latency, buffer_size)
def __init__(self, port=0): """Create a parallel port input and output. Parameters: ----------- port : int, optional The port to use (default=0). """ if not isinstance(parallel, ModuleType): message = """SimpleParallelPort can not be initialized. The Python package 'pyParallel' is not installed.""" raise ImportError(message) if float(parallel.VERSION) < 0.2: raise ImportError("Expyriment {0} ".format(__version__) + "is not compatible with PyParallel {0}.".format( parallel.VERSION) + "\nPlease install PyParallel 0.2 or higher.") Input.__init__(self) Output.__init__(self) self._port = port self._parallel = parallel.Parallel(self._port) self.input_history = False # dummy
def __init__(self, port, default_package_size=None, start_listening=True): """Create a TcpServer. Parameters: ----------- port : int The port to connect to. default_package_size : int, optional The default size of the packages to be received. start_listening : bool If True, start listening on port immediately. """ Input.__init__(self) Output.__init__(self) self._port = port if default_package_size is None: default_package_size = defaults.tcpserver_default_package_size self._default_package_size = default_package_size self._socket = None self._is_connected = False if start_listening is None: start_listening = defaults.tcpserver_start_listening if start_listening: self.listen()
def __init__(self, host, port, default_package_size=None, connect=None): """Create a TcpClient and connect to it. Parameters: ----------- host : str The hostname or IPv4 address of the server to connect to. port : int The port to connect to. default_package_size : int The default size of the packages to be received. connect : bool, optional If True, connect immediately. """ Input.__init__(self) Output.__init__(self) self._host = host self._port = port if default_package_size is None: default_package_size = defaults.tcpclient_default_package_size self._default_package_size = default_package_size self._socket = None self._is_connected = False if connect is None: connect = defaults.tcpclient_connect if connect: self.connect()
def __init__(self, host, port, timeout=None, connect=None): """Create a TbvNetworkInterface. Parameters: ----------- host : str The hostname or IPv4 address of the TBV server to connect to. port : int The port on the TBV server to connect to. timeout : int, optional The maximal time to wait for a response from the server for each request. connect : bool, optional If True, connect immediately. """ Input.__init__(self) Output.__init__(self) self._host = host self._port = port self._is_connected = False self._tbv_plugin_version = None self._tcp = TcpClient(host, port, None, False) if timeout is None: timeout = defaults.tbvnetworkinterface_timeout self._timeout = timeout if connect is None: connect = defaults.tbvnetworkinterface_connect if connect: self.connect()
def __init__(self, device, latency=None, buffer_size=None): """Create a MIDI output. Parameters ---------- device : int or str id or name of the MIDI device latency : int, optional delay in ms applied to timestamp buffer_size : int, optional number of events to be buffered """ import types if type(_midi) is not types.ModuleType: raise ImportError( """Sorry, MIDI output is not supported on this computer.""") if not expyriment._active_exp.is_initialized: raise RuntimeError( "Cannot create MidiOut before expyriment.initialize()!") _midi.init() Output.__init__(self) self._id = device if buffer_size is None: buffer_size = defaults.midiout_buffer_size self._buffer_size = buffer_size if latency is None: latency = defaults.midiout_latency self._latency = latency self.output = _midi.Output(device, latency, buffer_size)
def __init__(self, device, latency=0, buffer_size=1024): """Create a MIDI output. Parameters ---------- device : int or str id or name of the MIDI device latency : int, optional delay in ms applied to timestamp (default=0) buffer_size : int, optional number of events to be buffered (default=1024) """ if not isinstance(_midi, ModuleType): raise ImportError( """Sorry, MIDI output is not supported on this computer.""") if not _internals.active_exp.is_initialized: raise RuntimeError( "Cannot create MidiOut before expyriment.initialize()!") _midi.init() Output.__init__(self) self._id = device self._buffer_size = buffer_size self._latency = latency self.output = _midi.Output(device, latency, buffer_size)
def __init__(self, address, reverse=False): """Create a parallel port input and output. Parameters ---------- address : hex or str The address of the port to use. reverse : bool Whether the port should be in reverse mode (default=False). Reverse mode enables to read from the data pins. Notes ----- On Windows, common port addresses are:: LPT1 = 0x0378 or 0x03BC LPT2 = 0x0278 or 0x0378 LPT3 = 0x0278 On Linux, port addresses are in the following format:: /dev/parport0 """ import types if type(_ParallelPort) is types.NoneType: if sys.platform == "win32": _message = "Please install one of the following parallel port " + \ "drivers: 'input32' (http://www.highrez.co.uk/Downloads/InpOut32/) or " + \ "'dlportio' (http://real.kiev.ua/2010/11/29/dlportio-and-32-bit-windows/)." elif sys.platform.startswith("linux"): _message = "Please install the Python package 'PyParallel'." else: _message = "Not available on your computer." message = "ParallelPort can not be initialized! {0}".format( _message) raise ImportError(message) Input.__init__(self) Output.__init__(self) if isinstance(address, basestring) and address.startswith('0x'): address = int(address, 16) self._address = address try: self._parallel = _ParallelPort(address=address) except: raise RuntimeError( "Could not initiate parallel port at {0}".format(address)) self.input_history = False # dummy self._reverse = reverse