Esempio n. 1
0
    pBuffer process(pBuffer b) override
    {
        Interval I = b->getInterval ();

        Signal::IntervalType i = std::max(0ll, I.first);
        FLAC__stream_decoder_seek_absolute(decoder, i);
        while (true)
        {
            fmt->block->set_sample_offset (i);
            *b |= *fmt->block;
            i += fmt->last_blocksize;

            if (i>=I.last)
                break;

            if (!FLAC__stream_decoder_process_single (decoder))
            {
                Log("flacfile: failed reading at %d") % i;
                break;
            }
        }

        // if reading before start, zeros
        if (I.first < 0)
            *b |= Buffer(Signal::Interval(I.first, 0), b->sample_rate (), b->number_of_channels ());

        // if b extends EOF, zeros
        if (i < I.last)
            *b |= Buffer(Interval(i,I.last), b->sample_rate (), b->number_of_channels ());

        return b;
    }
Esempio n. 2
0
pBuffer OperationSetSilent::Operation::
        process (pBuffer b)
{
    Signal::Interval i = section_ & b->getInterval ();

    if (i) {
        Buffer zero(i, b->sample_rate(), b->number_of_channels ());
        *b |= zero;
    }

    return b;
}
Esempio n. 3
0
pBuffer RenderOperationDesc::Operation::
        process(pBuffer b)
{
    Signal::Interval input = b?b->getInterval ():Signal::Interval();

    b = wrapped_->process (b);

    Signal::Interval output = b?b->getInterval ():Signal::Interval();

    render_target_.write ()->processedData (input, output);

    return b;
}
Esempio n. 4
0
void transpose(const pBuffer& out, const void* vin)
{
    const T* in = (const T*)vin;
    int C = out->number_of_channels ();
    int L = out->number_of_samples ();

    for (int c=0; c<C; c++)
    {
        pMonoBuffer m = out->getChannel (c);
        float* p = CpuMemoryStorage::WriteAll<1>(m->waveform_data()).ptr ();

        for (int s=0; s<L; s++)
            p[s] = in[s*C+c];
    }
}
Esempio n. 5
0
void Step::
        finishTask(Step::ptr step, int taskid, pBuffer result)
{
    Interval result_interval;
    if (result)
        result_interval = result->getInterval ();

    TASKINFO TaskInfo ti(format("Step::finishTask %2% on %1%")
              % step.raw ()->operation_name()
              % result_interval);

    if (result) {
        // Result must have the same number of channels and sample rate as previous cache.
        // Call deprecateCache(Interval::Interval_ALL) to erase the cache when chainging number of channels or sample rate.
        step.raw ()->cache_->put (result);
    }

    auto self = step.write ();
    int matched_task = self->running_tasks.count (taskid);
    if (1 != matched_task) {
        Log("C = %d, taskid = %x on %s") % matched_task % taskid % self->operation_name ();
        EXCEPTION_ASSERT_EQUALS( 1, matched_task );
    }

    Intervals expected_output = self->running_tasks[ taskid ];

    Intervals update_miss = expected_output - result_interval;
    self->not_started_ |= update_miss;

    if (!result) {
        TASKINFO TaskInfo(format("The task was cancelled. Restoring %1% for %2%")
                 % update_miss
                 % self->operation_name());
    } else {
        if (update_miss) {
            TaskInfo(format("These samples were supposed to be updated by the task but missed: %1% by %2%")
                     % update_miss
                     % self->operation_name());
        }
        if (result_interval - expected_output) {
            // These samples were not supposed to be updated by the task but were calculated anyway
            TaskInfo(format("Unexpected extras: %1% = (%2%) - (%3%) from %4%")
                     % (result_interval - expected_output)
                     % result_interval
                     % expected_output
                     % self->operation_name());

            // The samples are still marked as invalid. Would need to remove the
            // extra calculated samples from not_started_ but that would fail
            // in a situation where deprecatedCache is called after the task has
            // been created. So not_started_ can't be modified here (unless calls
            // to deprecatedCache were tracked).
        }
    }

    self->running_tasks.erase ( taskid );
    self.unlock ();

    step.raw ()->wait_for_tasks_.notify_all ();
}
Esempio n. 6
0
void SinkSource::
        put( pBuffer b )
{
    TIME_SINKSOURCE TaskTimer tt("%s %s", __FUNCTION__, b->getInterval().toString().c_str());

    /* CANONICAL {
        QMutexLocker l(&_mutex);

        // Simply remove previous overlapping buffer, don't bother merging.
        foreach( pBuffer& s, _cache) {
        {
            if (!s)
                s = b;
            else if (s->sample_offset < b->sample_offset+b->number_of_samples() && s->sample_offset + s->number_of_samples() > b->sample_offset)
            {
                s = b;
                b.reset(); // If copied more than once, set others to 0
            }
        }
    }

    _cache.push_back( b );
    */

    merge(b);
}
Esempio n. 7
0
void SinkSource::
        putExpectedSamples( pBuffer buffer, const Intervals& expected )
{
    BufferSource bs( buffer );

    const Intervals I = expected & buffer->getInterval();
    BOOST_FOREACH( const Interval& i, I )
    {
        pBuffer s = bs.readFixedLength( i );
        put( s );
    }
Esempio n. 8
0
void uncomment_line(pBuffer Buf, CURSOR Line) {
    TextIter X = Buf->get_iter_at_offset(Line);
    TextIter Y = Buf->get_iter_at_offset(Line + 1);
    Buf->erase(X, Y);
}
Esempio n. 9
0
void comment_line(pBuffer Buf, CURSOR Line) {
    TextIter Iter = Buf->get_iter_at_offset(Line);
    Buf->insert(Iter, "#");
}
Esempio n. 10
0
Lines get_start_lines(pBuffer Buf, CURSOR X, CURSOR Y) {
    TextIter Xi = Buf->get_iter_at_offset(X);
    Xi.set_line_offset(0);
    TextIter Yi = Buf->get_iter_at_offset(Y);
    return get_starts(Xi, Yi);
}