aubio
0.4.1
|
00001 /* 00002 Copyright (C) 2012-2014 Paul Brossier <piem@aubio.org> 00003 00004 This file is part of aubio. 00005 00006 aubio is free software: you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation, either version 3 of the License, or 00009 (at your option) any later version. 00010 00011 aubio is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with aubio. If not, see <http://www.gnu.org/licenses/>. 00018 00019 */ 00020 00021 #ifndef _AUBIO_SINK_H 00022 #define _AUBIO_SINK_H 00023 00024 /** \file 00025 00026 Media sink to write blocks of consecutive audio samples to file. 00027 00028 To read from file, use ::aubio_source_t. 00029 00030 Depending on how aubio was compiled, the following sinks will be available. 00031 00032 When creating a new sink using ::new_aubio_sink, the new function of each of 00033 the compiled-in sinks will be attempted, in the following order, until one of 00034 them gets successfully created. If all sinks returned NULL, ::new_aubio_sink 00035 will return NULL. 00036 00037 \b \p sink_apple_audio : ExtAudioFileRef 00038 00039 This sink uses CoreAudio [Extended Audio File Services] 00040 (https://developer.apple.com/library/mac/documentation/MusicAudio/Reference/ExtendedAudioFileServicesReference/Reference/reference.html) 00041 to write 16-bits encoded WAV files. 00042 00043 \b \p sink_sndfile : libsndfile 00044 00045 This sink uses [libsndfile](http://www.mega-nerd.com/libsndfile/) to write 00046 16-bits encoded WAV files. 00047 00048 \b \p sink_wavwrite : native WAV write 00049 00050 A simple sink to write 16-bits PCM RIFF encoded WAV files. 00051 00052 \example io/test-sink.c 00053 00054 */ 00055 00056 #ifdef __cplusplus 00057 extern "C" { 00058 #endif 00059 00060 /** media sink object */ 00061 typedef struct _aubio_sink_t aubio_sink_t; 00062 00063 /** 00064 00065 create new ::aubio_sink_t 00066 00067 \param uri the file path or uri to write to 00068 \param samplerate sample rate to write the file at 00069 00070 \return newly created ::aubio_sink_t 00071 00072 Creates a new sink object. 00073 00074 If samplerate is set to 0, the creation of the file will be delayed until 00075 both ::aubio_sink_preset_samplerate and ::aubio_sink_preset_channels have 00076 been called. 00077 00078 */ 00079 aubio_sink_t * new_aubio_sink(char_t * uri, uint_t samplerate); 00080 00081 /** 00082 00083 preset sink samplerate 00084 00085 \param s sink, created with ::new_aubio_sink 00086 \param samplerate samplerate to preset the sink to, in Hz 00087 00088 \return 0 on success, 1 on error 00089 00090 Preset the samplerate of the sink. The file should have been created using a 00091 samplerate of 0. 00092 00093 The file will be opened only when both samplerate and channels have been set. 00094 00095 */ 00096 uint_t aubio_sink_preset_samplerate(aubio_sink_t *s, uint_t samplerate); 00097 00098 /** 00099 00100 preset sink channels 00101 00102 \param s sink, created with ::new_aubio_sink 00103 \param channels number of channels to preset the sink to 00104 00105 \return 0 on success, 1 on error 00106 00107 Preset the samplerate of the sink. The file should have been created using a 00108 samplerate of 0. 00109 00110 The file will be opened only when both samplerate and channels have been set. 00111 00112 */ 00113 uint_t aubio_sink_preset_channels(aubio_sink_t *s, uint_t channels); 00114 00115 /** 00116 00117 get samplerate of sink object 00118 00119 \param s sink object, created with ::new_aubio_sink 00120 \return samplerate, in Hz 00121 00122 */ 00123 uint_t aubio_sink_get_samplerate(aubio_sink_t *s); 00124 00125 /** 00126 00127 get channels of sink object 00128 00129 \param s sink object, created with ::new_aubio_sink 00130 \return number of channels 00131 00132 */ 00133 uint_t aubio_sink_get_channels(aubio_sink_t *s); 00134 00135 /** 00136 00137 write monophonic vector of length hop_size to sink 00138 00139 \param s sink, created with ::new_aubio_sink 00140 \param write_data ::fvec_t samples to write to sink 00141 \param write number of frames to write 00142 00143 */ 00144 void aubio_sink_do(aubio_sink_t * s, fvec_t * write_data, uint_t write); 00145 00146 /** 00147 00148 write polyphonic vector of length hop_size to sink 00149 00150 \param s sink, created with ::new_aubio_sink 00151 \param write_data ::fmat_t samples to write to sink 00152 \param write number of frames to write 00153 00154 */ 00155 void aubio_sink_do_multi(aubio_sink_t * s, fmat_t * write_data, uint_t write); 00156 00157 /** 00158 00159 close sink 00160 00161 \param s sink object, created with ::new_aubio_sink 00162 00163 \return 0 on success, non-zero on failure 00164 00165 */ 00166 uint_t aubio_sink_close(aubio_sink_t * s); 00167 00168 /** 00169 00170 close sink and cleanup memory 00171 00172 \param s sink object, created with ::new_aubio_sink 00173 00174 */ 00175 void del_aubio_sink(aubio_sink_t * s); 00176 00177 #ifdef __cplusplus 00178 } 00179 #endif 00180 00181 #endif /* _AUBIO_SINK_H */