source: trunk/src/testing/include/sageAudioModule.h @ 4

Revision 4, 4.6 KB checked in by ajaworski, 13 years ago (diff)

Added modified SAGE sources

Line 
1/******************************************************************************
2 * SAGE - Scalable Adaptive Graphics Environment
3 *
4 * Module: sageAudioModule.h
5 * Author : Hyejung Hur
6 *
7 * Copyright (C) 2004 Electronic Visualization Laboratory,
8 * University of Illinois at Chicago
9 *
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions are met:
14 *
15 *  * Redistributions of source code must retain the above copyright
16 *    notice, this list of conditions and the following disclaimer.
17 *  * Redistributions in binary form must reproduce the above
18 *    copyright notice, this list of conditions and the following disclaimer
19 *    in the documentation and/or other materials provided with the distribution.
20 *  * Neither the name of the University of Illinois at Chicago nor
21 *    the names of its contributors may be used to endorse or promote
22 *    products derived from this software without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
28 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
29 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
30 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
31 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
32 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
33 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 *
36 * Direct questions, comments etc about SAGE to sage_users@listserv.uic.edu or
37 * http://www.evl.uic.edu/cavern/forum/
38 *
39 ***************************************************************************************************************************/
40
41#ifndef _SAGE_AUDIO_MODULE_H
42#define _SAGE_AUDIO_MODULE_H
43
44#include <vector>
45
46#include "sageBase.h"
47#include "sageAudioCircBuf.h"
48#include "audioFileReader.h"
49#include "audioFileWriter.h"
50#include "audioFormatManager.h"
51
52class sailConfig;
53class sageAudio;
54
55/**
56 * class sageAudioConfig
57 */
58class sageAudioConfig {
59public:
60   int  deviceNum;
61   sageSampleFmt sampleFmt;
62   long samplingRate;
63   int  channels;
64   int  framePerBuffer;
65   sageAudioMode audioMode;
66
67   sageAudioConfig() : deviceNum(-1), sampleFmt(SAGE_SAMPLE_FLOAT32), samplingRate(44100), channels(2), framePerBuffer(1024), audioMode(SAGE_AUDIO_CAPTURE) {}
68   ~sageAudioConfig() { }
69};
70
71
72/**
73 * \brief one instance per sageAudioManager
74 */
75class sageAudioModule {
76public:
77   /** this class is singleton
78   */
79   static sageAudioModule* _instance;
80
81   /** create instance and assign it to _instance
82   */
83   static sageAudioModule* instance();
84
85   /** sets parameters for audio configuration
86   * will call init() after setting parameters
87   */
88   void init(sailConfig &conf);
89   virtual void init(sageAudioConfig &conf);
90   void updateConfig(sageAudioConfig &conf);
91
92   sageAudioCircBuf* load(char* filename, bool loop, int nframes, long totalframes=0);
93   int save(char* filename);
94
95   /** open audio stream and play
96   */
97   int play(int id);
98
99   int pause(int id);
100   int stop(int id);
101
102   /**
103    * sageAudio is instantiated in here
104    */
105   sageAudioCircBuf* createObject(sageAudioConfig &conf, int instID =-1);
106   // temporaly....
107   sageAudioCircBuf* createObject(int instID =-1);
108   int deleteObject(int id);
109
110   sageAudioCircBuf* createBuffer(int instID=-1);
111   sageAudioCircBuf* createBuffer(sageAudioConfig &conf, int size=64, int instID=-1);
112
113   /** test audio input/output device
114   */
115   void testDevices();
116
117   ~sageAudioModule();
118
119   void setgFrameNum(long frames);
120   long getgFrameNum();
121
122   std::vector<sageAudioCircBuf*>& getBufferList(void);
123        sageAudioConfig* getAudioConfig();
124
125protected:
126        /**
127         * initialize() of PortAudio lib is called
128         */
129   sageAudioModule();
130
131   /** create audio and create circular buffer for saving audio block.
132    * New audioFormatManager, audioFileReader, and audioFileWriter objects are generated.
133   */
134   void init();
135
136protected:
137   /** audio pointer
138   */
139   //sageAudio* audio;
140   std::vector<sageAudio*> audioList;
141
142   /** audio circular buffer list
143   */
144   std::vector<sageAudioCircBuf*> bufferList;
145
146   /** audio configuration
147   */
148   sageAudioConfig config;
149
150   audioFileReader* fileReader;
151   audioFileWriter* fileWriter;
152   audioFormatManager* formatManager;
153
154   long gFrameNum;
155
156};
157
158#endif
Note: See TracBrowser for help on using the repository browser.