home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / arts / artsflow.idl < prev    next >
Encoding:
Text File  |  2005-09-10  |  15.8 KB  |  567 lines

  1.     /*
  2.  
  3.     Copyright (C) 2000 Stefan Westerfeld
  4.                        stefan@space.twc.de
  5.  
  6.     This library is free software; you can redistribute it and/or
  7.     modify it under the terms of the GNU Library General Public
  8.     License as published by the Free Software Foundation; either
  9.     version 2 of the License, or (at your option) any later version.
  10.   
  11.     This library is distributed in the hope that it will be useful,
  12.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14.     Library General Public License for more details.
  15.  
  16.     You should have received a copy of the GNU Library General Public License
  17.     along with this library; see the file COPYING.LIB.  If not, write to
  18.     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19.     Boston, MA 02111-1307, USA.
  20.  
  21.     */
  22.  
  23. /*
  24.  * arts.idl - MCOP port. What's missing currently in MCOP?
  25.  *
  26.  * -   namespaces (module)
  27.  */
  28.  
  29. module Arts {  // analog real time synthesizer
  30.  
  31. enum AutoSuspendState { asNoSuspend, asSuspend, asSuspendStop, asSuspendMask = 0x3,
  32.                         asProducer = 0x10, asConsumer = 0x20, asDirectionMask = 0x30 };
  33.  
  34. /**
  35.  * The SynthModule interface is the base for all modules containing streams.
  36.  *
  37.  * There are two goals achieved by this interface. On one side, there is
  38.  * functionality which users of stream carrying modules want to use (which
  39.  * is: start streaming, stop streaming).
  40.  *
  41.  * On the other hand, there is functionality which the flow system will use
  42.  * to achieve these goals.
  43.  */
  44. interface SynthModule {
  45.     // interface for users of this module
  46.  
  47.     /**
  48.      * This function starts the streaming (e.g. the module will start
  49.      * producing samples) - if you write a module, do not reimplement this,
  50.      * instead reimplement streamInit/streamStart
  51.      */
  52.     void start();
  53.  
  54.     /**
  55.      * This function stops the streaming - if you write a plugin, do not
  56.      * reimplement this, instead reimplement streamEnd
  57.      */
  58.     void stop();
  59.  
  60.     // interface for people implementing modules
  61.  
  62.     /**
  63.      * this is supposed to be the initialization every module passes after
  64.      * all attributes have been set up (e.g. you can see which file to open,
  65.      * how to initialize your filter coefficients or whatever)
  66.      */
  67.     void streamInit();
  68.  
  69.     /**
  70.      * starts the I/O of the module
  71.      */
  72.     void streamStart();
  73.  
  74.     /**
  75.      * stop the thing again, and free data possibly allocated in streamInit
  76.      */
  77.     void streamEnd();
  78.  
  79.     /**
  80.      * If you run a mixer desk (without anything connected), no calculations
  81.      * need to be done - since the output is silent anyway. For this reason,
  82.      * there exists this autosuspend attribute. It allows the flow system
  83.      * to detect the idle condition, and start suspending the calculations,
  84.      * until something "important" happens again.
  85.      *
  86.      * There are three possible values:
  87.      *
  88.      * @li  asNoSuspend - this one is appropriate when you have a module that
  89.      *                    is active by itself
  90.      * @li  asSuspend   - this one is appropriate for modules that "do nothing"
  91.      *                    by themselves
  92.      * @li  asSuspendStop - this one is for modules that should be stopped, when
  93.      *                    the system gets suspended, and restarted when the
  94.      *                    system will start again - an example for this is
  95.      *                    soundcard output
  96.      *
  97.      * A module should choose asSuspend (or asSuspendStop) only if the
  98.      * following conditions are true:
  99.      *
  100.      * @li given constant inputs (like 3.0 on all ports), the module will
  101.      *     give constant output after some time
  102.      * @li given only 0.0 inputs, the module will give only 0.0 outputs
  103.      *     after some time
  104.      * @li the module does not synchronize itself through signal flow (i.e.
  105.      *     a midi sequence which "knows" when a second has passed through
  106.      *     the signal flow breaks when suspension happens)
  107.      * @li the module can't be brought to do something with a method
  108.      *     invocation (i.e. a module which starts generating noise for
  109.      *     a second whenever the noise() method is called is not suspendable)
  110.      * @li the module has no internal state that changes over time when only
  111.      *     constant inputs are given
  112.      *
  113.      * Typical examples for suspendable modules are arithmetic operations,
  114.      * filters, delay/hall/reverb.
  115.      *
  116.      * Typical examples for non-suspendable modules are sequences, midi stuff,
  117.      * oscillators, sample players,...
  118.      *
  119.      * To deal with modules which either input data from some external source
  120.      * (i.e. soundcard input) or output data to some external destination,
  121.      * (i.e. soundcard output) the following flags are available:
  122.      *
  123.      * @li    asProducer  - set this flag for modules which fulfill the conditions
  124.      *                    for a suspendable module, but produce non-zero output
  125.      *                    even when left alone
  126.      * @li    asConsumer  - set this flag for modules which write the data to
  127.      *                    some external destination - that is - definitely
  128.      *                    require constant input to be suspended
  129.      *
  130.      * The suspension algorithm will first divide the graph of modules into
  131.      * subgraphs of interconnected modules. A subgraph is suspendable if
  132.      * all of its modules are suspendable and the subgraph does not contain
  133.      * producer(s) and consumer(s) at the same time.
  134.      *
  135.      * Finally, our module graph is suspendable if all its subgraphs are.
  136.      */
  137.     readonly attribute AutoSuspendState autoSuspend;
  138. };
  139.  
  140. /**
  141.  * Plays a stream of audio data to the soundcard
  142.  */
  143. interface Synth_PLAY : SynthModule {
  144.     // attribute string channels;
  145.     default in audio stream invalue_left,invalue_right;
  146. };
  147.  
  148. /**
  149.  * Records a stream of audio data from the soundcard
  150.  */
  151. interface Synth_RECORD : SynthModule {
  152.     // attribute string channels;
  153.     default out audio stream left,right;
  154. };
  155.  
  156. /**
  157.  * A frequency generator
  158.  *
  159.  * This kind of object is used to create frequencies. Oscillators are connected
  160.  * at the output of this object
  161.  */
  162. interface Synth_FREQUENCY : SynthModule {
  163.     in audio stream frequency;
  164.     out audio stream pos;
  165. };
  166.  
  167. /**
  168.  * A sine wave
  169.  */
  170. interface Synth_WAVE_SIN : SynthModule {
  171.     in audio stream pos;
  172.     out audio stream outvalue;
  173. };
  174.  
  175. /**
  176.  * A module which mixes an arbitary number of audio streams
  177.  */
  178. interface Synth_MULTI_ADD : SynthModule {
  179.     in multi audio stream invalue;
  180.     out audio stream outvalue;
  181. };
  182.  
  183. /**
  184.  * A module which adds two audio streams
  185.  */
  186. interface Synth_ADD : SynthModule {
  187.     default in audio stream invalue1,invalue2;
  188.     out audio stream outvalue;
  189. };
  190.  
  191. /**
  192.  * Multiplies two audio streams
  193.  */
  194. interface Synth_MUL : SynthModule {
  195.     in audio stream invalue1,invalue2;
  196.     out audio stream outvalue;
  197.     default invalue1, invalue2;
  198. };
  199.  
  200. /**
  201.  * This plays a wave file
  202.  */
  203. interface Synth_PLAY_WAV : SynthModule {
  204.     /**
  205.      * How fast should it be played? 1.0 = normal speed
  206.      */
  207.     attribute float speed;
  208.     /**
  209.      * Which file should be played
  210.      */
  211.     attribute string filename;
  212.     /**
  213.      * Is true as soon as the file is finished
  214.      */
  215.     readonly attribute boolean finished;
  216.  
  217.     out audio stream left, right;
  218.     default left, right;
  219. };
  220.  
  221. /**
  222.  * sends data to a bus - busses are dynamic N:M connections - all signals
  223.  * from all uplinks are mixed together, and sent to all downlinks
  224.  */
  225. interface Synth_BUS_UPLINK : SynthModule {
  226.     /**
  227.      * the name of the bus to use
  228.      */
  229.     attribute string busname;
  230.  
  231.     default in audio stream left,right;
  232. };
  233.  
  234. /**
  235.  * receives data from a bus - busses are dynamic N:M connections - all signals
  236.  * from all uplinks are mixed together, and sent to all downlinks
  237.  */
  238. interface Synth_BUS_DOWNLINK : SynthModule {
  239.     /**
  240.      * the name of the bus to use
  241.      */
  242.     attribute string busname;
  243.  
  244.     default out audio stream left,right;
  245. };
  246.  
  247.  
  248. /**
  249.  * Byte stream to audio conversion object
  250.  *
  251.  * Converts an asynchronous byte stream to a synchronous audio stream
  252.  */
  253. interface ByteStreamToAudio : SynthModule {
  254.     attribute long samplingRate;
  255.     attribute long channels;
  256.     attribute long bits;
  257.  
  258.     /**
  259.      * is conversion currently running, or is it stalled due to the fact
  260.      * that there is not enough input input?
  261.      */
  262.     readonly attribute boolean running;
  263.  
  264.     async in byte stream indata;
  265.  
  266.     out audio stream left,right;
  267.     default left;
  268.     default right;
  269. };
  270.  
  271. /**
  272.  * Audio to Byte stream conversion object
  273.  *
  274.  * Converts a synchronous audio stream to an asynchronous byte stream
  275.  */
  276. interface AudioToByteStream : SynthModule {
  277.     attribute long samplingRate;
  278.     attribute long channels;
  279.     attribute long bits;
  280.  
  281.     async out byte stream outdata;
  282.  
  283.     in audio stream left,right;
  284.     default left;
  285.     default right;
  286. };
  287.  
  288. /**
  289.  * Base interface for all stereo effects
  290.  */
  291. interface StereoEffect : SynthModule {
  292.     default in audio stream inleft, inright;
  293.     default out audio stream outleft, outright;
  294. };
  295.  
  296. /**
  297.  * this is a simple clipping stereo volume control
  298.  */
  299. interface StereoVolumeControl : StereoEffect {
  300.     attribute float scaleFactor;
  301.     readonly attribute float currentVolumeLeft;
  302.     readonly attribute float currentVolumeRight;
  303. };
  304.  
  305. /**
  306.  * A funny FFT scope
  307.  */
  308. interface StereoFFTScope : StereoEffect {
  309.     readonly attribute sequence<float> scope;
  310. };
  311.  
  312. /**
  313.  * A stack of stereo effects
  314.  */
  315. interface StereoEffectStack : StereoEffect {
  316.     /**
  317.      * inserts an effect at the top side (= directly after the input)
  318.      *
  319.      * @returns an ID which can be used to remove the effect again
  320.      */
  321.     long insertTop(StereoEffect effect, string name);
  322.  
  323.     /**
  324.      * inserts an effect at the bottom (= close to the output) side
  325.      *
  326.      * @returns an ID which can be used to remove the effect again
  327.      */
  328.     long insertBottom(StereoEffect effect, string name);
  329.  
  330.     /**
  331.      * removes an effect again
  332.      */
  333.     void remove(long ID);
  334. };
  335.  
  336. /*
  337.  * Audio Manager stuff
  338.  */
  339.  
  340. enum AudioManagerDirection { amPlay, amRecord };
  341.  
  342. /**
  343.  * Information structure for audio manager clients
  344.  */
  345. struct AudioManagerInfo {
  346.     long ID;
  347.     string destination;
  348.  
  349.     AudioManagerDirection direction;
  350.     string title, autoRestoreID;
  351. };
  352.  
  353. /**
  354.  * an audio manager client
  355.  */
  356. interface AudioManagerClient {
  357.     readonly attribute long ID;
  358.     attribute AudioManagerDirection direction;
  359.     attribute string title, autoRestoreID;
  360.  
  361.     void constructor(AudioManagerDirection direction, string title,
  362.                      string autoRestoreID);
  363. };
  364.  
  365. /**
  366.  * The audio manager interface
  367.  */
  368. interface AudioManager {
  369.     /**
  370.      * a list of destinations, where you can play/record data to/from
  371.      */
  372.     readonly attribute sequence<string> destinations;
  373.  
  374.     /**
  375.      * a list of clients
  376.      */
  377.     readonly attribute sequence<AudioManagerInfo> clients;
  378.  
  379.     /**
  380.      * this is incremented each time a change is made (i.e. new client attached)
  381.      * TODO: SHOULD GO AWAY WITH ATTRIBUTE WATCHING
  382.      */
  383.     readonly attribute long changes;
  384.  
  385.     /**
  386.      * this is used to route a client to another destination
  387.      */
  388.     void setDestination(long ID, string destination);
  389. };
  390. /**
  391.  * This is a virtual output port, which you use to play data. Where exactly
  392.  * this data gets played is managed by the audiomanager.
  393.  *
  394.  * Creation: there are two ways to initialize a Synth_AMAN_PLAY - one is
  395.  * to set title and autoRestoreID to sensible (non empty) values. The other
  396.  * is to pass an already initialized AudioManagerClient on the constructor.
  397.  */
  398. interface Synth_AMAN_PLAY : SynthModule {
  399.     attribute string title, autoRestoreID;
  400.     void constructor(AudioManagerClient client);
  401.  
  402.     default in audio stream left, right;
  403. };
  404.  
  405. /**
  406.  * This is a virtual input port, which you use to record data. Where this
  407.  * data comes from is in turn managed by the audiomanager.
  408.  *
  409.  * Creation: there are two ways to initialize a Synth_AMAN_RECORD - one is
  410.  * to set title and autoRestoreID to sensible (non empty) values. The other
  411.  * is to pass an already initialized AudioManagerClient on the constructor.
  412.  */
  413. interface Synth_AMAN_RECORD : SynthModule {
  414.     attribute string title, autoRestoreID;
  415.     void constructor(AudioManagerClient client);
  416.  
  417.     default out audio stream left, right;
  418. };
  419.  
  420. /* --------------------------------------------------------------------- */
  421.  
  422. /**
  423.  * Wraps a datahandle. That is an abstraction for a float value array
  424.  * which can be directly loaded data from a file or have some
  425.  * processing stages in between (caching, reversing, cropping...)
  426.  * which are hidden to this interface.
  427.  * In contrast to the underlying C++ API, this datahandle is already
  428.  * open()ed after creation, so you can access its information (like
  429.  * channelCount) without further action.
  430.  * A datahandle normally has one more important function: read() which
  431.  * is not wrapped in MCOP because of the overhead of the data
  432.  * transfer. (If there is need for sth. like that in the future,
  433.  * one could maybe find a solution.)
  434.  */
  435. interface DataHandle {
  436.     readonly attribute long bitDepth;
  437.     readonly attribute long channelCount;
  438.     readonly attribute long valueCount;
  439.     /**
  440.      * error code open() returned
  441.      */
  442.     readonly attribute long errorNo;
  443. };
  444.  
  445. /**
  446.  * Represents a datahandle which delivers the data from the underlying
  447.  * sourceDatahandle in reverse order.
  448.  */
  449. interface ReversedDataHandle : DataHandle {
  450.     void init(DataHandle sourceHandle);
  451. };
  452.  
  453. /**
  454.  * Represents a datahandle which delivers an "inner" part of the data
  455.  * from the underlying sourceDatahandle. You can cut away parts at the
  456.  * start and/or the end with this.
  457.  */
  458. interface CroppedDataHandle : DataHandle {
  459.     void init(DataHandle sourceHandle,
  460.               long headCutValueCount,
  461.               long tailCutValueCount);
  462. };
  463.  
  464. /**
  465.  * Represents a datahandle which delivers the data from the underlying
  466.  * sourceDatahandle without the "inner" part containing the values
  467.  * [cutOffset..cutOffset+cutValueCount-1], which will be cut away.
  468.  */
  469. interface CutDataHandle : DataHandle {
  470.     void init(DataHandle sourceHandle,
  471.               long cutOffset,
  472.               long cutValueCount);
  473. };
  474.  
  475. /**
  476.  * DataHandlePlay uses a gsl_wave_osc to play back data from a
  477.  * DataHandle using sophisticated anti-aliasing filtering and caching
  478.  * techniques. (Though not implemented at the time of writing this, it
  479.  * will be optimized for cases where the anti-aliasing is not needed
  480.  * because the mixerFrequency equals the current soundserver's.)
  481.  */
  482. interface DataHandlePlay : SynthModule {
  483.     /**
  484.      * Which data should be played?
  485.      */
  486.     attribute DataHandle handle;
  487.     /**
  488.      * What is the normal mixer frequency the data from the handle
  489.      * should be played back at? (default: current mixing frequency
  490.      * of the soundserver, e.g. 44100)
  491.      */
  492.     attribute float mixerFrequency;
  493.     /**
  494.      * Which channel of the datahandle should by played?
  495.      * (defaults to 0 = the first channel)
  496.      */
  497.     attribute long channelIndex;
  498.     /**
  499.      * How fast should the data be played?
  500.      * (defaults to 1.0 = normal speed, see mixerFrequency)
  501.      */
  502.     attribute float speed;
  503.     /**
  504.      * Current position while playing, in fact it's the index in the
  505.      * datahandle, so 0 <= pos < handle.valueCount
  506.      */
  507.     attribute long pos;
  508.     /**
  509.      * Is true as soon as the file is finished
  510.      */
  511.     readonly attribute boolean finished;
  512.     /**
  513.      * Can be used to pause and/or continue playing
  514.      */
  515.     attribute boolean paused;
  516.  
  517.     default out audio stream outvalue;
  518.  
  519.     DataHandlePlay clone();
  520. };
  521.  
  522. /**
  523.  * DataHandle which represents sample data loaded from a file. Note
  524.  * that the samples from all channels are interleaved, that is, the
  525.  * samples of the first channel in a stereo file are found at offsets
  526.  * 0,2,4,6,.. etc.
  527.  */
  528. interface WaveDataHandle : DataHandle {
  529.     /**
  530.      * Properties of the loaded sample data. Note that those
  531.      * properties are only available from a WaveDataHandle, but may be
  532.      * available from a DataHandle in the future.
  533.      */
  534.     readonly attribute float mixerFrequency;
  535.     readonly attribute float oscillatorFrequency;
  536.  
  537.     /**
  538.      * Load the first wavechunk from a file and return true on
  539.      * success. A more specific error code is not available at the
  540.      * moment.
  541.      */
  542.     boolean load(string filename);
  543.  
  544.     /**
  545.      * Load a specific wavechunk from a file and return true on
  546.      * success. A more specific error code is not available at the
  547.      * moment.
  548.      */
  549.     boolean load(string filename,
  550.                  long waveIndex, long chunkIndex);
  551.  
  552.     /**
  553.      * Return true if and only if a wavechunk was successfully loaded
  554.      * from a file.
  555.      */
  556.     readonly attribute boolean isLoaded;
  557.  
  558.     /**
  559.      * Creates a DataHandlePlay object with the important attributes
  560.      * handle, mixerFrequency and channelCount already set to play
  561.      * this WaveDataHandle.
  562.      */
  563.     DataHandlePlay createPlayer();
  564. };
  565.  
  566. };
  567.