00001 /* 00002 * Copyright (C) 2010 Stefan Westerfeld 00003 * 00004 * This library is free software; you can redistribute it and/or modify it 00005 * under the terms of the GNU Lesser General Public License as published by the 00006 * Free Software Foundation; either version 3 of the License, or (at your 00007 * option) any later version. 00008 * 00009 * This library is distributed in the hope that it will be useful, but WITHOUT 00010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00011 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 00012 * for more details. 00013 * 00014 * You should have received a copy of the GNU Lesser General Public License 00015 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00016 */ 00017 00018 #ifndef SPECTMORPH_AUDIO_HH 00019 #define SPECTMORPH_AUDIO_HH 00020 00021 #include <bse/bsecxxplugin.hh> 00022 #include <vector> 00023 00024 #include "smgenericin.hh" 00025 #include "smgenericout.hh" 00026 00027 #define SPECTMORPH_BINARY_FILE_VERSION 10 00028 00029 namespace SpectMorph 00030 { 00031 00040 class AudioBlock 00041 { 00042 public: 00043 std::vector<float> noise; 00044 std::vector<float> freqs; 00045 std::vector<float> mags; 00046 std::vector<float> phases; 00047 std::vector<float> original_fft; 00048 std::vector<float> debug_samples; 00049 }; 00050 00051 enum AudioLoadOptions 00052 { 00053 AUDIO_LOAD_DEBUG, 00054 AUDIO_SKIP_DEBUG 00055 }; 00056 00064 class Audio 00065 { 00066 public: 00067 Audio(); 00068 00069 enum LoopType { 00070 LOOP_NONE = 0, 00071 LOOP_FRAME_FORWARD, 00072 LOOP_FRAME_PING_PONG, 00073 LOOP_TIME_FORWARD, 00074 LOOP_TIME_PING_PONG, 00075 }; 00076 00077 float fundamental_freq; 00078 float mix_freq; 00079 float frame_size_ms; 00080 float frame_step_ms; 00081 float attack_start_ms; 00082 float attack_end_ms; 00083 int zeropad; 00084 LoopType loop_type; 00085 int loop_start; 00086 int loop_end; 00087 int zero_values_at_start; 00088 int sample_count; 00089 std::vector<float> original_samples; 00090 std::vector<AudioBlock> contents; 00091 00092 BseErrorType load (const std::string& filename, AudioLoadOptions load_options = AUDIO_LOAD_DEBUG); 00093 BseErrorType load (SpectMorph::GenericIn *file, AudioLoadOptions load_options = AUDIO_LOAD_DEBUG); 00094 BseErrorType save (const std::string& filename); 00095 BseErrorType save (SpectMorph::GenericOut *file); 00096 }; 00097 00098 } 00099 00100 #endif