Esempio n. 1
0
// private signal constructor: make a reference to a slice of the external signal.
// of course this object will be meaningless when the other Signal is gone, so
// use wih care -- only as a temporary, ideally.  Is there a way to force 
// the object to be a temporary?  In other words not allow a named 
// MLSignal notTemporary(pOther, 4);
//
// NOTE this signal will not pass checkIntegrity()!
//
MLSignal::MLSignal(const MLSignal* other, int slice) : 
	mData(0),
	mDataAligned(0),
	mCopy(0),
	mCopyAligned(0)
{
	mRate = kMLToBeCalculated;
	setConstant(false);
	if(other->getDepth() > 1) // make 2d slice
	{
		mDataAligned = other->mDataAligned + other->plane(slice);
		mWidth = other->mWidth;
		mHeight = other->mHeight;
		mDepth = 1;
	}
	else if(other->getHeight() > 1) // make 1d slice
	{
		mDataAligned = other->mDataAligned + other->row(slice);
		mWidth = other->mWidth;
		mHeight = 1;
		mDepth = 1;
	}
	else
	{
		// signal to take slice of must be 2d or 3d!
		assert(false);
	}
	mWidthBits = bitsToContain(mWidth);
	mHeightBits = bitsToContain(mHeight);
	mDepthBits = bitsToContain(mDepth);
	mSize = 1 << mWidthBits << mHeightBits << mDepthBits;
	mConstantMask = mSize - 1;
}
Esempio n. 2
0
MLProc::err MLProcRingBuffer::resize() 
{	
	MLProc::err e = OK;
	int size = 1 << bitsToContain((int)getParam("length"));
	void * buf;
	
	// debug() << "allocating " << size << " samples for ringbuffer " << getName() << "\n";

	buf = mRing.setDims(size);
	
	if (!buf)
	{
		debug() << "MLRingBuffer: allocate failed!\n";
		e = memErr;
	}
	else
	{	
		PaUtil_InitializeRingBuffer( &mBuf, sizeof(MLSample), size, buf );
        
		// get trash signal
		if (getParam("mode") != eMLRingBufferNoTrash)
		{
			mTrashSignal.setDims(size);	
		}
	}

	return e;
}
Esempio n. 3
0
// only convert .aupreset (AU) to .mlpreset (VST) now. After Aalto 1.6 / Kaivo 1.2 there will be no need to convert presets.
void MLPluginController::convertPresets()
{
    if(!mpProcessor) return;
	
	mMaxFileQueueSize = 0;
	mFilesProcessed = 0;
	mFilesConverted = 0;
	
    File presetsFolder = getDefaultFileLocation(kOldPresetFiles);
    if (presetsFolder != File::nonexistent)
    {
		// turn off audio -- will be turned back on by finish or cancel
        mpProcessor->suspendProcessing(true);
		
		// clear presets collection
		mpProcessor->clearPresetCollection();

		// clear menu
		findMenuByName("preset")->clear();
		
		mPresetsToConvertAU1 = std::auto_ptr<MLFileCollection>(new MLFileCollection("convert_presets_au1", getDefaultFileLocation(kOldPresetFiles), ".aupreset"));
		mPresetsToConvertAU1->addListener(this);
		mPresetsToConvertAU2 = std::auto_ptr<MLFileCollection>(new MLFileCollection("convert_presets_au2", getDefaultFileLocation(kOldPresetFiles2), ".aupreset"));
		mPresetsToConvertAU2->addListener(this);
		mPresetsToConvertVST1 = std::auto_ptr<MLFileCollection>(new MLFileCollection("convert_presets_vst1", getDefaultFileLocation(kOldPresetFiles), ".mlpreset"));
		mPresetsToConvertVST1->addListener(this);
		mPresetsToConvertVST2 = std::auto_ptr<MLFileCollection>(new MLFileCollection("convert_presets_vst2", getDefaultFileLocation(kOldPresetFiles2), ".mlpreset"));
		mPresetsToConvertVST2->addListener(this);
		
		mFilesToProcess = 0;
		mFilesToProcess += mPresetsToConvertAU1->searchForFilesImmediate();
		mFilesToProcess += mPresetsToConvertAU2->searchForFilesImmediate();
		mFilesToProcess += mPresetsToConvertVST1->searchForFilesImmediate();
		mFilesToProcess += mPresetsToConvertVST2->searchForFilesImmediate();
		
		int fileBufferSize = 1 << bitsToContain(mFilesToProcess);
		mFileActionData.resize(fileBufferSize);
		PaUtil_InitializeRingBuffer( &mFileActionQueue, sizeof(FileAction), fileBufferSize, &(mFileActionData[0]) );
		
		// convert files in immediate mode and wait for finish.
		int interFileDelay = 0;
		mPresetsToConvertAU1->processFilesImmediate(interFileDelay);
		mPresetsToConvertAU2->processFilesImmediate(interFileDelay);
		mPresetsToConvertVST1->processFilesImmediate(interFileDelay);
		mPresetsToConvertVST2->processFilesImmediate(interFileDelay);
		mConvertingPresets = true;
		
		(new ConvertProgressDisplayThread(this))->launchThread();
		
//		startTimer(5); // speed up action for convert
    }
    else
    {
        debug() << "convertPresets: couldn't find preset folder " << presetsFolder.getFullPathName() << ".\n";
    }
}
Esempio n. 4
0
MLSample* MLSignal::setDims (int width, int height, int depth)
{
	mDataAligned = 0;	
	// delete old
	if (mData)
	{
		delete[] mData;
	}

	mWidth = width;
	mHeight = height;
	mDepth = depth;
	mWidthBits = bitsToContain(width);
	mHeightBits = bitsToContain(height);
	mDepthBits = bitsToContain(depth);
	mSize = 1 << mWidthBits << mHeightBits << mDepthBits;
	mData = allocateData(mSize);	
	mDataAligned = initializeData(mData, mSize);	
	mConstantMask = mSize - 1;
	return mDataAligned;
}
Esempio n. 5
0
int MLRingBuffer::resize(int length)
{
    int r = 0;
    int size = 1 << bitsToContain(length);
    if (pData) delete[] pData;
    pData = new MLSample[size];

    if (pData)
    {
        r = size;
        PaUtil_InitializeRingBuffer( &mBuf, sizeof(MLSample), size, pData );
    }

    return r;
}
Esempio n. 6
0
MLProc::err MLProcDelayInput::resize() 
{	
	MLProc::err e = OK;
	const float sr = getContextSampleRate();
	int lenBits = bitsToContain((int)(getParam("length") * sr));
	int length = 1 << lenBits;
	mLengthMask = length - 1;
	
	MLSample* pBuf = mBuffer.setDims(length);
	if (!pBuf)
	{
		e = memErr;
	}

	return e;
}
Esempio n. 7
0
void MLPluginProcessor::prepareToPlay (double sr, int maxFramesPerBlock)
{
	MLProc::err prepareErr;
	MLProc::err r = preflight();
	
	if (!mpPluginDoc.get()) return;
	
	if (r == MLProc::OK)
	{
		// get the Juce process lock  // TODO ???
		const ScopedLock sl (getCallbackLock());

		unsigned inChans = getNumInputChannels();
		unsigned outChans = getNumOutputChannels();
		mEngine.setInputChannels(inChans);
		mEngine.setOutputChannels(outChans);

		unsigned bufSize = 0;
		unsigned chunkSize = 0;

		// choose new buffer size and vector size.
		{
			// bufSize is the smallest power of two greater than maxFramesPerBlock.
			int maxFramesBits = bitsToContain(maxFramesPerBlock);
			bufSize = 1 << maxFramesBits;
			
			// vector size is desired processing block size, set this to default size of signal.
			chunkSize = min((int)bufSize, (int)kMLProcessChunkSize);
		}	
		
		// dsp engine has one chunkSize of latency in order to run constant block size.
		setLatencySamples(chunkSize);
		
		// debug() << "MLPluginProcessor: prepareToPlay: rate " << sr << ", buffer size " << bufSize << ", vector size " << vecSize << ". \n";	
		
		// build: turn XML description into graph of processors
		if (mEngine.getGraphStatus() != MLProc::OK)
		{
			bool makeSignalInputs = inChans > 0;
			r = mEngine.buildGraphAndInputs(&*mpPluginDoc, makeSignalInputs, wantsMIDI()); 
			// debug() << getNumParameters() << " parameters in description.\n";
		}
		else
		{
			// debug() << "MLPluginProcessor graph OK.\n";
		}

#ifdef DEBUG
		theSymbolTable().audit();
		//theSymbolTable().dump();
#endif

		// compile: schedule graph of processors , setup connections, allocate buffers
		if (mEngine.getCompileStatus() != MLProc::OK)
		{
			mEngine.compileEngine();
		}
		else
		{
			debug() << "compile OK.\n";
		}

		// prepare to play: resize and clear processors
		prepareErr = mEngine.prepareEngine(sr, bufSize, chunkSize);
		if (prepareErr != MLProc::OK)
		{
			debug() << "MLPluginProcessor: prepareToPlay error: \n";
		}
		
		// mEngine.dump();
			
		// after prepare to play, set state from saved blob if one exists
		const unsigned blobSize = mSavedParamBlob.getSize();
		if (blobSize > 0)
		{
			setStateFromBlob (mSavedParamBlob.getData(), blobSize);
			mSavedParamBlob.setSize(0);
		}
		else 
		{
			mEngine.clear();
			if (!mHasParametersSet)
			{
				loadDefaultPreset();
			}
		}		
		
		if(!mInitialized)
		{					
			initializeProcessor();
			mInitialized = true;
		}		
		
		mEngine.setEnabled(prepareErr == MLProc::OK);
	}
}