1 /*
2 MPEG Maaate: An Australian MPEG audio analysis toolkit
3 Copyright (C) 2000 Commonwealth Scientific and Industrial Research Organisation
4 (CSIRO), Australia.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program 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
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21 #include "SOUNDfile.H"
22
23 /* constructors and destructor */
24 CSAPI_TIER1
maaateP_new_soundfile(char * filestr)25 SOUNDfile * maaateP_new_soundfile(char * filestr) {
26 return new SOUNDfile(filestr);
27 }
28
maaateP_destroy(SOUNDfile * sf)29 CSAPI_TIER1 void maaateP_destroy(SOUNDfile * sf) {
30 delete sf;
31 }
32
33 /* about this file */
maaateP_get_filename(SOUNDfile * sf)34 CSAPI_TIER1 char * maaateP_get_filename(SOUNDfile * sf) {
35 return (char *) (sf->file()).c_str();
36 }
37
maaateP_get_filetype(SOUNDfile * sf)38 CSAPI_TIER1 Format maaateP_get_filetype(SOUNDfile * sf) {
39 return sf->file_type();
40 }
41
maaateP_is_stereo(SOUNDfile * sf)42 CSAPI_TIER1 int maaateP_is_stereo(SOUNDfile * sf) {
43 return (int) sf->is_stereo();
44 }
45
maaateP_channels(SOUNDfile * sf)46 CSAPI_TIER1 int maaateP_channels(SOUNDfile * sf) {
47 return sf->channels();
48 }
49
maaateP_samplingrate(SOUNDfile * sf)50 CSAPI_TIER1 double maaateP_samplingrate(SOUNDfile * sf) {
51 return sf->sampling_rate();
52 }
53
54 /* time functions */
maaateP_at_time(SOUNDfile * sf)55 CSAPI_TIER1 float maaateP_at_time(SOUNDfile * sf) {
56 return sf->at_time();
57 }
58
maaateP_file_duration(SOUNDfile * sf)59 CSAPI_TIER1 float maaateP_file_duration(SOUNDfile * sf) {
60 return sf->file_duration();
61 }
62
maaateP_sample_duration(SOUNDfile * sf,Resolution res)63 CSAPI_TIER1 float maaateP_sample_duration(SOUNDfile * sf, Resolution res) {
64 return sf->sample_duration(res);
65 }
66
maaateP_seek_time(SOUNDfile * sf,float t)67 CSAPI_TIER1 int maaateP_seek_time(SOUNDfile * sf, float t ) {
68 return sf->seek_time(t);
69 }
70
maaateP_window_duration(SOUNDfile * sf)71 CSAPI_TIER1 float maaateP_window_duration(SOUNDfile * sf) {
72 return sf->window_duration();
73 }
74
75
76 /* window functions */
maaateP_at_window(SOUNDfile * sf)77 CSAPI_TIER1 long maaateP_at_window(SOUNDfile * sf) {
78 return sf->at_window();
79 }
80
maaateP_file_window_number(SOUNDfile * sf)81 CSAPI_TIER1 long maaateP_file_window_number(SOUNDfile * sf) {
82 return sf->file_window_number();
83 }
84
maaateP_timeticks(SOUNDfile * sf,Resolution res)85 CSAPI_TIER1 unsigned int maaateP_timeticks(SOUNDfile * sf, Resolution res) {
86 return sf->timeticks(res);
87 }
88
maaateP_seek_window(SOUNDfile * sf,long w_nb)89 CSAPI_TIER1 int maaateP_seek_window(SOUNDfile * sf, long w_nb ) {
90 return sf->seek_window(w_nb);
91 }
92
93 /* matching functions */
maaateP_time2window(SOUNDfile * sf,float t)94 CSAPI_TIER1 long maaateP_time2window(SOUNDfile * sf, float t ) {
95 return sf->time2window(t);
96 }
97
maaateP_window2time(SOUNDfile * sf,long w_nb)98 CSAPI_TIER1 float maaateP_window2time(SOUNDfile * sf, long w_nb ) {
99 return sf->window2time(w_nb);
100 }
101
102
103 /* extract and skip */
maaateP_next_window(SOUNDfile * sf,Resolution res)104 CSAPI_TIER1 int maaateP_next_window(SOUNDfile * sf, Resolution res) {
105 return sf->next_window(res);
106 }
107
maaateP_skip_window(SOUNDfile * sf)108 CSAPI_TIER1 int maaateP_skip_window(SOUNDfile * sf) {
109 return sf->skip_window();
110 }
111
112
113 /* access function */
maaateP_freq_value(SOUNDfile * sf,unsigned int ch,unsigned int sb,unsigned int nb,Resolution res)114 CSAPI_TIER1 double maaateP_freq_value(SOUNDfile * sf, unsigned int ch,
115 unsigned int sb, unsigned int nb,
116 Resolution res)
117 {
118 return sf->freq_value(ch,sb,nb,res);
119 }
120
maaateP_nb_subbands(SOUNDfile * sf,Resolution res)121 CSAPI_TIER1 unsigned int maaateP_nb_subbands(SOUNDfile * sf, Resolution res) {
122 return sf->nb_subbands(res);
123 }
124
125 /* Analyse functions */
126
127 //time resolution = 1 subband sample
128
maaateP_freqvalue_st_mean(SOUNDfile * sf,unsigned int sb,unsigned int nb,Resolution res)129 CSAPI_TIER1 double maaateP_freqvalue_st_mean(SOUNDfile * sf, unsigned int sb,
130 unsigned int nb, Resolution res)
131 {
132 return sf->freqvalue_st_mean(sb,nb,res);
133 }
134
maaateP_freqvalue_st_rms(SOUNDfile * sf,unsigned int sb,unsigned int nb,Resolution res)135 CSAPI_TIER1 double maaateP_freqvalue_st_rms(SOUNDfile * sf, unsigned int sb,
136 unsigned int nb, Resolution res)
137 {
138 return sf->freqvalue_st_rms(sb,nb,res);
139 }
140
maaateP_normalised_sb_nrj(SOUNDfile * sf,unsigned int sb,unsigned int nb,Resolution res)141 CSAPI_TIER1 double maaateP_normalised_sb_nrj(SOUNDfile * sf, unsigned int sb,
142 unsigned int nb, Resolution res)
143 {
144 return sf->normalised_sb_nrj(sb,nb,res);
145 }
146
147 // time resolution = 1 window
148
maaateP_subband_mean(SOUNDfile * sf,unsigned int sb,Resolution res)149 CSAPI_TIER1 double maaateP_subband_mean (SOUNDfile * sf, unsigned int sb, Resolution res)
150 {
151 return sf->subband_mean(sb,res);
152 }
153
maaateP_subband_rms(SOUNDfile * sf,unsigned int sb,Resolution res)154 CSAPI_TIER1 double maaateP_subband_rms (SOUNDfile * sf, unsigned int sb, Resolution res)
155 {
156 return sf->subband_rms(sb,res);
157 }
158
maaateP_subband_nrj(SOUNDfile * sf,unsigned int sb,Resolution res)159 CSAPI_TIER1 double maaateP_subband_nrj (SOUNDfile * sf, unsigned int sb, Resolution res)
160 {
161 return sf->subband_nrj(sb,res);
162 }
163
164 /* decoder*/
maaateP_decode(SOUNDfile * sf,short * buffer,long windows,Channels ch)165 CSAPI_TIER1 long maaateP_decode (SOUNDfile * sf, short * buffer, long windows, Channels ch) {
166 return sf->decode(buffer,windows,ch);
167 }
168
169 /* File format specific pointer access */
maaateP_format_access(SOUNDfile * sf)170 CSAPI_TIER1 AllFormat * maaateP_format_access(SOUNDfile * sf)
171 {
172 return sf->format;
173 }
174