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

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

Added modified SAGE sources

Line 
1/******************************************************************************
2 * SAGE - Scalable Adaptive Graphics Environment
3 *
4 * Module: audioConverter.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 AUDIO_CONVERTER_H
42#define AUDIO_CONVERTER_H
43
44#include <stdio.h>
45#include "sageBase.h"
46
47class audioConverter {
48public:
49   audioConverter();
50   virtual ~audioConverter();
51
52   virtual int init(FILE* fp);
53
54   /** Returns a tuple (nchannels, sampwidth, framerate, nframes),
55       equivalent to output of the get*() methods ??? */   
56   virtual int readHeader(int& nchan, long& samrate, int& nframes, sageSampleFmt& fmt)=0;
57   virtual int writeHeader(int nchan, long samrate, int nframes, int bits)=0;   
58
59   /** Returns a tuple (nchannels, sampwidth, framerate, nframes),
60       equivalent to output of the get*() methods ??? */
61   int getParams(int& nchan, long& samrate, int& nframes, sageSampleFmt& fmt);
62
63   /** Reads and returns at most n frames of audio, as a string of bytes */
64   virtual int readFrames(void* frames) =0;
65   /** Write n frames of audio, as a string of bytes */
66   virtual int writeFrames(void* frames) =0;   
67
68   /** ewind the file pointer to the beginning of the audio stream */
69   virtual void begin();
70
71   virtual void close()=0;
72   
73protected:
74   FILE* fileID;
75   
76   long formatLength;
77   short formatTag;
78   short channels;
79   long sampleRate;
80   long avgBytesSec;
81   short blockAlign;
82   short bitsPerSample;   
83   long dataSize;
84   
85   int framesPerBuffer;
86   sageSampleFmt sampleFmt;
87   long blockSize;
88   long blockCount;
89   long totalBlocks;
90   
91   fpos_t dataPos;
92   int writeMode;
93};
94
95#endif
Note: See TracBrowser for help on using the repository browser.