AudioFileWAV.cpp
1 /* 2 This file is part of Darling. 3 4 Copyright (C) 2020 Lubos Dolezel 5 6 Darling 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 Darling 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 Darling. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 #include "AudioFileWAV.h" 20 #include "AVFormatFileObject.h" 21 #include "AudioFileFormatGeneric.h" 22 23 class AudioFileFormatWAV : public AudioFileFormatGeneric 24 { 25 public: 26 AudioFileFormatWAV() : AudioFileFormatGeneric('.mp3', "wav") {} 27 protected: 28 const Description& description() const override 29 { 30 static const Description d = { 31 .name = "WAVE", 32 .extensions = { "wav" }, 33 .utis = { "com.microsoft.waveform-audio", "public.audio", "public.data" }, 34 .mimeTypes = { "audio/wav" }, 35 .formats = { 36 Format(kAudioFormatLinearPCM, 0, 8), 37 Format(kAudioFormatLinearPCM, kAudioFormatFlagIsSignedInteger, 16), 38 Format(kAudioFormatLinearPCM, kAudioFormatFlagIsSignedInteger, 24), 39 Format(kAudioFormatLinearPCM, kAudioFormatFlagIsSignedInteger, 32), 40 Format(kAudioFormatLinearPCM, kAudioFormatFlagIsFloat, 32), 41 Format(kAudioFormatLinearPCM, kAudioFormatFlagIsFloat, 64), 42 'ulaw', 'alaw' 43 }, 44 }; 45 return d; 46 } 47 }; 48 49 class WAVComponent : public AVFormatFileObject<AudioFileFormatWAV, AudioFileWAV, '.wav'> 50 { 51 public: 52 WAVComponent(AudioComponentInstance inInstance) : AVFormatFileObject(inInstance) {} 53 }; 54 55 #pragma GCC visibility push(default) 56 AUDIOCOMPONENT_ENTRY(AudioFileComponentFactory, WAVComponent); 57 #pragma GCC visibility pop 58 59 AudioFileWAV::AudioFileWAV() 60 : AudioFileObject('.wav') 61 { 62 63 } 64 65 Boolean AudioFileWAV::IsDataFormatSupported(const AudioStreamBasicDescription *inFormat) 66 { 67 return true; 68 }