//------------------------------------------------------------------------ // // SampleDataLoader.cpp // // This class shows how to extend the CVisDataLoader class to load some // data. Currently, it only does a Random or Wave waveform. // // ------------------------------------------------------------------- // * COPYRIGHT 2001, Greg Ratajik and Ratajik Software * // * All rights Reserved * // ------------------------------------------------------------------- // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // 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 for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // More information about this program can be found at: // http://www.ratajik.com/VisInterface // C H A N G E L O G // ===================================================================== // Change ID Date Programmer Description // ============ ========= =========== ================================ // 02-21-01 Ratajik Initial Development //------------------------------------------------------------------------ #include "Stdafx.h" #include "VisInterface.h" #include "SampleDataLoader.h" //------------------------------------------------------------------------ // // Method: CSampleDataLoader // // Description: The ctor // // Parms: N/A // // Return: N/A // // Exceptions: N/A // // C H A N G E L O G // ===================================================================== // Change ID Date Programmer Description // ============ ========= =========== ================================ // 02-21-01 Ratajik Initial Development //_________________________________________________________________________ CSampleDataLoader::CSampleDataLoader() : m_nLast(0), m_typeData(TYPE_WAVE), m_bDoSpec(true), m_bDoWave(true) { } //------------------------------------------------------------------------ // // Method: LoadData // // Description: Using the passed pointers, load the data. This only does // two very basic waveforms. Others will be added later... // // Parms: unsigned char * - Waveform left channel // unsigned char * - Waveform right channel // unsigned char * - Spec left channel // unsigned char * - Spec right channel // // Return: bool - TRUE = worked // // Exceptions: N/A // // C H A N G E L O G // ===================================================================== // Change ID Date Programmer Description // ============ ========= =========== ================================ // 02-21-01 Ratajik Initial Development //_________________________________________________________________________ bool CSampleDataLoader::LoadData(unsigned char *pWaveLeft, unsigned char *pWaveRight, unsigned char *pSpecLeft, unsigned char *pSpecRight) { ASSERT(pWaveLeft && pSpecLeft); int i; if(pWaveLeft && pSpecLeft && pSpecLeft && pSpecRight) { // // Even though this is running from a thread at some point, // this is still safe (m_typeData can change via the UI) // if(m_typeData == TYPE_RANDOM) { // // Fill for the size of the buffer. // for( i = 0; i < VIS_BUFFER_SIZE;i++ ) { if(m_bDoSpec) { pSpecLeft [i] = rand(); pSpecRight[i] = rand(); } else { pSpecLeft [i] = 0; pSpecRight[i] = 0; } if(m_bDoWave) { pWaveLeft [i] = rand(); pWaveRight[i] = rand(); } else { pWaveLeft [i] = 0; pWaveRight[i] = 0; } } } else { int nCur = m_nLast; // Start at the last place we were. int nMod = 1; // // Fill for the size of the buffer. // for( i = 0; i < VIS_BUFFER_SIZE;i++ ) { if(m_bDoSpec) { pSpecLeft[i] = nCur; pSpecRight[i] = nCur; } else { pSpecLeft [i] = 0; pSpecRight[i] = 0; } if(m_bDoWave) { pWaveLeft[i] = nCur; pWaveRight[i] = nCur; } else { pWaveLeft [i] = 0; pWaveRight[i] = 0; } nCur += nMod; if(nCur > 225) nMod = -1; if(nCur < 1) nMod = 1; m_nLast = nCur; } } return(true); } else return(false); } //------------------------------------------------------------------------ // // Method: IsValid // // Description: This is a very simple one, so it's ALWAYS valid.... // // Parms: N/A // // Return: bool - TRUE = is Valid. // // Exceptions: N/A // // C H A N G E L O G // ===================================================================== // Change ID Date Programmer Description // ============ ========= =========== ================================ // 02-21-01 Ratajik Initial Development //_________________________________________________________________________ bool CSampleDataLoader::IsValid( void ) { return(true); }