Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

/root/src/subsynth/syn/Stream/WavImporter.h

Go to the documentation of this file.
00001 
00002 /****************** <SYN heading BEGIN do not edit this line> *****************
00003  *
00004  * subsynth - modular audio synthesizer
00005  * subsynth is (C) Copyright 2001-2002 by Kevin Meinert
00006  *
00007  * Original Author: Kevin Meinert
00008  *
00009  * This library is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU Library General Public
00011  * License as published by the Free Software Foundation; either
00012  * version 2 of the License, or (at your option) any later version.
00013  *
00014  * This library is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017  * Library General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU Library General Public
00020  * License along with this library; if not, write to the
00021  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00022  * Boston, MA 02111-1307, USA.
00023  *
00024  * -----------------------------------------------------------------
00025  * File:          $RCSfile: WavImporter.h,v $
00026  * Date modified: $Date: 2002/02/16 19:24:16 $
00027  * Version:       $Revision: 1.11 $
00028  * -----------------------------------------------------------------
00029  *
00030  ****************** <SYN heading END do not edit this line> ******************/
00031 #ifndef WAV_READER
00032 #define WAV_READER
00033 
00034 #include <iostream>
00035 
00036 #include <stdio.h>
00037 #include <stdlib.h>
00038 #include "syn/Util/Endian.h"
00039 #include "syn/Stream/WavHeader.h"
00040 #include "syn/Stream/WavAudioIStream.h"
00041 
00046 class WavImporter
00047 {
00048 public:
00049    bool import( syn::AudioFormat fmt, const char* const filename, std::vector<unsigned char>& data )
00050     {
00051         syn::WavAudioIStream wav_stream;
00052         wav_stream.setName( filename );
00053         wav_stream.open( fmt );
00054 
00055         if (wav_stream.isOpen() != true || wav_stream.good() != true)
00056         {
00057            std::cout<<"Failed to open "<<filename<<"\n"<<std::flush;
00058            wav_stream.close();
00059            return false;
00060         }
00061 
00062         data.resize( wav_stream.numbytes() );
00063         std::cout<<"reading... "<<wav_stream.numsamps()<<" samples from wav file\n"<<std::flush;
00064 
00065         wav_stream.read( (char*)&data.front(), wav_stream.numsamps() );
00066         wav_stream.close();
00067 
00068         return true;
00069     }
00070 
00071 private:  
00072 
00074    /*#  syn::WavAudioIStream lnkWavAudioIStream1; */
00075 };
00076 
00077 #endif

Generated at Mon Apr 15 09:26:08 2002 for subsynth by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001