// ============================================================================================ bool TestLauncher::goForward() { if (currentIndex < tests.size() - 1) { currentIndex++; /* update audio data */ dbgOut( L"\t Starting test " + String(currentIndex) + L"\t" + tests[currentIndex]->testName ); releaseAudioData(); runThread(); return true; } else { return false; } }
/********************************************** * \brief * * * \return none */ result_t HalExpansionPortClass::writePcaPorts(uint32_t iRegister, uint8_t *pBuffer, uint32_t bufLength) { uint32_t bufCnt=bufLength; uint32_t breakOut_cnt=0; result_t retResult=SUCCESS; TWI_StartWrite(HW_ADDR_TWI_PCA9698,HW_PCA9698_TwiAddr, iRegister,HW_PCA9698_InternalAddrLen,*pBuffer); pBuffer++; bufCnt--; while(bufCnt >0) { //if no NACK and Byte sent, then transmit next one if (TWI_SR_NACK & TWI_GetStatus(HW_ADDR_TWI_PCA9698)) { dbgOut1(eDbgAll_errEvt,'B',"HalTwiPca Unexpected NACK ",bufCnt); retResult=FAIL; break; } if (!TWI_ByteSent(HW_ADDR_TWI_PCA9698)) { if (90000 < ++breakOut_cnt) { dbgOut1(eDbgAll_errEvt,'B',"HalTwiPca TWI_SR_TXRDY exceeded ",bufCnt); retResult=FAIL; break; //Out while } continue; } breakOut_cnt = 0; TWI_WriteByte(HW_ADDR_TWI_PCA9698,*pBuffer); pBuffer++; bufCnt--; } TWI_Stop(HW_ADDR_TWI_PCA9698); while (!TWI_TransferComplete(HW_ADDR_TWI_PCA9698)) { if (90000 < ++breakOut_cnt) { dbgOut(eDbgAll_errEvt,'B',"HalTwiPca TWI_SR_TXCOMP exceeded "); break; //Out while } } return retResult; }//portInit
wxString wxPdfVolt::ProcessRules(const wxString& text) { #if 0 wxFFileOutputStream dbgOut( wxT("d:/temp/pdfdoc-indic-dbg.txt"), wxT("a")); wxTextOutputStream dbgIndic( dbgOut ); wxString str; #endif wxString processText = text; size_t n = m_rules.GetCount(); size_t j; for (j = 0; j < n; ++j) { wxPdfVoltRule* rule = (wxPdfVoltRule*) m_rules.Item(j); int matchCount; do { matchCount = rule->m_re.Replace(&processText, rule->m_replace); #if 0 str = wxEmptyString; wxString::const_iterator ch; for (ch = processText.begin(); ch != processText.end(); ++ch) { str += wxString::Format(wxT(" %04x"), *ch); } str += wxT("\n"); dbgIndic.WriteString(str); #endif } while (rule->m_repeat && matchCount > 0); } #if 0 dbgOut.Close(); #endif return processText; }
GameObject::GameObject(std::string name) : i(0), m_name(name){ dbgOut(__FUNCTION__); }
PlayerKeys2::~PlayerKeys2(void){ dbgOut(__FUNCTION__); }
Template::Template() : i(0) { dbgOut(__FUNCTION__ << "Bla"); }
CSpriteManager::~CSpriteManager(void){ dbgOut(__FUNCTION__); }
~CSpriteHook(){ dbgOut(__FUNCTION__ << " " << this); }
SerializationHelpers::~SerializationHelpers(void){ dbgOut(__FUNCTION__); }
Template::Template() { dbgOut(__FUNCTION__ << std::endl); }
Player::~Player(void){ dbgOut(__FUNCTION__); }
Player::Player() : GameObject("Player1"){ dbgOut(__FUNCTION__); }
Screen::~Screen(void){ dbgOut(__FUNCTION__ << " " << this); }
Screen::Screen(CCanvas* background, bool usesSDL2Render) : m_bUsesSDL2Render(usesSDL2Render), Hookable(true){ //, CMessageHandler() // , m_pMainScreen(mainScreen) dbgOut(__FUNCTION__ << " " << this); }
Template::~Template(void) { dbgOut(__FUNCTION__ << "Bla"); }
GameObject::~GameObject(void){ dbgOut(__FUNCTION__); }
Template::~Template(void) { dbgOut(__FUNCTION__ << std::endl); }
Template::Template(){ dbgOut(__FUNCTION__); }
PlayerKeys3::~PlayerKeys3(void){ dbgOut(__FUNCTION__); }
Template::~Template(void){ dbgOut(__FUNCTION__); }
SerializationHelpers::SerializationHelpers(){ dbgOut(__FUNCTION__); }
// ============================================================================================ void TestLauncher::run() { bool res = false; int bsize = audioDeviceSettings->getBufferSize(); unsigned int deviceChan = audioDeviceSettings->getOutputChannels(); int nbuff; int remsamples; double progressMax; releaseAudioData(); for (int i = 0; i<stimCount; i++) { if (threadShouldExit()) break; /* Create input stream for the audio file */ File af(getCurrentTest()->soundFiles[i]); wavReader = audioFormatManager.createReaderFor( af ); dbgOut( L"Loading file " + af.getFullPathName() ); if (wavReader == NULL) { lastError = L"Unable to create reader for " + getCurrentTest()->soundFiles[i]; return ; } /* get length and number of channels */ if (wavReader->numChannels > deviceChan) { lastError = L"The number of audio channels in stimuli files exceeds available device outputs."; return ; } chanCount = wavReader->numChannels; samplesCount = static_cast<unsigned int> ( wavReader->lengthInSamples ); /* adjust to the integer number of audio buffers */ nbuff = div(samplesCount,bsize).quot; remsamples = div(samplesCount,bsize).rem; if (remsamples > 0) { samplesCount = bsize*(nbuff+1); progressMax = stimCount*(nbuff+1); } else { progressMax = stimCount*nbuff; } /* create audio data buffers */ currentData = new int* [chanCount]; if (currentData == NULL) { lastError = L"Unable to allocate " + String(2*chanCount*sizeof(float*) + L"b of memory." ); return ; } /* create an array of pointers to data buffers */ for (int ch = 0; ch < chanCount; ch++) { currentData[ch] = new int[samplesCount]; if (currentData[ch] == NULL) { lastError = L"Unable to allocate " + String(samplesCount*sizeof(float*) + L"b of memory." ); /* clean up (data is massive) */ for (int k = 0; k<ch; k++) { delete [] currentData[k]; } delete [] currentData; releaseAudioData(); return ; } /* clear memory */ //zeromem(currentData[ch], sizeof(int)*samplesCount); } /* add array to audioStimData */ audioStimData.add(currentData); /* read file in memory */ for (int k=0; k<nbuff; k++) { res = wavReader->readSamples( currentData, chanCount, bsize*k, bsize*k, bsize); if (!res) { releaseAudioData(); lastError = L"Unable to read data from file " + getCurrentTest()->soundFiles[i]; return ; } /* update progress bar */ setProgress((i*nbuff + k)/progressMax); } /* read the last buffer and zero pad */ if (remsamples > 0) { /* zero-padding is done by AudioFormatReader */ res = wavReader->readSamples( currentData, chanCount, bsize*nbuff, bsize*nbuff, bsize); if (!res) { releaseAudioData(); lastError = L"Unable to read data from file " + getCurrentTest()->soundFiles[i]; return ; } } /* clean up */ delete wavReader; } /*for (int k = 0; k<chanCount; k++) { debugBuffer(getAudioData(0,k,48000), bsize*5, L"audio") + String(k)); }*/ setProgress(1.0); wait(500); }
CSpriteManager::CSpriteManager(/*SDL_Surface* screen*/){ dbgOut(__FUNCTION__); }
PlayerKeys2::PlayerKeys2(float x, float y) : m_position(x, y), m_speed(0), m_lastTick(0), m_curspeed(0) { dbgOut(__FUNCTION__); }
~EyeMover(){ dbgOut(__FUNCTION__ << " " << this); }
//============================================================================== void AudioFileConverter::run() { while ( getQueueSize() > 0 ) { { // lock jobQueue before retrieving a task const ScopedLock lock (queueLock); task = jobQueue[0]; } /* try opening the file */ File inputDataFile( task->getFileName() ); String inputFileName( inputDataFile.getFullPathName() ); if ( !inputDataFile.existsAsFile() || (inputDataFile.getSize() == 0) ) { dbgOut(L"** AudioFileConverter ** Invalid or corrupted temporary file:\t" + inputFileName); removeFromQueue(); continue; } /* try creating the input stream */ FileInputStream* fileInputStream = inputDataFile.createInputStream(); if (fileInputStream == NULL) { dbgOut(L"** AudioFileConverter ** Unable to create input stream for file:\t" + inputFileName); removeFromQueue(); continue; } dbgOut(L""); dbgOut(L" *** AudioFileConverter ***"); dbgOut(L"** AudioFileConverter ** Converting file:\t" + inputFileName + L" (" + String( inputDataFile.getSize() ) + L" b)"); int processorOutputs = task->getChannelNumber(); const int bytesPerSample = processorOutputs * sizeof(float); int bufferSize = task->getBufferSize(); double samplingRate = task->getSamplingRate(); int bitDepth = task->getBitDepth(); String audioFormatName = task->getFormat(); AudioSampleBuffer tempBuffer(1, bufferSize); // declare classes needed to save the format OwnedArray<AudioFormat> someAudioFormats; OwnedArray<AudioFormatWriter> audioFormatWriters; OwnedArray<File> audioFiles; Array<FileOutputStream*> outStreams; String audioFileName; AudioFormatWriter* tmpWriter; FileOutputStream* tmpStream; File* tmpAudioFile; String outputDir = inputDataFile.getParentDirectory().getFullPathName(); for (int i=0; i < processorOutputs ; i++) { // Delete temporary files File tmpDataFile(outputDir + File::separatorString + L"channel" + String::formatted("%.2d", i ) + ".dat"); if ( tmpDataFile != File::nonexistent) { dbgOut( L"** AudioFileConverter ** \tDeleting temporary file:\t" + tmpDataFile.getFullPathName() ); tmpDataFile.deleteFile(); } else { dbgOut( "** AudioFileConverter ** Unable to delete temporary file:\t\t" + tmpDataFile.getFullPathName() ); } // Define the format (wav is default) if (audioFormatName == "wav") someAudioFormats.add( new WavAudioFormat() ); else if (audioFormatName == "aiff") someAudioFormats.add( new AiffAudioFormat() ); else if (audioFormatName == "flac") someAudioFormats.add( new FlacAudioFormat() ); // else if (audioFormatName == "ogg") // someAudioFormats.add( new OggVorbisAudioFormat() ); else someAudioFormats.add( new WavAudioFormat() ); audioFileName = outputDir + File::separatorString + "channel" + String::formatted("%.2d",i) + someAudioFormats[i]->getFileExtensions()[0]; tmpAudioFile = new File (audioFileName); if (*tmpAudioFile == File::nonexistent) { dbgOut( L"** AudioFileConverter ** Unable to create file:\t" + audioFileName ); audioFormatWriters.clear(true); someAudioFormats.clear(true); audioFiles.clear(true); outStreams.clear(); delete fileInputStream; removeFromQueue(); continue; } audioFiles.add( tmpAudioFile ); // Delete existing files if (audioFiles[i]->existsAsFile()) { dbgOut( "** AudioFileConverter ** \tDeleting existing audio file:\t\t" + audioFileName ); if (!audioFiles[i]->deleteFile()) { dbgOut( L"** AudioFileConverter ** Unable to delete existing file:\t" + audioFileName ); audioFormatWriters.clear(true); someAudioFormats.clear(true); audioFiles.clear(true); outStreams.clear(); delete fileInputStream; removeFromQueue(); continue; } } dbgOut( "** AudioFileConverter ** \tSaving audio file:\t\t" + audioFileName ); /* Create output stream for this file */ tmpStream = audioFiles[i]->createOutputStream(); if (tmpStream == NULL) { dbgOut( L"** AudioFileConverter ** Unable to create output stream for file:\t" + audioFileName ); delete tmpAudioFile; audioFormatWriters.clear(true); someAudioFormats.clear(true); audioFiles.clear(true); outStreams.clear(); delete fileInputStream; removeFromQueue(); continue; } outStreams.add( tmpStream ); /* Create Audio Format Writer */ tmpWriter = someAudioFormats[i]->createWriterFor( outStreams[i], // streamToWriteTo, samplingRate, // sampleRateToUse, 1, // numberOfChannels, someAudioFormats[i]->getPossibleBitDepths().getLast(), // bitsPerSample - Get the maximum possible bit depth for this format NULL, // metadataValues, 0 ); if (tmpWriter == NULL) { dbgOut( L"** AudioFileConverter ** Unable to create audio format writer for:\t" + audioFileName ); delete tmpAudioFile; audioFormatWriters.clear(true); someAudioFormats.clear(true); audioFiles.clear(true); outStreams.clear(); delete fileInputStream; removeFromQueue(); continue; } audioFormatWriters.add( tmpWriter ); } // Write data to wav file int dataBlockSize = processorOutputs * bufferSize * bitDepth/8 ; MemoryBlock* buffer = new MemoryBlock( dataBlockSize, true); int64 bytesSaved = inputDataFile.getSize(); while ( !fileInputStream->isExhausted() && (fileInputStream->getPosition() < bytesSaved) ) { float* x = (float *) buffer->getData() ; int bytesRead = fileInputStream->read( (void *)x, dataBlockSize ); int numSamples = (int)( bytesRead / bytesPerSample ); for (int ch=0; ch < processorOutputs; ch++) { // const int numBytes = (int) (bytesRead/processorOutputs); tempBuffer.copyFrom( 0, // const int destChannel, 0, // const int destStartSample, x+ch*numSamples, // const float * source, numSamples // int numSamples ); audioFormatWriters[ch]->write( (const int**)(tempBuffer.getArrayOfChannels()), //AudioFormatWriter * writer, numSamples //const int numSamples ); } } // clean up delete buffer; // this should delete 'owned' objects audioFormatWriters.clear(true); someAudioFormats.clear(true); audioFiles.clear(true); // clear the outStreams without deleting objects (already deleted) outStreams.clear(); // Delete and close the stream delete fileInputStream; // Delete the data.dat file dbgOut( L"** AudioFileConverter ** \tDeleting temporary file:\t" + inputFileName ); inputDataFile.deleteFile(); // Delete the task removeFromQueue(); dbgOut( "** AudioFileConverter ** Files saved." ); } dbgOut( "** AudioFileConverter ** Thread terminates." ); }