/* Copyright (C) 2006-2011 Nasca Octavian Paul Author: Nasca Octavian Paul This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License (version 2) for more details. You should have received a copy of the GNU General Public License (version 2) along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #pragma once #include "../globals.h" #include "../JuceLibraryCode/JuceHeader.h" class InputS { public: InputS() { skipbufsize=1024; skipbuf.setSize(1, skipbufsize); }; virtual ~InputS() { }; virtual bool openAudioFile(File file)=0; virtual void close()=0; virtual int readNextBlock(AudioBuffer& abuf, int smps, int numchans)=0; void skip(int nsmps) { while ((nsmps>0)&&(m_silenceoutputted<1)) { int readsize=(nsmps getActiveRange() { return m_activerange; } double getLengthSeconds() { if (info.nsamples == 0 || info.samplerate==0) return 0.0; return (double)info.nsamples / info.samplerate; } virtual void setActiveRange(Range rng) = 0; bool isLooping() { return m_loop_enabled; } virtual void setLoopEnabled(bool b) = 0; int64_t getCurrentPosition() { return m_currentsample; } double getCurrentPositionPercent() { return 1.0 / info.nsamples*m_currentsample; } virtual bool hasEnded() { return m_currentsample >= info.nsamples*m_activerange.getEnd(); } virtual AudioBuffer* getAudioBuffer()=0; int64_t getDiskReadSampleCount() { return m_disk_read_count; } protected: volatile int64_t m_currentsample = 0; int m_silenceoutputted = 0; bool m_loop_enabled = false; Range m_activerange{ 0.0,1.0 }; int64_t m_disk_read_count = 0; private: int skipbufsize; AudioBuffer skipbuf; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(InputS) };