CFX_ByteTextBuf& CFX_ByteTextBuf::operator << (double f) { char buf[32]; FX_STRSIZE len = FX_ftoa((FX_FLOAT)f, buf); AppendBlock(buf, len); return *this; }
CFX_ByteTextBuf& CFX_ByteTextBuf::operator << (int i) { char buf[32]; FXSYS_itoa(i, buf, 10); AppendBlock(buf, (FX_STRSIZE)FXSYS_strlen(buf)); return *this; }
CFX_ByteTextBuf& CFX_ByteTextBuf::operator << (FX_DWORD i) { char buf[32]; FXSYS_itoa(i, buf, 10); AppendBlock(buf, FXSYS_strlen(buf)); return *this; }
bool NewSong(void) { root->tempo=128; root->lpb=4; root->signature = ratio(4,4); pc->initplaying=false; pc->isplaying=false; AppendBlock(); BL_init(); if(OpenTrackerWindow(20,20,00,00)==-1) return false; return true; }
/* ** Add additional blocks to the block list in order to cover ** all elements on the element list. ** ** If any old blocks are found on the element list, they must ** be left over from a prior rendering. Unlink and delete them. */ void HtmlFormBlocks(HtmlWidget *htmlPtr){ HtmlElement *pElem; if( htmlPtr->lastBlock ){ pElem = FillOutBlock(htmlPtr, htmlPtr->lastBlock); }else{ pElem = htmlPtr->pFirst; } while( pElem ){ int cnt; pElem = FindStartOfNextBlock(htmlPtr, pElem, &cnt); if( pElem ){ HtmlBlock *pNew = AllocBlock(); if( htmlPtr->lastBlock ){ htmlPtr->lastBlock->base.count += cnt; } AppendBlock(htmlPtr, pElem, pNew); pElem = FillOutBlock(htmlPtr, pNew); } } }
CFX_WideTextBuf& CFX_WideTextBuf::operator<<(const CFX_WideTextBuf& buf) { AppendBlock(buf.m_pBuffer, buf.m_DataSize); return *this; }
CFX_WideTextBuf& CFX_WideTextBuf::operator<<(const FX_WCHAR* lpsz) { AppendBlock(lpsz, FXSYS_wcslen(lpsz) * sizeof(FX_WCHAR)); return *this; }
CFX_WideTextBuf& CFX_WideTextBuf::operator<<(const CFX_WideString& str) { AppendBlock(str.c_str(), str.GetLength() * sizeof(FX_WCHAR)); return *this; }
CFX_ByteTextBuf& CFX_ByteTextBuf::operator<<(const CFX_ByteStringC& lpsz) { AppendBlock(lpsz.GetPtr(), lpsz.GetLength()); return *this; }
bool Sequence::Paste(sampleCount s, const Sequence *src) { if (s < 0) s = 0; if (s >= mNumSamples) s = mNumSamples; // Quick check to make sure that it doesn't overflow if (((double)mNumSamples) + ((double)src->mNumSamples) > wxLL(9223372036854775807)) return false; BlockArray *srcBlock = src->mBlock; sampleCount addedLen = src->mNumSamples; unsigned int srcNumBlocks = srcBlock->Count(); int sampleSize = SAMPLE_SIZE(mSampleFormat); if (addedLen == 0 || srcNumBlocks == 0) return true; unsigned int b = FindBlock(s); unsigned int numBlocks = mBlock->Count(); if (numBlocks == 0 || (s == mNumSamples && mBlock->Item(numBlocks-1)->f->GetLength() >= mMinSamples)) { // Special case: this track is currently empty, or it's safe to append // onto the end because the current last block is longer than the // minimum size for (unsigned int i = 0; i < srcNumBlocks; i++) AppendBlock(srcBlock->Item(i)); return ConsistencyCheck(wxT("Paste branch one")); } if (b >= 0 && b < numBlocks && mBlock->Item(b)->f->GetLength() + addedLen < mMaxSamples) { // Special case: we can fit all of the new samples inside of // one block! samplePtr buffer = NewSamples(mMaxSamples, mSampleFormat); int splitPoint = s - mBlock->Item(b)->start; Read(buffer, mSampleFormat, mBlock->Item(b), 0, splitPoint); src->Get(buffer + splitPoint*sampleSize, mSampleFormat, 0, addedLen); Read(buffer + (splitPoint + addedLen)*sampleSize, mSampleFormat, mBlock->Item(b), splitPoint, mBlock->Item(b)->f->GetLength() - splitPoint); SeqBlock *largerBlock = new SeqBlock(); largerBlock->start = mBlock->Item(b)->start; int largerBlockLen = mBlock->Item(b)->f->GetLength() + addedLen; if (largerBlockLen > mMaxSamples) largerBlockLen = mMaxSamples; // Prevent overruns, per NGS report for UmixIt. largerBlock->f = mDirManager->NewSimpleBlockFile(buffer, largerBlockLen, mSampleFormat); mDirManager->Deref(mBlock->Item(b)->f); delete mBlock->Item(b); mBlock->Item(b) = largerBlock; for (unsigned int i = b + 1; i < numBlocks; i++) mBlock->Item(i)->start += addedLen; mNumSamples += addedLen; DeleteSamples(buffer); return ConsistencyCheck(wxT("Paste branch two")); } // Case two: if we are inserting four or fewer blocks, // it's simplest to just lump all the data together // into one big block along with the split block, // then resplit it all unsigned int i; BlockArray *newBlock = new BlockArray(); newBlock->Alloc(numBlocks + srcNumBlocks + 2); int newNumBlocks = 0; for (i = 0; i < b; i++) { newBlock->Add(mBlock->Item(i)); newNumBlocks++; } SeqBlock *splitBlock = mBlock->Item(b); sampleCount splitLen = mBlock->Item(b)->f->GetLength(); int splitPoint = s - splitBlock->start; if (srcNumBlocks <= 4) { sampleCount sum = splitLen + addedLen; samplePtr sumBuffer = NewSamples(sum, mSampleFormat); Read(sumBuffer, mSampleFormat, splitBlock, 0, splitPoint); src->Get(sumBuffer + splitPoint * sampleSize, mSampleFormat, 0, addedLen); Read(sumBuffer + (splitPoint + addedLen) * sampleSize, mSampleFormat, splitBlock, splitPoint, splitBlock->f->GetLength() - splitPoint); BlockArray *split = Blockify(sumBuffer, sum); for (i = 0; i < split->Count(); i++) { split->Item(i)->start += splitBlock->start; newBlock->Add(split->Item(i)); newNumBlocks++; } delete split; DeleteSamples(sumBuffer); } else { // The final case is that we're inserting at least five blocks. // We divide these into three groups: the first two get merged // with the first half of the split block, the middle ones get // copied in as is, and the last two get merged with the last // half of the split block. sampleCount srcFirstTwoLen = srcBlock->Item(0)->f->GetLength() + srcBlock->Item(1)->f->GetLength(); sampleCount leftLen = splitPoint + srcFirstTwoLen; samplePtr leftBuffer = NewSamples(leftLen, mSampleFormat); Read(leftBuffer, mSampleFormat, splitBlock, 0, splitPoint); src->Get(leftBuffer + splitPoint*sampleSize, mSampleFormat, 0, srcFirstTwoLen); BlockArray *split = Blockify(leftBuffer, leftLen); for (i = 0; i < split->Count(); i++) { split->Item(i)->start += splitBlock->start; newBlock->Add(split->Item(i)); newNumBlocks++; } delete split; DeleteSamples(leftBuffer); for (i = 2; i < srcNumBlocks - 2; i++) { SeqBlock *insertBlock = new SeqBlock(); insertBlock->start = srcBlock->Item(i)->start + s; insertBlock->f = mDirManager->CopyBlockFile(srcBlock->Item(i)->f); if (!insertBlock->f) { // TODO error: Could not paste! (Out of disk space?) return false; } newBlock->Add(insertBlock); newNumBlocks++; } sampleCount srcLastTwoLen = srcBlock->Item(srcNumBlocks - 2)->f->GetLength() + srcBlock->Item(srcNumBlocks - 1)->f->GetLength(); sampleCount rightSplit = splitBlock->f->GetLength() - splitPoint; sampleCount rightLen = rightSplit + srcLastTwoLen; samplePtr rightBuffer = NewSamples(rightLen, mSampleFormat); sampleCount lastStart = srcBlock->Item(srcNumBlocks - 2)->start; src->Get(rightBuffer, mSampleFormat, lastStart, srcLastTwoLen); Read(rightBuffer + srcLastTwoLen * sampleSize, mSampleFormat, splitBlock, splitPoint, rightSplit); sampleCount pos = s + lastStart; split = Blockify(rightBuffer, rightLen); for (i = 0; i < split->Count(); i++) { split->Item(i)->start += pos; newBlock->Add(split->Item(i)); newNumBlocks++; } delete split; DeleteSamples(rightBuffer); } mDirManager->Deref(splitBlock->f); delete splitBlock; // Copy remaining blocks to new block array and // swap the new block array in for the old for (i = b + 1; i < numBlocks; i++) { mBlock->Item(i)->start += addedLen; newBlock->Add(mBlock->Item(i)); newNumBlocks++; } delete mBlock; mBlock = newBlock; mNumSamples += addedLen; return ConsistencyCheck(wxT("Paste branch three")); }
//! Appends the PinnedBlock virtual void AppendPinnedBlock(PinnedBlock&& b, bool is_last_block) { return AppendBlock(std::move(b).MoveToBlock(), is_last_block); }
void WaveTrack::Paste(double t, VTrack * src) { wxASSERT(src->GetKind() == WaveTrack::Wave); envelope.ExpandRegion(t, src->GetMaxLen()); #if wxUSE_THREADS wxMutexLocker lock(*blockMutex); #endif sampleCount s = (sampleCount) ((t - tOffset) * rate + 0.5); if (s < 0) s = 0; if (s >= numSamples) s = numSamples; BlockArray *srcBlock = ((WaveTrack *) src)->GetBlockArray(); int addedLen = ((WaveTrack *) src)->numSamples; int srcNumBlocks = srcBlock->Count(); if (addedLen == 0 || srcNumBlocks == 0) return; int b = FindBlock(s); int numBlocks = block->Count(); if (numBlocks == 0) { // Special case: this track is currently empty. for (int i = 0; i < srcNumBlocks; i++) AppendBlock(srcBlock->Item(i)); envelope.SetTrackLen(numSamples / rate); ConsistencyCheck("Paste branch one"); return; } if (b >= 0 && b < numBlocks && block->Item(b)->len + addedLen < maxSamples) { // Special case: we can fit all of the new samples inside of // one block! sampleType *buffer = new sampleType[maxSamples]; int splitPoint = s - block->Item(b)->start; Read(buffer, block->Item(b), 0, splitPoint); ((WaveTrack *) src)->Get(&buffer[splitPoint], 0, addedLen); Read(&buffer[splitPoint + addedLen], block->Item(b), splitPoint, block->Item(b)->len - splitPoint); WaveBlock *largerBlock = new WaveBlock(); largerBlock->start = block->Item(b)->start; largerBlock->len = block->Item(b)->len + addedLen; largerBlock->f = dirManager->NewBlockFile(); bool inited = InitBlock(largerBlock); wxASSERT(inited); FirstWrite(buffer, largerBlock, largerBlock->len); dirManager->Deref(block->Item(b)->f); delete block->Item(b); block->Item(b) = largerBlock; for (int i = b + 1; i < numBlocks; i++) block->Item(i)->start += addedLen; numSamples += addedLen; delete[]buffer; envelope.SetTrackLen(numSamples / rate); ConsistencyCheck("Paste branch two"); return; } // Case two: if we are inserting four or fewer blocks, // it's simplest to just lump all the data together // into one big block along with the split block, // then resplit it all int i; BlockArray *newBlock = new BlockArray(); newBlock->Alloc(numBlocks + srcNumBlocks + 2); int newNumBlocks = 0; for (i = 0; i < b; i++) { newBlock->Add(block->Item(i)); newNumBlocks++; } WaveBlock *splitBlock = block->Item(b); sampleCount splitLen = block->Item(b)->len; int splitPoint = s - splitBlock->start; if (srcNumBlocks <= 4) { sampleCount sum = splitLen + addedLen; sampleType *sumBuffer = new sampleType[sum]; Read(sumBuffer, splitBlock, 0, splitPoint); ((WaveTrack *) src)->Get(&sumBuffer[splitPoint], 0, addedLen); Read(&sumBuffer[splitPoint + addedLen], splitBlock, splitPoint, splitBlock->len - splitPoint); BlockArray *split = Blockify(sumBuffer, sum); for (i = 0; i < split->Count(); i++) { split->Item(i)->start += splitBlock->start; newBlock->Add(split->Item(i)); newNumBlocks++; } delete split; delete[]sumBuffer; } else { // The final case is that we're inserting at least five blocks. // We divide these into three groups: the first two get merged // with the first half of the split block, the middle ones get // copied in as is, and the last two get merged with the last // half of the split block. sampleCount srcFirstTwoLen = srcBlock->Item(0)->len + srcBlock->Item(1)->len; sampleCount leftLen = splitPoint + srcFirstTwoLen; sampleType *leftBuffer = new sampleType[leftLen]; Read(leftBuffer, splitBlock, 0, splitPoint); ((WaveTrack *) src)->Get(&leftBuffer[splitPoint], 0, srcFirstTwoLen); BlockArray *split = Blockify(leftBuffer, leftLen); for (i = 0; i < split->Count(); i++) { split->Item(i)->start += splitBlock->start; newBlock->Add(split->Item(i)); newNumBlocks++; } delete split; delete[]leftBuffer; for (i = 2; i < srcNumBlocks - 2; i++) { WaveBlock *insertBlock = new WaveBlock(); insertBlock->start = srcBlock->Item(i)->start + s; insertBlock->len = srcBlock->Item(i)->len; insertBlock->min = srcBlock->Item(i)->min; insertBlock->max = srcBlock->Item(i)->max; insertBlock->f = dirManager->CopyBlockFile(srcBlock->Item(i)->f); if (!insertBlock->f) { wxMessageBox("Could not paste! (Out of disk space?)"); } newBlock->Add(insertBlock); newNumBlocks++; } sampleCount srcLastTwoLen = srcBlock->Item(srcNumBlocks - 2)->len + srcBlock->Item(srcNumBlocks - 1)->len; sampleCount rightSplit = splitBlock->len - splitPoint; sampleCount rightLen = rightSplit + srcLastTwoLen; sampleType *rightBuffer = new sampleType[rightLen]; sampleCount lastStart = srcBlock->Item(srcNumBlocks - 2)->start; ((WaveTrack *) src)->Get(rightBuffer, lastStart, srcLastTwoLen); Read(&rightBuffer[srcLastTwoLen], splitBlock, splitPoint, rightSplit); sampleCount pos = s + lastStart; split = Blockify(rightBuffer, rightLen); for (i = 0; i < split->Count(); i++) { split->Item(i)->start += pos; newBlock->Add(split->Item(i)); newNumBlocks++; } delete split; delete[]rightBuffer; } dirManager->Deref(splitBlock->f); delete splitBlock; // Copy remaining blocks to new block array and // swap the new block array in for the old for (i = b + 1; i < numBlocks; i++) { block->Item(i)->start += addedLen; newBlock->Add(block->Item(i)); newNumBlocks++; } delete block; block = newBlock; numSamples += addedLen; envelope.SetTrackLen(numSamples / rate); ConsistencyCheck("Paste branch three"); }
CFX_WideTextBuf& CFX_WideTextBuf::operator << (FX_LPCWSTR lpsz) { AppendBlock(lpsz, (FX_STRSIZE)FXSYS_wcslen(lpsz)*sizeof(FX_WCHAR)); return *this; }
CFX_WideTextBuf& CFX_WideTextBuf::operator << (FX_WSTR str) { AppendBlock(str.GetPtr(), str.GetLength() * sizeof(FX_WCHAR)); return *this; }
CFX_ByteTextBuf& CFX_ByteTextBuf::operator << (FX_BSTR lpsz) { AppendBlock((FX_LPCBYTE)lpsz, lpsz.GetLength()); return *this; }