paulstretch_cpp

PaulStretch
Log | Files | Refs | LICENSE

InputS.h (1475B)


      1 /*
      2   Copyright (C) 2006-2011 Nasca Octavian Paul
      3   Author: Nasca Octavian Paul
      4 
      5   This program is free software; you can redistribute it and/or modify
      6   it under the terms of version 2 of the GNU General Public License 
      7   as published by the Free Software Foundation.
      8 
      9   This program is distributed in the hope that it will be useful,
     10   but WITHOUT ANY WARRANTY; without even the implied warranty of
     11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     12   GNU General Public License (version 2) for more details.
     13 
     14   You should have received a copy of the GNU General Public License (version 2)
     15   along with this program; if not, write to the Free Software Foundation,
     16   Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
     17 */
     18 
     19 #ifndef INPUTS_H
     20 #define INPUTS_H
     21 #include "../globals.h"
     22 
     23 class InputS{
     24 	public:
     25 		InputS(){
     26 			skipbufsize=1024;
     27 			skipbuf=new short int[skipbufsize*4];	
     28 		};
     29 
     30 		virtual ~InputS(){
     31 			delete [] skipbuf;
     32 		};
     33 		virtual bool open(std::string filename)=0;
     34 		virtual void close()=0;
     35 
     36 		virtual int read(int nsmps,short int *smps)=0;
     37 		void skip(int nsmps){
     38 			while ((nsmps>0)&&(!eof)){
     39 				int readsize=(nsmps<skipbufsize)?nsmps:skipbufsize;
     40 				read(readsize,skipbuf);
     41 				nsmps-=readsize;
     42 			};
     43 		};
     44 		virtual void seek(double pos)=0;//0=start,1.0=end
     45 
     46 		struct {
     47 			int nsamples;
     48 			int nchannels;
     49 			int samplerate;
     50 			int currentsample;
     51 		} info;
     52 		bool eof;	
     53 	private:
     54 		int skipbufsize;
     55 		short int *skipbuf;
     56 
     57 };
     58 
     59 #endif
     60 
     61