[1223979] | 1 | /* |
---|
[222b176] | 2 | Copyright (C) 2012-2014 Paul Brossier <piem@aubio.org> |
---|
[1223979] | 3 | |
---|
| 4 | This file is part of aubio. |
---|
| 5 | |
---|
| 6 | aubio 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 3 of the License, or |
---|
| 9 | (at your option) any later version. |
---|
| 10 | |
---|
| 11 | aubio 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 aubio. If not, see <http://www.gnu.org/licenses/>. |
---|
| 18 | |
---|
| 19 | */ |
---|
| 20 | |
---|
[6f42c16] | 21 | #ifndef AUBIO_SINK_APPLE_AUDIO_H |
---|
| 22 | #define AUBIO_SINK_APPLE_AUDIO_H |
---|
[1223979] | 23 | |
---|
| 24 | /** \file |
---|
| 25 | |
---|
[ac20c85] | 26 | Write to file using Apple AudioToolbox's |
---|
| 27 | [ExtAudioFileRef](https://developer.apple.com/library/ios/#documentation/MusicAudio/Reference/ExtendedAudioFileServicesReference/Reference/reference.html) |
---|
| 28 | |
---|
| 29 | Avoid including this file directly! Prefer using ::aubio_sink_t instead to |
---|
| 30 | make your code portable. |
---|
| 31 | |
---|
| 32 | To read from file, use ::aubio_source_t. |
---|
[1223979] | 33 | |
---|
[4e3723d] | 34 | \example io/test-sink_apple_audio.c |
---|
| 35 | |
---|
[1223979] | 36 | */ |
---|
| 37 | |
---|
[4e3723d] | 38 | #ifdef __cplusplus |
---|
| 39 | extern "C" { |
---|
| 40 | #endif |
---|
| 41 | |
---|
[222b176] | 42 | /** sink_apple_audio object */ |
---|
[1223979] | 43 | typedef struct _aubio_sink_apple_audio_t aubio_sink_apple_audio_t; |
---|
[ac20c85] | 44 | |
---|
| 45 | /** |
---|
| 46 | |
---|
| 47 | create new ::aubio_sink_apple_audio_t |
---|
| 48 | |
---|
| 49 | \param uri the file path or uri to write to |
---|
| 50 | \param samplerate sample rate to write the file at |
---|
| 51 | |
---|
| 52 | \return newly created ::aubio_sink_apple_audio_t |
---|
| 53 | |
---|
| 54 | Creates a new sink object. |
---|
| 55 | |
---|
[222b176] | 56 | If samplerate is set to 0, the creation of the file will be delayed until |
---|
| 57 | both ::aubio_sink_preset_samplerate and ::aubio_sink_preset_channels have |
---|
| 58 | been called. |
---|
| 59 | |
---|
[ac20c85] | 60 | */ |
---|
[ae5d58a] | 61 | aubio_sink_apple_audio_t * new_aubio_sink_apple_audio(const char_t * uri, uint_t samplerate); |
---|
[ac20c85] | 62 | |
---|
| 63 | /** |
---|
| 64 | |
---|
[222b176] | 65 | preset sink samplerate |
---|
| 66 | |
---|
| 67 | \param s sink, created with ::new_aubio_sink_apple_audio |
---|
| 68 | \param samplerate samplerate to preset the sink to, in Hz |
---|
| 69 | |
---|
| 70 | \return 0 on success, 1 on error |
---|
| 71 | |
---|
| 72 | Preset the samplerate of the sink. The file should have been created using a |
---|
| 73 | samplerate of 0. |
---|
| 74 | |
---|
| 75 | The file will be opened only when both samplerate and channels have been set. |
---|
| 76 | |
---|
| 77 | */ |
---|
| 78 | uint_t aubio_sink_apple_audio_preset_samplerate(aubio_sink_apple_audio_t *s, uint_t samplerate); |
---|
| 79 | |
---|
| 80 | /** |
---|
| 81 | |
---|
| 82 | preset sink channels |
---|
| 83 | |
---|
| 84 | \param s sink, created with ::new_aubio_sink_apple_audio |
---|
| 85 | \param channels number of channels to preset the sink to |
---|
| 86 | |
---|
| 87 | \return 0 on success, 1 on error |
---|
| 88 | |
---|
| 89 | Preset the samplerate of the sink. The file should have been created using a |
---|
| 90 | samplerate of 0. |
---|
| 91 | |
---|
| 92 | The file will be opened only when both samplerate and channels have been set. |
---|
| 93 | |
---|
| 94 | */ |
---|
| 95 | uint_t aubio_sink_apple_audio_preset_channels(aubio_sink_apple_audio_t *s, uint_t channels); |
---|
| 96 | |
---|
| 97 | /** |
---|
| 98 | |
---|
[2b208a8] | 99 | preset sink format |
---|
| 100 | |
---|
| 101 | \param s sink, created with ::new_aubio_sink_apple_audio |
---|
| 102 | \param fmt format of the file to create |
---|
| 103 | |
---|
| 104 | \return 0 on success, 1 on error |
---|
| 105 | |
---|
| 106 | Preset the format of the sink. Supported format strings: |
---|
| 107 | - "wav": WAVE, 16 bit (default) |
---|
| 108 | - "aiff": AIFF, 16 bit |
---|
| 109 | - "m4a" or "mp4": Apple Audio Lossless Codec (ALAC) |
---|
| 110 | - "aac": Audio Advanced Codec, lossy |
---|
| 111 | |
---|
| 112 | Full list of supported encoding format is available in Table 1-2 of |
---|
| 113 | `Multimedia Programming Guide |
---|
| 114 | <https://developer.apple.com/library/archive/documentation/AudioVideo/Conceptual/MultimediaPG/UsingAudio/UsingAudio.html>`_. |
---|
| 115 | |
---|
| 116 | */ |
---|
| 117 | uint_t aubio_sink_apple_audio_preset_format(aubio_sink_apple_audio_t *s, |
---|
| 118 | const char_t *fmt); |
---|
| 119 | |
---|
| 120 | /** |
---|
| 121 | |
---|
[222b176] | 122 | get samplerate of sink object |
---|
| 123 | |
---|
| 124 | \param s sink object, created with ::new_aubio_sink_apple_audio |
---|
| 125 | \return samplerate, in Hz |
---|
| 126 | |
---|
| 127 | */ |
---|
[ae5d58a] | 128 | uint_t aubio_sink_apple_audio_get_samplerate(const aubio_sink_apple_audio_t *s); |
---|
[222b176] | 129 | |
---|
| 130 | /** |
---|
| 131 | |
---|
| 132 | get channels of sink object |
---|
| 133 | |
---|
| 134 | \param s sink object, created with ::new_aubio_sink_apple_audio |
---|
| 135 | \return number of channels |
---|
| 136 | |
---|
| 137 | */ |
---|
[ae5d58a] | 138 | uint_t aubio_sink_apple_audio_get_channels(const aubio_sink_apple_audio_t *s); |
---|
[222b176] | 139 | |
---|
| 140 | /** |
---|
| 141 | |
---|
[ac20c85] | 142 | write monophonic vector of length hop_size to sink |
---|
| 143 | |
---|
| 144 | \param s sink, created with ::new_aubio_sink_apple_audio |
---|
| 145 | \param write_data ::fvec_t samples to write to sink |
---|
| 146 | \param write number of frames to write |
---|
| 147 | |
---|
| 148 | */ |
---|
[1223979] | 149 | void aubio_sink_apple_audio_do(aubio_sink_apple_audio_t * s, fvec_t * write_data, uint_t write); |
---|
[ac20c85] | 150 | |
---|
| 151 | /** |
---|
| 152 | |
---|
[222b176] | 153 | write polyphonic vector of length hop_size to sink |
---|
| 154 | |
---|
| 155 | \param s sink, created with ::new_aubio_sink_apple_audio |
---|
| 156 | \param write_data ::fmat_t samples to write to sink |
---|
| 157 | \param write number of frames to write |
---|
| 158 | |
---|
| 159 | */ |
---|
| 160 | void aubio_sink_apple_audio_do_multi(aubio_sink_apple_audio_t * s, fmat_t * write_data, uint_t write); |
---|
| 161 | |
---|
| 162 | /** |
---|
| 163 | |
---|
[a9fd272] | 164 | close sink |
---|
| 165 | |
---|
| 166 | \param s sink_apple_audio object, created with ::new_aubio_sink_apple_audio |
---|
| 167 | |
---|
| 168 | \return 0 on success, non-zero on failure |
---|
| 169 | |
---|
| 170 | */ |
---|
| 171 | uint_t aubio_sink_apple_audio_close(aubio_sink_apple_audio_t * s); |
---|
| 172 | |
---|
| 173 | /** |
---|
| 174 | |
---|
[ac20c85] | 175 | close sink and cleanup memory |
---|
| 176 | |
---|
| 177 | \param s sink, created with ::new_aubio_sink_apple_audio |
---|
| 178 | |
---|
| 179 | */ |
---|
[1223979] | 180 | void del_aubio_sink_apple_audio(aubio_sink_apple_audio_t * s); |
---|
| 181 | |
---|
| 182 | #ifdef __cplusplus |
---|
| 183 | } |
---|
| 184 | #endif |
---|
| 185 | |
---|
[6f42c16] | 186 | #endif /* AUBIO_SINK_APPLE_AUDIO_H */ |
---|