1 /*(LGPL) 2 --------------------------------------------------------------------------- 3 a_patch.h - Audio Engine "instrument" definitions 4 --------------------------------------------------------------------------- 5 * Copyright (C) 2001, 2002, David Olofson 6 * 7 * This program is free software; you can redistribute it and/or modify it 8 * under the terms of the GNU Lesser General Public License as published by 9 * the Free Software Foundation; either version 2.1 of the License, or (at 10 * your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, but 13 * WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public License 18 * along with this program; if not, write to the Free Software Foundation, 19 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 */ 21 22 #ifndef _A_PATCH_H_ 23 #define _A_PATCH_H_ 24 25 #include "a_globals.h" 26 #include "a_types.h" 27 #include "a_events.h" 28 #include "eel.h" 29 30 /*---------------------------------------------------------- 31 Audio Patch 32 ----------------------------------------------------------*/ 33 struct audio_channel_t; 34 35 typedef struct audio_patch_t 36 { 37 appbank_t param; 38 39 /* 40 * Process input events, update internal state and 41 * generate output events for 'frames' frames. 42 * 43 * IMPORTANT! 44 * The engine may occasionally call this 45 * function with a 0 'frames' argument. This 46 * doesn't mean "do nothing", but rather 47 * "process all events available for the 48 * first frame". (It's used whenever the 49 * engine needs to split for an ACC_PATCH 50 * while there are more events for the 51 * same frame.) 52 */ 53 void (*process)(struct audio_patch_t *p, 54 struct audio_channel_t *c, unsigned frames); 55 56 eel_symbol_t *eel_process; 57 } audio_patch_t; 58 59 60 typedef enum 61 { 62 PES_START = 0, 63 PES_START2, 64 PES_DELAY, 65 PES_ATTACK, 66 PES_HOLD, 67 PES_DECAY, 68 PES_SUSTAIN, 69 PES_WAIT, 70 PES_RELEASE, 71 PES_DEAD 72 } A_patch_env_states; 73 74 /* 75 * Temporary kludge. Something more flexible will probably 76 * be needed, but I'm using this for now, to avoid type 77 * casting void pointers all over the place. (Not an issue 78 * with EEL based patches.) 79 */ 80 typedef struct patch_closure_t 81 { 82 /* Arguments from CE_START */ 83 int velocity; 84 int pitch; /* w/ RANDPITCH, but w/o channel PITCH */ 85 int velvol; /* For envelope */ 86 87 /* Envelope generator state */ 88 A_patch_env_states env_state; 89 int queued_stop; 90 aev_timestamp_t env_next; 91 int lvol, rvol; 92 int lsend, rsend; 93 } patch_closure_t; 94 95 96 void audio_patch_open(void); 97 void audio_patch_close(void); 98 99 #endif /*_A_PATCH_H_*/ 100