int oslVramMgrSetParameters(void *baseAddr, int size) { int curVramSize = osl_vramSize; int blockNum = osl_vramBlocksNb - 1; int sizeDiff; if (!osl_useVramManager) return 0; //La taille est toujours multiple de 16 - arrondir au bloc supérieur if (size & 15) size += 16; //Différence de taille (négatif pour réduction, positif pour aggrandissement) sizeDiff = size - curVramSize; //Le dernier bloc est TOUJOURS libre, même s'il reste 0 octet. Cf la bidouille dans ulTexVramAlloc if (isBlockFree(blockNum) && getBlockSize(blockNum) + sizeDiff >= 0) { setBlockSize(blockNum, getBlockSize(blockNum) + sizeDiff); osl_vramBase = (u32)baseAddr; osl_vramSize = size; //Pour ceux qui ne veulent pas utiliser le gestionnaire... osl_currentVramPtr = osl_vramBase; } else return 0; return 1; }
void CHalfBandFilter::processBlock(float* data, int numSamples) { setBlockSize(numSamples); double* proc = bufferDouble.getPtr(0); { int n=0; for (int i=0; i<numSamples; ++i) { const float x = data[i]; proc[n++] = x; proc[n++] = x; } } filter->processBlock(proc, numSamples); { int n=0; for (int i=0; i<numSamples; ++i) { const float output = float(proc[n++] + oldout) * 0.5f; oldout = proc[n++]; data[i] = output; } } }
MDFlib::MDFTX::MDFTX(QFile* file, long pTX, unsigned short byteOrder) { myMDFFile = file; QByteArray byteArray; QDataStream instream(myMDFFile); QString blockType; unsigned short blockSize; QString text; if(byteOrder == 0) { instream.setByteOrder(QDataStream::LittleEndian); } else { instream.setByteOrder(QDataStream::BigEndian); } myMDFFile->seek(pTX); byteArray = myMDFFile->read(2); blockType.append(byteArray.data()); myMDFFile->seek(pTX + 2); instream >> blockSize; myMDFFile->seek(pTX + 4); byteArray = myMDFFile->read(blockSize); text.append(byteArray.data()); setBlockType(&blockType); setBlockSize(blockSize); setText(&text); }
void ofxZenGarden::processNonInterleaved(float *input, float *output, int frameCount) { if(context==NULL || !running) return; setBlockSize(frameCount); memset(output, 0, frameCount*sizeof(float)*numOutputChannels); zg_process(context, input, output); }
float* OverSampler2x::processUp(float* in, int numSamples) { setBlockSize(2*numSamples); upSampler.processBlock(in, data, numSamples); return data; }
rWAVAudio::rWAVAudio(const char *sName, EDtError &rc) : FileReader(sName, rc) { if (rc != DT_OK) return; readHeaders(); setBlockSize(2352); setLittleEndian(true); setType(Data_Audio); }
FixedPointIter<ScalarType,MV,OP>::FixedPointIter(const Teuchos::RCP<LinearProblem<ScalarType,MV,OP> > &problem, const Teuchos::RCP<OutputManager<ScalarType> > &printer, const Teuchos::RCP<StatusTest<ScalarType,MV,OP> > &tester, Teuchos::ParameterList ¶ms ): lp_(problem), om_(printer), stest_(tester), numRHS_(0), initialized_(false), stateStorageInitialized_(false), iter_(0) { setBlockSize(params.get("Block Size",MVT::GetNumberVecs(*problem->getCurrRHSVec()))); }
//Note: il faut traduire une vraie adresse en offset int oslVramMgrFreeBlock(void *blockAddress, int blockSize) { int i, j, updateNeeded; int blockOffset = (u32)blockAddress - (u32)osl_vramBase; //Sans le manager, c'est plus simple... if (!osl_useVramManager) { osl_currentVramPtr -= blockSize; //Pas vraiment utile, juste là pour s'assurer qu'on ne dépassera jamais de l'espace alloué if (osl_currentVramPtr < osl_vramBase) osl_currentVramPtr = osl_vramBase; return 1; } //Trouvons le bloc qui va bien for (i=0;i<osl_vramBlocksNb;i++) { if (getBlockOffset(i) == blockOffset) break; } //Impossible de trouver le bloc if (i >= osl_vramBlocksNb) return 0; //Le bloc est maintenant libre ^^ setBlockFree(i, 1); //Bon maintenant reste à "assembler" les blocs libres adjacents do { updateNeeded = 0; for (j=0;j<osl_vramBlocksNb-1;j++) { //Cherchons deux blocs adjacents if ((isBlockFree(j) && isBlockFree(j + 1)) || (isBlockFree(j) && getBlockSize(j) == 0)) { //Assemblons ces blocs maintenant int newSize = getBlockSize(j) + getBlockSize(j + 1), newAdd = getBlockOffset(j); memmove(osl_vramBlocks + j, osl_vramBlocks + j + 1, sizeof(OSL_VRAMBLOCK) * (osl_vramBlocksNb - j - 1)); setBlockOffset(j, newAdd); setBlockSize(j, newSize); //Le bloc entre deux est supprimé osl_vramBlocksNb--; //ATT: On devra refaire un tour pour vérifier si de nouveaux blocs n'ont pas été créés updateNeeded = 1; } } } while (updateNeeded); return 1; }
bool Binary::setConfiguration(QHash<QString, QString> propertiesList) { bool res = TransformAbstract::setConfiguration(propertiesList); bool ok = true; int val = 0; val = propertiesList.value(XMLBLOCKSIZE).toInt(&ok); if (!ok) { res = false; emit error(tr("Invalid value for %1").arg(XMLBLOCKSIZE),id); } else { res = setBlockSize(val) && res; } return res; }
//------------------------------------------------------------------------------------------------------- VstIntPtr AudioEffect::dispatcher (VstInt32 opcode, VstInt32 index, VstIntPtr value, void* ptr, float opt) { VstIntPtr v = 0; switch (opcode) { case effOpen: open (); break; case effClose: close (); break; case effSetProgram: if (value < numPrograms) setProgram ((VstInt32)value); break; case effGetProgram: v = getProgram (); break; case effSetProgramName: setProgramName ((char*)ptr); break; case effGetProgramName: getProgramName ((char*)ptr); break; case effGetParamLabel: getParameterLabel (index, (char*)ptr); break; case effGetParamDisplay: getParameterDisplay (index, (char*)ptr); break; case effGetParamName: getParameterName (index, (char*)ptr); break; case effSetSampleRate: setSampleRate (opt); break; case effSetBlockSize: setBlockSize ((VstInt32)value); break; case effMainsChanged: if (!value) suspend (); else resume (); break; #if !VST_FORCE_DEPRECATED case effGetVu: v = (VstIntPtr)(getVu () * 32767.); break; #endif //---Editor------------ case effEditGetRect: if (editor) v = editor->getRect ((ERect**)ptr) ? 1 : 0; break; case effEditOpen: if (editor) v = editor->open (ptr) ? 1 : 0; break; case effEditClose: if (editor) editor->close (); break; case effEditIdle: if (editor) editor->idle (); break; #if (TARGET_API_MAC_CARBON && !VST_FORCE_DEPRECATED) case effEditDraw: if (editor) editor->draw ((ERect*)ptr); break; case effEditMouse: if (editor) v = editor->mouse (index, value); break; case effEditKey: if (editor) v = editor->key (value); break; case effEditTop: if (editor) editor->top (); break; case effEditSleep: if (editor) editor->sleep (); break; #endif case DECLARE_VST_DEPRECATED (effIdentify): v = CCONST ('N', 'v', 'E', 'f'); break; //---Persistence------- case effGetChunk: v = getChunk ((void**)ptr, index ? true : false); break; case effSetChunk: v = setChunk (ptr, (VstInt32)value, index ? true : false); break; } return v; }
BlockCGIter<ScalarType,MV,OP>::BlockCGIter(const Teuchos::RCP<LinearProblem<ScalarType,MV,OP> > &problem, const Teuchos::RCP<OutputManager<ScalarType> > &printer, const Teuchos::RCP<StatusTest<ScalarType,MV,OP> > &tester, const Teuchos::RCP<MatOrthoManager<ScalarType,MV,OP> > &ortho, Teuchos::ParameterList ¶ms ): lp_(problem), om_(printer), stest_(tester), ortho_(ortho), blockSize_(0), initialized_(false), stateStorageInitialized_(false), iter_(0) { // Set the block size and allocate data int bs = params.get("Block Size", 1); setBlockSize( bs ); }
//----------------------------------------------------------------------------- long AudioEffect::dispatcher(long opCode, long index, long value, void *ptr, float opt) { long v = 0; switch(opCode) { case effOpen: open(); break; case effClose: close(); break; case effSetProgram: if(value < numPrograms) setProgram(value); break; case effGetProgram: v = getProgram(); break; case effSetProgramName: setProgramName((char *)ptr); break; case effGetProgramName: getProgramName((char *)ptr); break; case effGetParamLabel: getParameterLabel(index, (char *)ptr); break; case effGetParamDisplay: getParameterDisplay(index, (char *)ptr); break; case effGetParamName: getParameterName(index, (char *)ptr); break; case effSetSampleRate: setSampleRate(opt); break; case effSetBlockSize: setBlockSize(value); break; case effMainsChanged: if(!value) suspend(); else resume(); break; case effGetVu: v = (long)(getVu() * 32767.); break; // editor case effEditGetRect: if(editor) v = editor->getRect((ERect **)ptr); break; case effEditOpen: if(editor) v = editor->open(ptr); break; case effEditClose: if(editor) editor->close(); break; case effEditIdle: if(editor) editor->idle(); break; #if MAC case effEditDraw: if(editor) editor->draw((ERect *)ptr); break; case effEditMouse: if(editor) v = editor->mouse(index, value); break; case effEditKey: if(editor) v = editor->key(value); break; case effEditTop: if(editor) editor->top(); break; case effEditSleep: if(editor) editor->sleep(); break; #endif // new case effIdentify: v = 'NvEf'; break; case effGetChunk: v = getChunk((void**)ptr, index ? true : false); break; case effSetChunk: v = setChunk(ptr, value, index ? true : false); break; } return v; }
void oslVramMgrInit() { //If we don't use it OR it has already been initialized if (!osl_useVramManager || osl_vramBlocksMax > 0) return; osl_vramBlocksMax = DEFAULT_TABLE_SIZE; osl_vramBlocksNb = 1; osl_vramBlocks = (OSL_VRAMBLOCK*)malloc(osl_vramBlocksMax * sizeof(OSL_VRAMBLOCK)); if (!osl_vramBlocks){ osl_useVramManager = 0; osl_vramBlocksMax = 0; osl_vramBlocksNb = 0; return; } //Premier bloc: libre, taille totale de la VRAM, adresse 0 setBlockOffset(0, 0); //La taille en blocs doit être divisée par 16 puisqu'on n'utilise pas des octets sinon il serait impossible de coder toute la VRAM sur 16 bits setBlockSize(0, osl_vramSize); setBlockFree(0, 1); }
bool MzSpectrogramFFTW::initialise(size_t channels, size_t stepsize, size_t blocksize) { if (channels < getMinChannelCount() || channels > getMaxChannelCount()) { return false; } // step size and block size should never be zero if (stepsize <= 0 || blocksize <= 0) { return false; } setChannelCount(channels); setBlockSize(blocksize); setStepSize(stepsize); mz_minbin = getParameterInt("minbin"); mz_maxbin = getParameterInt("maxbin"); if (mz_minbin >= getBlockSize()/2) { mz_minbin = getBlockSize()/2-1; } if (mz_maxbin >= getBlockSize()/2) { mz_maxbin = getBlockSize()/2-1; } if (mz_maxbin < 0) { mz_maxbin = getBlockSize()/2-1; } if (mz_maxbin < mz_minbin) { std::swap(mz_minbin, mz_maxbin); } // The signal size/transform size are equivalent for this // plugin but the FFTW can handle any size transform. // If the size of the transform is a multiple of small // prime numbers the FFT will be used, otherwise it will // be slow (when block size=1021 for example). mz_transformer.setSize(getBlockSize()); delete [] mz_wind_buff; mz_wind_buff = new double[getBlockSize()]; makeHannWindow(mz_wind_buff, getBlockSize()); return true; }
void ofxZenGarden::process(float *input, float *output, int frameCount) { if(context==NULL || !running) return; setBlockSize(frameCount); memset(output, 0, frameCount*sizeof(float)*numOutputChannels); zg_process(context, input, outputBuffer); if(numOutputChannels==1) { memcpy(output, outputBuffer, sizeof(float)*frameCount); } else if(numOutputChannels==2) { for(int i = 0; i < frameCount; i++) { output[i*2] = outputBuffer[i]; output[i*2 + 1] = outputBuffer[i + blockSize]; } } else { for(int i = 0; i < blockSize; i++) { for(int channel = 0; channel < numOutputChannels; channel++) { output[i*numOutputChannels + channel] = outputBuffer[i + channel*blockSize]; } } } }
void CHalfBandFilter::processBlock(float* dataL, float* dataR, int numSamples) { setBlockSize(numSamples); float* proc = bufferFloat.getPtr(0); { int n=0; for (int i=0; i<numSamples; ++i) { const float l = dataL[i]; const float r = dataR[i]; proc[n++] = l; proc[n++] = l; proc[n++] = r; proc[n++] = r; } } filter->processBlock(proc, numSamples); { int n=0; for (int i=0; i<numSamples; ++i) { const float outputL = float(proc[n++] + oldOutL) * 0.5f; const float outputR = float(proc[n++] + oldOutR) * 0.5f; oldOutL = proc[n++]; oldOutR = proc[n++]; dataL[i] = outputL; dataR[i] = outputR; } } }
void ZBlockGrid::setBlockSize(const ZIntPoint &s) { setBlockSize(s.getX(), s.getY(), s.getZ()); }
Grid* Grid::init() { return setBlockSize(D3DXVECTOR2(1, 1))->setSize(4); }
void OverSampler2x::processDown(float* inL, float* inR, float* outL, float* outR, int numSamples) { setBlockSize(2*numSamples); downSampler.processBlock(inL, inR, outL, outR, numSamples); }
void *oslVramMgrAllocBlock(int blockSize) { int i; osl_skip = osl_vramBlocks[0].size; //Le bloc ne peut pas être de taille nulle ou négative if (blockSize <= 0) return NULL; //La taille est toujours multiple de 16 - arrondir au bloc supérieur if (blockSize & 15) blockSize += 16; //Sans le manager, c'est plus simple... if (!osl_useVramManager) { int ptr = osl_currentVramPtr; //Dépassement de la mémoire? if (osl_currentVramPtr + blockSize >= osl_vramBase + osl_vramSize) return NULL; osl_currentVramPtr += blockSize; return (void*)ptr; } for (i=0;i<osl_vramBlocksNb;i++) { //Ce bloc est-il suffisant? if (isBlockFree(i) && getBlockSize(i) >= blockSize) break; } //Aucun bloc libre if (i >= osl_vramBlocksNb) return NULL; //Pile la mémoire qu'il faut? - pas géré, il faut toujours que le dernier bloc soit marqué comme libre (même s'il reste 0 octet) pour ulSetTexVramParameters if (getBlockSize(i) == blockSize && i != osl_vramBlocksNb - 1) { //Il n'est plus libre setBlockFree(i, 0); } else { //On va ajouter un nouveau bloc osl_vramBlocksNb++; //Plus de mémoire pour le tableau? On l'aggrandit if (osl_vramBlocksNb >= osl_vramBlocksMax) { OSL_VRAMBLOCK *oldBlock = osl_vramBlocks; osl_vramBlocksMax += DEFAULT_TABLE_SIZE; osl_vramBlocks = (OSL_VRAMBLOCK*)realloc(osl_vramBlocks, osl_vramBlocksMax); //Vérification que la mémoire a bien pu être allouée if (!osl_vramBlocks) { osl_vramBlocks = oldBlock; osl_vramBlocksMax -= DEFAULT_TABLE_SIZE; //Pas assez de mémoire return NULL; } } //Décalage pour insérer notre nouvel élément memmove(osl_vramBlocks + i + 1, osl_vramBlocks + i, sizeof(OSL_VRAMBLOCK) * (osl_vramBlocksNb - i - 1)); //Remplissons notre nouveau bloc setBlockSize(i, blockSize); //Il a l'adresse du bloc qui était là avant setBlockOffset(i, getBlockOffset(i + 1)); //Il n'est pas libre setBlockFree(i, 0); //Pour le prochain, sa taille diminue setBlockSize(i + 1, getBlockSize(i + 1) - blockSize); //ATTENTION: calcul d'offset setBlockOffset(i + 1, getBlockOffset(i + 1) + blockSize); } //Note: il faut traduire l'offset en vraie adresse return (void*)(getBlockOffset(i) + osl_vramBase); }