Changes in / [1ec59e4:2244f00]
- Files:
-
- 5 deleted
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
.circleci/config.yml
r1ec59e4 r2244f00 3 3 command: | 4 4 sudo apt-get update 5 sudo apt-get -y install make sox pkg-config libavcodec-dev libavformat-dev libavresample-dev libavutil-dev libsndfile1-dev libsamplerate-dev libvorbis-dev libflac-dev5 sudo apt-get -y install make sox pkg-config libavcodec-dev libavformat-dev libavresample-dev libavutil-dev libsndfile1-dev libsamplerate-dev 6 6 7 7 pip-install: &pip-install -
.travis.yml
r1ec59e4 r2244f00 39 39 os: osx 40 40 compiler: clang 41 env: WAFOPTS="--enable-fat --disable-avcodec --disable-sndfile --disable-samplerate --disable-vorbis --disable-flac"41 env: WAFOPTS="--enable-fat --disable-avcodec --disable-sndfile --disable-samplerate" 42 42 - language: C 43 43 os: osx 44 44 compiler: clang 45 env: WAFOPTS="--with-target-platform=ios --disable-avcodec --disable-sndfile --disable-samplerate --disable-vorbis --disable-flac" AUBIO_NOTESTS=145 env: WAFOPTS="--with-target-platform=ios --disable-avcodec --disable-sndfile --disable-samplerate" AUBIO_NOTESTS=1 46 46 - language: C 47 47 os: osx 48 48 compiler: clang 49 env: WAFOPTS="--with-target-platform=iosimulator --disable-avcodec --disable-sndfile --disable-samplerate --disable-vorbis --disable-flac" AUBIO_NOTESTS=149 env: WAFOPTS="--with-target-platform=iosimulator --disable-avcodec --disable-sndfile --disable-samplerate" AUBIO_NOTESTS=1 50 50 51 51 # use trusty … … 63 63 - libsndfile1-dev 64 64 - libsamplerate-dev 65 - libvorbis-dev66 - libflac-dev67 65 - libjack-dev 68 66 - libasound2-dev … … 75 73 - ffmpeg 76 74 - libsndfile 77 - libvorbis78 - flac79 75 - lcov 80 76 update: true -
azure-pipelines.yml
r1ec59e4 r2244f00 30 30 brew update 31 31 brew install pkg-config gnupg 32 brew install sox ffmpeg libsndfile l ibvorbis flac lcov32 brew install sox ffmpeg libsndfile lcov 33 33 displayName: 'brew install' 34 34 - script: | -
src/io/sink.c
r1ec59e4 r2244f00 54 54 }; 55 55 56 extern uint_t aubio_str_path_has_extension(const char_t *filename,57 const char_t *pattern);58 59 #ifdef HAVE_VORBISENC60 typedef struct _aubio_sink_vorbis_t aubio_sink_vorbis_t;61 extern aubio_sink_vorbis_t * new_aubio_sink_vorbis(const char_t *uri,62 uint_t samplerate);63 extern void del_aubio_sink_vorbis (aubio_sink_vorbis_t *s);64 extern uint_t aubio_sink_vorbis_open(aubio_sink_vorbis_t *s);65 extern uint_t aubio_sink_vorbis_close(aubio_sink_vorbis_t *s);66 extern uint_t aubio_sink_vorbis_preset_channels(aubio_sink_vorbis_t *s,67 uint_t channels);68 extern uint_t aubio_sink_vorbis_preset_samplerate(aubio_sink_vorbis_t *s,69 uint_t samplerate);70 extern uint_t aubio_sink_vorbis_get_channels(aubio_sink_vorbis_t *s);71 extern uint_t aubio_sink_vorbis_get_samplerate(aubio_sink_vorbis_t *s);72 extern void aubio_sink_vorbis_do(aubio_sink_vorbis_t *s, fvec_t*73 write_data, uint_t write);74 extern void aubio_sink_vorbis_do_multi(aubio_sink_vorbis_t *s, fmat_t*75 write_data, uint_t write);76 #endif /* HAVE_VORBISENC */77 78 #ifdef HAVE_FLAC79 typedef struct _aubio_sink_flac_t aubio_sink_flac_t;80 extern aubio_sink_flac_t * new_aubio_sink_flac(const char_t *uri,81 uint_t samplerate);82 extern void del_aubio_sink_flac (aubio_sink_flac_t *s);83 extern uint_t aubio_sink_flac_open(aubio_sink_flac_t *s);84 extern uint_t aubio_sink_flac_close(aubio_sink_flac_t *s);85 extern uint_t aubio_sink_flac_preset_channels(aubio_sink_flac_t *s,86 uint_t channels);87 extern uint_t aubio_sink_flac_preset_samplerate(aubio_sink_flac_t *s,88 uint_t samplerate);89 extern uint_t aubio_sink_flac_get_channels(aubio_sink_flac_t *s);90 extern uint_t aubio_sink_flac_get_samplerate(aubio_sink_flac_t *s);91 extern void aubio_sink_flac_do(aubio_sink_flac_t *s, fvec_t*92 write_data, uint_t write);93 extern void aubio_sink_flac_do_multi(aubio_sink_flac_t *s, fmat_t*94 write_data, uint_t write);95 #endif /* HAVE_FLAC */96 97 56 aubio_sink_t * new_aubio_sink(const char_t * uri, uint_t samplerate) { 98 57 aubio_sink_t * s = AUBIO_NEW(aubio_sink_t); 99 100 #ifdef HAVE_VORBISENC101 // check if this uri could be for us102 if (aubio_str_path_has_extension(uri, "ogg")) {103 s->sink = (void *)new_aubio_sink_vorbis(uri, samplerate);104 if (s->sink) {105 s->s_do = (aubio_sink_do_t)(aubio_sink_vorbis_do);106 s->s_do_multi = (aubio_sink_do_multi_t)(aubio_sink_vorbis_do_multi);107 s->s_preset_samplerate = (aubio_sink_preset_samplerate_t)(aubio_sink_vorbis_preset_samplerate);108 s->s_preset_channels = (aubio_sink_preset_channels_t)(aubio_sink_vorbis_preset_channels);109 s->s_get_samplerate = (aubio_sink_get_samplerate_t)(aubio_sink_vorbis_get_samplerate);110 s->s_get_channels = (aubio_sink_get_channels_t)(aubio_sink_vorbis_get_channels);111 s->s_close = (aubio_sink_close_t)(aubio_sink_vorbis_close);112 s->s_del = (del_aubio_sink_t)(del_aubio_sink_vorbis);113 return s;114 }115 }116 #endif /* HAVE_VORBISENC */117 118 #ifdef HAVE_FLAC119 // check if this uri could be for us120 if (aubio_str_path_has_extension(uri, "flac")) {121 s->sink = (void *)new_aubio_sink_flac(uri, samplerate);122 if (s->sink) {123 s->s_do = (aubio_sink_do_t)(aubio_sink_flac_do);124 s->s_do_multi = (aubio_sink_do_multi_t)(aubio_sink_flac_do_multi);125 s->s_preset_samplerate = (aubio_sink_preset_samplerate_t)(aubio_sink_flac_preset_samplerate);126 s->s_preset_channels = (aubio_sink_preset_channels_t)(aubio_sink_flac_preset_channels);127 s->s_get_samplerate = (aubio_sink_get_samplerate_t)(aubio_sink_flac_get_samplerate);128 s->s_get_channels = (aubio_sink_get_channels_t)(aubio_sink_flac_get_channels);129 s->s_close = (aubio_sink_close_t)(aubio_sink_flac_close);130 s->s_del = (del_aubio_sink_t)(del_aubio_sink_flac);131 return s;132 }133 }134 #endif /* HAVE_FLAC */135 136 58 #ifdef HAVE_SINK_APPLE_AUDIO 137 59 s->sink = (void *)new_aubio_sink_apple_audio(uri, samplerate); … … 178 100 #if !defined(HAVE_WAVWRITE) && \ 179 101 !defined(HAVE_SNDFILE) && \ 180 !defined(HAVE_SINK_APPLE_AUDIO) && \ 181 !defined(HAVE_VORBISENC) && \ 182 !defined(HAVE_FLAC) 102 !defined(HAVE_SINK_APPLE_AUDIO) 183 103 AUBIO_ERROR("sink: failed creating '%s' at %dHz (no sink built-in)\n", uri, samplerate); 184 104 #endif -
src/io/sink_apple_audio.c
r1ec59e4 r2244f00 39 39 uint_t aubio_sink_apple_audio_open(aubio_sink_apple_audio_t *s); 40 40 41 uint_t aubio_str_extension_matches(const char_t *ext,42 const char_t *pattern);43 const char_t *aubio_str_get_extension(const char_t *filename);44 45 41 #define MAX_SIZE 4096 // the maximum number of frames that can be written at a time 46 42 … … 57 53 ExtAudioFileRef audioFile; 58 54 bool async; 59 AudioFileTypeID fileType;60 55 }; 61 56 … … 76 71 s->channels = 0; 77 72 78 aubio_sink_apple_audio_preset_format(s, aubio_str_get_extension(uri));79 80 73 // zero samplerate given. do not open yet 81 74 if ((sint_t)samplerate == 0) { … … 128 121 } 129 122 130 uint_t aubio_sink_apple_audio_preset_format(aubio_sink_apple_audio_t *s,131 const char_t *fmt)132 {133 if (aubio_str_extension_matches(fmt, "wav")) {134 s->fileType = kAudioFileWAVEType;135 } else if (aubio_str_extension_matches(fmt, "m4a")136 || aubio_str_extension_matches(fmt, "mp4") ) {137 // use alac for "mp4" and "m4a"138 s->fileType = kAudioFileM4AType;139 } else if (aubio_str_extension_matches(fmt, "aac") ) {140 // only use lossy codec for "aac"141 s->fileType = kAudioFileMPEG4Type;142 } else if (aubio_str_extension_matches(fmt, "aiff") ) {143 // only use lossy codec for "aac"144 s->fileType = kAudioFileAIFFType;145 } else {146 s->fileType = kAudioFileWAVEType;147 if (fmt && strnlen(fmt, PATH_MAX)) {148 AUBIO_WRN("sink_apple_audio: could not guess format for %s,"149 " using default (wav)\n", s->path);150 return AUBIO_FAIL;151 }152 }153 return AUBIO_OK;154 }155 156 static void aubio_sink_apple_audio_set_client_format(aubio_sink_apple_audio_t* s,157 AudioStreamBasicDescription *clientFormat)158 {159 memset(clientFormat, 0, sizeof(AudioStreamBasicDescription));160 // always set samplerate and channels first161 clientFormat->mSampleRate = (Float64)(s->samplerate);162 clientFormat->mChannelsPerFrame = s->channels;163 164 switch (s->fileType) {165 case kAudioFileM4AType:166 clientFormat->mFormatID = kAudioFormatAppleLossless;167 break;168 case kAudioFileMPEG4Type:169 clientFormat->mFormatID = kAudioFormatMPEG4AAC;170 clientFormat->mFormatFlags = kMPEG4Object_AAC_Main;171 clientFormat->mFormatFlags |= kAppleLosslessFormatFlag_16BitSourceData;172 clientFormat->mFramesPerPacket = 1024;173 break;174 case kAudioFileWAVEType:175 clientFormat->mFormatID = kAudioFormatLinearPCM;176 clientFormat->mFormatFlags = kAudioFormatFlagIsSignedInteger;177 clientFormat->mFormatFlags |= kAudioFormatFlagIsPacked;178 clientFormat->mBitsPerChannel = sizeof(short) * 8;179 clientFormat->mFramesPerPacket = 1;180 clientFormat->mBytesPerFrame = clientFormat->mBitsPerChannel * clientFormat->mChannelsPerFrame / 8;181 clientFormat->mBytesPerPacket = clientFormat->mFramesPerPacket * clientFormat->mBytesPerFrame;182 break;183 case kAudioFileAIFFType:184 clientFormat->mFormatID = kAudioFormatLinearPCM;185 clientFormat->mFormatFlags = kAudioFormatFlagIsSignedInteger;186 clientFormat->mFormatFlags |= kAudioFormatFlagIsPacked;187 clientFormat->mFormatFlags |= kAudioFormatFlagIsBigEndian;188 clientFormat->mBitsPerChannel = sizeof(short) * 8;189 clientFormat->mFramesPerPacket = 1;190 clientFormat->mBytesPerFrame = clientFormat->mBitsPerChannel * clientFormat->mChannelsPerFrame / 8;191 clientFormat->mBytesPerPacket = clientFormat->mFramesPerPacket * clientFormat->mBytesPerFrame;192 break;193 default:194 break;195 }196 }197 198 123 uint_t aubio_sink_apple_audio_get_samplerate(const aubio_sink_apple_audio_t *s) 199 124 { … … 210 135 if (s->samplerate == 0 || s->channels == 0) return AUBIO_FAIL; 211 136 137 AudioStreamBasicDescription clientFormat; 138 memset(&clientFormat, 0, sizeof(AudioStreamBasicDescription)); 139 clientFormat.mFormatID = kAudioFormatLinearPCM; 140 clientFormat.mSampleRate = (Float64)(s->samplerate); 141 clientFormat.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked; 142 clientFormat.mChannelsPerFrame = s->channels; 143 clientFormat.mBitsPerChannel = sizeof(short) * 8; 144 clientFormat.mFramesPerPacket = 1; 145 clientFormat.mBytesPerFrame = clientFormat.mBitsPerChannel * clientFormat.mChannelsPerFrame / 8; 146 clientFormat.mBytesPerPacket = clientFormat.mFramesPerPacket * clientFormat.mBytesPerFrame; 147 clientFormat.mReserved = 0; 148 149 AudioFileTypeID fileType = kAudioFileWAVEType; 212 150 CFURLRef fileURL = createURLFromPath(s->path); 213 151 bool overwrite = true; … … 224 162 inputFormat.mBytesPerFrame = inputFormat.mBitsPerChannel * inputFormat.mChannelsPerFrame / 8; 225 163 inputFormat.mBytesPerPacket = inputFormat.mFramesPerPacket * inputFormat.mBytesPerFrame; 226 227 // get the in-file format228 AudioStreamBasicDescription clientFormat;229 aubio_sink_apple_audio_set_client_format(s, &clientFormat);230 231 164 OSStatus err = noErr; 232 err = ExtAudioFileCreateWithURL(fileURL, s->fileType, &clientFormat, NULL,165 err = ExtAudioFileCreateWithURL(fileURL, fileType, &clientFormat, NULL, 233 166 overwrite ? kAudioFileFlags_EraseFile : 0, &s->audioFile); 234 167 CFRelease(fileURL); … … 240 173 goto beach; 241 174 } 242 243 #if defined(kAppleSoftwareAudioCodecManufacturer)244 // on iOS, set software based encoding before setting clientDataFormat245 UInt32 codecManf = kAppleSoftwareAudioCodecManufacturer;246 err = ExtAudioFileSetProperty(s->audioFile,247 kExtAudioFileProperty_CodecManufacturer,248 sizeof(UInt32), &codecManf);249 if (err) {250 char_t errorstr[20];251 AUBIO_ERR("sink_apple_audio: error when trying to set sofware codec on %s "252 "(%s)\n", s->path, getPrintableOSStatusError(errorstr, err));253 goto beach;254 }255 #endif256 175 257 176 err = ExtAudioFileSetProperty(s->audioFile, -
src/io/sink_apple_audio.h
r1ec59e4 r2244f00 97 97 /** 98 98 99 preset sink format100 101 \param s sink, created with ::new_aubio_sink_apple_audio102 \param fmt format of the file to create103 104 \return 0 on success, 1 on error105 106 Preset the format of the sink. Supported format strings:107 - "wav": WAVE, 16 bit (default)108 - "aiff": AIFF, 16 bit109 - "m4a" or "mp4": Apple Audio Lossless Codec (ALAC)110 - "aac": Audio Advanced Codec, lossy111 112 Full list of supported encoding format is available in Table 1-2 of113 `Multimedia Programming Guide114 <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 122 99 get samplerate of sink object 123 100 -
src/io/sink_sndfile.c
r1ec59e4 r2244f00 49 49 uint_t scratch_size; 50 50 smpl_t *scratch_data; 51 int format;52 51 }; 53 52 54 53 uint_t aubio_sink_sndfile_open(aubio_sink_sndfile_t *s); 55 56 uint_t aubio_str_extension_matches(const char_t *ext,57 const char_t *pattern);58 const char_t *aubio_str_get_extension(const char_t *filename);59 54 60 55 aubio_sink_sndfile_t * new_aubio_sink_sndfile(const char_t * path, uint_t samplerate) { … … 72 67 s->samplerate = 0; 73 68 s->channels = 0; 74 75 aubio_sink_sndfile_preset_format(s, aubio_str_get_extension(path));76 69 77 70 // zero samplerate given. do not open yet … … 119 112 if (s->samplerate != 0 /* && s->channels != 0 */) { 120 113 return aubio_sink_sndfile_open(s); 121 }122 return AUBIO_OK;123 }124 125 uint_t aubio_sink_sndfile_preset_format(aubio_sink_sndfile_t *s,126 const char_t *fmt)127 {128 if (aubio_str_extension_matches(fmt, "wav")) {129 s->format = SF_FORMAT_WAV | SF_FORMAT_PCM_16;130 } else if (aubio_str_extension_matches(fmt, "aiff")) {131 s->format = SF_FORMAT_AIFF | SF_FORMAT_PCM_16;132 } else if (aubio_str_extension_matches(fmt, "flac")) {133 s->format = SF_FORMAT_FLAC | SF_FORMAT_PCM_16;134 } else if (aubio_str_extension_matches(fmt, "ogg")) {135 s->format = SF_FORMAT_OGG | SF_FORMAT_VORBIS;136 } else if (atoi(fmt) > 0x010000) {137 s->format = atoi(fmt);138 } else {139 s->format = SF_FORMAT_WAV | SF_FORMAT_PCM_16;140 if (fmt && strnlen(fmt, PATH_MAX)) {141 AUBIO_WRN("sink_sndfile: could not guess format %s for %s,"142 " using default (wav)\n", fmt, s->path);143 return AUBIO_FAIL;144 }145 114 } 146 115 return AUBIO_OK; … … 163 132 sfinfo.samplerate = s->samplerate; 164 133 sfinfo.channels = s->channels; 165 sfinfo.format = s->format;134 sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_PCM_16; 166 135 167 136 /* try creating the file */ -
src/io/sink_sndfile.h
r1ec59e4 r2244f00 96 96 /** 97 97 98 preset sink format99 100 \param s sink, created with ::new_aubio_sink_sndfile101 \param fmt format of the file to create102 103 \return 0 on success, 1 on error104 105 Preset the format of the sink. Supported format strings:106 - "wav": 16 bit (default)107 - "aiff": aiff, 16 bit108 - "flac": flac, 16 bit109 - "ogg": ogg vorbis stream110 111 Alternatively, any sndfile format can be set by passing the corresponding112 integer as a string:113 114 \code{.c}115 char_t fmt[10];116 snprintf(fmt, sizeof(fmt), "%d", SF_FORMAT_FLAC | SF_FORMAT_PCM_24);117 aubio_sink_sndfile_preset_format(s, fmt);118 \endcode119 120 The file should have been created using a samplerate of 0.121 122 This function should be called before aubio_sink_sndfile_preset_samplerate()123 and aubio_sink_sndfile_preset_channels().124 125 */126 uint_t aubio_sink_sndfile_preset_format(aubio_sink_sndfile_t *s,127 const char_t* fmt);128 129 /**130 131 98 get samplerate of sink object 132 99 -
src/wscript_build
r1ec59e4 r2244f00 12 12 uselib += ['AVRESAMPLE'] 13 13 uselib += ['AVUTIL'] 14 uselib += ['VORBISENC']15 uselib += ['FLAC']16 14 uselib += ['BLAS'] 17 15 -
wscript
r1ec59e4 r2244f00 67 67 help_str = 'compile with libavcodec (auto)', 68 68 help_disable_str = 'disable libavcodec') 69 add_option_enable_disable(ctx, 'vorbis', default = None,70 help_str = 'compile with libvorbis (auto)',71 help_disable_str = 'disable libvorbis')72 add_option_enable_disable(ctx, 'flac', default = None,73 help_str = 'compile with libFLAC (auto)',74 help_disable_str = 'disable libflac')75 69 add_option_enable_disable(ctx, 'samplerate', default = None, 76 70 help_str = 'compile with samplerate (auto)', … … 436 430 ctx.define('HAVE_AVRESAMPLE', 1) 437 431 ctx.define('HAVE_LIBAV', 1) 438 439 # check for vorbisenc440 if (ctx.options.enable_vorbis != False):441 ctx.check_cfg(package = 'vorbisenc vorbis ogg',442 args = '--cflags --libs',443 uselib_store = 'VORBISENC',444 mandatory = ctx.options.enable_vorbis)445 446 # check for flac447 if (ctx.options.enable_flac != False):448 ctx.check_cfg(package = 'flac',449 args = '--cflags --libs',450 uselib_store = 'FLAC',451 mandatory = ctx.options.enable_flac)452 432 453 433 if (ctx.options.enable_wavread != False):
Note: See TracChangeset
for help on using the changeset viewer.