예제 #1
0
void FileReader::setParameter (int parameterIndex, float newValue)
{
    switch (parameterIndex)
    {
        //Change selected recording
        case 0:
            setActiveRecording (newValue);
            break;

        //set startTime
        case 1: 
            startSample = millisecondsToSamples (newValue);
            currentSample = startSample;

            static_cast<FileReaderEditor*> (getEditor())->setCurrentTime (samplesToMilliseconds (currentSample));
            break;

        //set stop time
        case 2:
            stopSample = millisecondsToSamples(newValue);
            currentSample = startSample;

            static_cast<FileReaderEditor*> (getEditor())->setCurrentTime (samplesToMilliseconds (currentSample));
            break;
    }
}
예제 #2
0
void FileReader::process (AudioSampleBuffer& buffer)
{
    const int samplesNeededPerBuffer = int (float (buffer.getNumSamples()) * (getDefaultSampleRate() / m_sysSampleRate));
    m_samplesPerBuffer.set(samplesNeededPerBuffer);
    // FIXME: needs to account for the fact that the ratio might not be an exact
    //        integer value
    
    // if cache window id == 0, we need to read and cache BUFFER_WINDOW_CACHE_SIZE more buffer windows
    if (bufferCacheWindow == 0)
    {
        switchBuffer();
    }
    
    for (int i = 0; i < currentNumChannels; ++i)
    {
        // offset readBuffer index by current cache window count * buffer window size * num channels
        input->processChannelData (*readBuffer + (samplesNeededPerBuffer * currentNumChannels * bufferCacheWindow),
                                   buffer.getWritePointer (i, 0),
                                   i,
                                   samplesNeededPerBuffer);
    }
    
    setTimestampAndSamples(timestamp, samplesNeededPerBuffer);
	timestamp += samplesNeededPerBuffer;

	static_cast<FileReaderEditor*> (getEditor())->setCurrentTime(samplesToMilliseconds(startSample + timestamp % (stopSample - startSample)));
    
    bufferCacheWindow += 1;
    bufferCacheWindow %= BUFFER_WINDOW_CACHE_SIZE;
}
예제 #3
0
void FileReader::setActiveRecording(int index)
{
    input->setActiveRecord(index);
    currentNumChannels = input->getActiveNumChannels();
    currentNumSamples = input->getActiveNumSamples();
    currentSampleRate = input->getActiveSampleRate();
    startSample = 0;
    stopSample = currentNumSamples;
    currentSample = 0;
    for (int i=0; i < currentNumChannels; i++)
    {
        channelInfo.add(input->getChannelInfo(i));
    }
    static_cast<FileReaderEditor*>(getEditor())->setTotalTime(samplesToMilliseconds(currentNumSamples));
    readBuffer.malloc(currentNumChannels*BUFFER_SIZE);
}
예제 #4
0
void FileReader::setActiveRecording (int index)
{    
    input->setActiveRecord (index);

    currentNumChannels  = input->getActiveNumChannels();
    currentNumSamples   = input->getActiveNumSamples();
    currentSampleRate   = input->getActiveSampleRate();

    currentSample   = 0;
    startSample     = 0;
    stopSample      = currentNumSamples;
    bufferCacheWindow = 0;

    for (int i = 0; i < currentNumChannels; ++i)
    {
        channelInfo.add (input->getChannelInfo (i));
    }

    static_cast<FileReaderEditor*> (getEditor())->setTotalTime (samplesToMilliseconds (currentNumSamples));
	input->seekTo(startSample);

   
}