From 55a85aa2a906d56818a35172594762a637d85f6d Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 13 Nov 2006 17:56:43 +0000 Subject: display timecode from BWF etc in SF browser; accels for windows now work (misspelling in ardour.bindings); use hide icon in automation tracks git-svn-id: svn://localhost/ardour2/trunk@1125 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/coreaudiosource.cc | 50 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'libs/ardour/coreaudiosource.cc') diff --git a/libs/ardour/coreaudiosource.cc b/libs/ardour/coreaudiosource.cc index 83103a6bd4..3c81b18fd4 100644 --- a/libs/ardour/coreaudiosource.cc +++ b/libs/ardour/coreaudiosource.cc @@ -185,3 +185,53 @@ CoreAudioSource::update_header (nframes_t when, struct tm&, time_t) { return 0; } + +int +CoreAudioSource::get_soundfile_info (string path, SoundFileInfo& _info, string& error_msg) +{ + FSRef ref; + ExtAudioFileRef af = 0; + size_t size; + CFStringRef name; + int ret = -1; + + if (FSPathMakeRef ((UInt8*)path.c_str(), &ref, 0) != noErr) { + goto out; + } + + if (ExtAudioFileOpen(&ref, &af) != noErr) { + goto out; + } + + AudioStreamBasicDescription absd; + memset(&absd, 0, sizeof(absd)); + size = sizeof(AudioStreamBasicDescription); + if (ExtAudioFileGetProperty (af, kExtAudioFileProperty_FileDataFormat, &size, &absd) != noErr) { + goto out; + } + + _info.samplerate = absd.mSampleRate; + _info.channels = absd.mChannelsPerFrame; + + size = sizeof(_info.length); + if (ExtAudioFileGetProperty(af, kExtAudioFileProperty_FileLengthFrames, &size, &_info.length) != noErr) { + goto out; + } + + size = sizeof(CFStringRef); + if (AudioFormatGetProperty(kAudioFormatProperty_FormatName, sizeof(absd), &absd, &size, &name) != noErr) { + goto out; + } + + _info.format_name = CFStringRefToStdString(name); + + // XXX it would be nice to find a way to get this information if it exists + + _info.timecode = 0; + ret = 0; + + out: + ExtAudioFileDispose (af); + return ret; + +} -- cgit v1.2.3