1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
|
/**************************************************************************
* Copyright 2009-2015 Olivier Belanger *
* *
* This file is part of pyo, a python module to help digital signal *
* processing script creation. *
* *
* pyo is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* pyo 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 Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with pyo. If not, see <http://www.gnu.org/licenses/>. *
* *
* Octobre 2013 : Multiple servers facility and embedded backend added *
* by Guillaume Barrette. *
* 2014-2016 : Several improvements by Olivier Belanger. *
*************************************************************************/
#ifndef Py_SERVERMODULE_H
#define Py_SERVERMODULE_H
#ifdef __cplusplus
extern "C" {
#endif
#include "sndfile.h"
#include "pyomodule.h"
#ifdef __APPLE__
#include <CoreAudio/AudioHardware.h>
#endif
typedef enum
{
PyoPortaudio = 0,
PyoCoreaudio = 1,
PyoJack,
PyoOffline,
PyoOfflineNB,
PyoEmbedded,
PyoManual
} PyoAudioBackendType;
typedef enum
{
PyoPortmidi = 0,
PyoJackMidi = 1
} PyoMidiBackendType;
/* Portmidi midi message and event type clones. */
typedef long PyoMidiTimestamp;
#define PyoMidi_Message(status, data1, data2) \
((((data2) << 16) & 0xFF0000) | \
(((data1) << 8) & 0xFF00) | \
((status) & 0xFF))
#define PyoMidi_MessageStatus(msg) ((msg) & 0xFF)
#define PyoMidi_MessageData1(msg) (((msg) >> 8) & 0xFF)
#define PyoMidi_MessageData2(msg) (((msg) >> 16) & 0xFF)
typedef long PyoMidiMessage;
typedef struct
{
PyoMidiMessage message;
PyoMidiTimestamp timestamp;
} PyoMidiEvent;
/************************************************/
typedef struct
{
PyObject_HEAD
PyObject *streams;
PyoAudioBackendType audio_be_type;
PyoMidiBackendType midi_be_type;
void *audio_be_data;
void *midi_be_data;
char *serverName; /* Only used for jack client name */
int jackautoin; /* jack port auto-connection (on by default) */
int jackautoout; /* jack port auto-connection (on by default) */
PyObject *jackAutoConnectInputPorts; /* list of lists of jack auto-connection ports to pyo inputs */
PyObject *jackAutoConnectOutputPorts; /* list of lists of jack auto-connection ports from pyo outputs */
PyObject *jackInputPortNames; /* string or list of strings (input port short names for jack server) */
PyObject *jackOutputPortNames; /* string or list of strings (output port short names for jack server) */
PyObject *jackAutoConnectMidiInputPort; /* lists of jack auto-connection ports to pyo midi input */
PyObject *jackAutoConnectMidiOutputPort; /* lists of jack auto-connection ports from pyo midi output */
PyObject *jackMidiInputPortName; /* string (midi input port short names for jack server) */
PyObject *jackMidiOutputPortName; /* string (midi output port short names for jack server) */
int isJackTransportSlave;
int jack_transport_state; /* 0 = stopped, 1 = started */
PyoMidiEvent midiEvents[200];
int midiin_count;
int midiout_count;
int midi_count;
long midi_time_offset;
double samplingRate;
int nchnls;
int ichnls;
int bufferSize;
int currentResampling;
int lastResampling;
int duplex;
int input;
int output;
int input_offset;
int output_offset;
int midi_input;
int midi_output;
int withPortMidi;
int withPortMidiOut;
int withJackMidi;
int midiActive;
int allowMMMapper;
int server_started;
int server_stopped; /* for fadeout */
int server_booted;
int stream_count;
int record;
int thisServerID; /* To keep the reference index in the array of servers */
#ifdef __APPLE__
pthread_mutex_t buf_mutex;
pthread_cond_t buf_cond;
AudioDeviceIOProcID outprocid;
AudioDeviceIOProcID inprocid;
#endif
/* global amplitude */
MYFLT amp;
MYFLT resetAmp;
MYFLT lastAmp;
MYFLT currentAmp;
MYFLT stepVal;
int timeStep;
int timeCount;
MYFLT *input_buffer;
float *output_buffer; /* Has to be float since audio callbacks must use floats */
/* rendering offline of the first "startoffset" seconds */
double startoffset;
/* rendering settings */
double recdur;
char *recpath;
int recformat;
int rectype;
double recquality;
SNDFILE *recfile;
SF_INFO recinfo;
/* GUI VUMETER */
int withGUI;
int numPass;
int gcount;
float *lastRms;
PyObject *GUI;
/* Current time */
unsigned long elapsedSamples; /* time since the server was started */
int withTIME;
int timePass;
int tcount;
PyObject *TIME;
/* custom callback */
PyObject *CALLBACK;
/* Globals dur and del times. */
float globalDur;
float globalDel;
/* Properties */
int verbosity; /* a sum of values to display different levels: 1 = error */
/* 2 = message, 4 = warning , 8 = debug. Default 7.*/
int globalSeed; /* initial seed for random objects. If <= 0, objects are seeded with the clock. */
int autoStartChildren; /* if true, calls to play, out and stop propagate to children objects. */
} Server;
PyObject * PyServer_get_server();
extern unsigned int pyorand();
extern PyObject * Server_removeStream(Server *self, int sid);
extern MYFLT * Server_getInputBuffer(Server *self);
extern PyoMidiEvent * Server_getMidiEventBuffer(Server *self);
extern int Server_getMidiEventCount(Server *self);
extern long Server_getMidiTimeOffset(Server *self);
extern unsigned long Server_getElapsedTime(Server *self);
extern int Server_getCurrentResamplingFactor(Server *self);
extern int Server_getLastResamplingFactor(Server *self);
extern int Server_generateSeed(Server *self, int oid);
extern PyTypeObject ServerType;
void pyoGetMidiEvents(Server *self);
void Server_process_buffers(Server *server);
void Server_error(Server *self, char * format, ...);
void Server_message(Server *self, char * format, ...);
void Server_warning(Server *self, char * format, ...);
void Server_debug(Server *self, char * format, ...);
PyObject * Server_shutdown(Server *self);
PyObject * Server_stop(Server *self);
PyObject * Server_start(Server *self);
PyObject * Server_boot(Server *self, PyObject *arg);
void Server_process_gui(Server *server);
void Server_process_time(Server *server);
int Server_start_rec_internal(Server *self, char *filename);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* Py_SERVERMODULE_H */
|