コード例 #1
0
ファイル: NovaOsc.cpp プロジェクト: gislitg/sc3-plugins
	PulseDPW2():
		mFreq(std::numeric_limits<float>::quiet_NaN()),
		mLastVal0(0),
		mLastVal1(0)
	{
		const float width = in0(1);
		const float phase = in0(2);

		mPhase0 = sc_wrap(phase, -1.0f, 1.0f);
		mPhase1 = sc_wrap(phase + width + width, -1.0f, 1.0f);

		switch (inRate(0)) {
		case calc_ScalarRate:
		{
			float freq = in0(0);
			float scale;
			double phaseIncrement;
			updateFrequency<true>(freq, scale, phaseIncrement);

			set_calc_function<PulseDPW2, &PulseDPW2::next_i>();
			break;
		}

		case calc_BufRate:
			set_calc_function<PulseDPW2, &PulseDPW2::next_k>();
			break;

		case calc_FullRate:
			set_calc_function<PulseDPW2, &PulseDPW2::next_a>();
		}
	}
コード例 #2
0
	void next_k(int inNumSamples)
	{
		float newFreq        = in0(1);
		float newQ           = in0(2);
		float newHPCutoff    = in0(3);

		if (q != newQ)
			set_q(newQ);

		if (newHPCutoff != hpCutoff)
			setFeedbackHPF(newHPCutoff * sampleDur());

		double a, a_inv, a2, b, b2, c, g, g0;
		calcFilterCoefficients(newFreq, a, a2, a_inv, b, b2, c, g, g0);

		double z0 = z[0];
		double z1 = z[1];
		double z2 = z[2];
		double z3 = z[3];
		double z4 = z[4];

		const float * inSig = zin(0);
		float * outSig = zout(0);

		for (int i = 0; i != inNumSamples; ++i) {
			double x = ZXP(inSig);
			ZXP(outSig) = tick(x, a, a2, a_inv, b, b2, c, g, g0, z0, z1, z2, z3, z4);
		}
		z[0] = z0;
		z[1] = z1;
		z[2] = z2;
		z[3] = z3;
		z[4] = z4;
	}
コード例 #3
0
// two instances of python processing processes should work
TEST_F(SignalProcessingInterfaceTest, TwoInstanceTest) {
    SignalProcessingImpl* sp2 = new SignalProcessingImpl();
    ASSERT_TRUE(sp2 != NULL);
    ASSERT_TRUE(sp2->init(SignalProcessingImpl::MAIN_PROCESSING_SCRIPT));

    android::String8 functionName("intsum");
    int nInputs = 2;
    int nOutputs = 1;
    bool inputTypes[2] = { false, false };
    bool outputTypes[1] = { false };

    TaskCase::Value in0((int64_t)10);
    TaskCase::Value in1((int64_t)100);
    void* inputs[2] = { &in0, &in1 };

    TaskCase::Value out0((int64_t)0);
    void *outputs[1] = { &out0 };

    ASSERT_TRUE(mSp->run( functionName,
            nInputs, inputTypes, inputs,
            nOutputs, outputTypes, outputs) == TaskGeneric::EResultOK);
    ASSERT_TRUE(out0.getInt64() == (in0.getInt64() + in1.getInt64()));
    out0.setInt64(0);
    ASSERT_TRUE(sp2->run( functionName,
                nInputs, inputTypes, inputs,
                nOutputs, outputTypes, outputs) == TaskGeneric::EResultOK);
    ASSERT_TRUE(out0.getInt64() == (in0.getInt64() + in1.getInt64()));
    delete sp2;
}
コード例 #4
0
ファイル: FIRFilter.cpp プロジェクト: EQ4/dsp
void FIRFilter::kaiser (RealArray &w, Real beta)
{
    size_t n = (1 + w.size()) / 2, ieo = w.size() % 2;
    Real bes = in0 (beta);
    Real xind = pow ((w.size() - 1.0), 2);

    for (size_t ii = 0; ii < n; ii++)
    {
        Real xi = ii;
        if (ieo == 0)
            xi += 0.5;
        size_t jj = n + ii - ieo;
        w[n - 1 - ii] =
            w[jj] = in0 (beta * sqrt(1.0 - 4.0 * xi * xi / xind)) / bes;
    }

}  // end kaiser
コード例 #5
0
// test to run processing/example.py
TEST_F(SignalProcessingInterfaceTest, exampleTest) {
    android::String8 functionName("example");
    int nInputs = 8;
    int nOutputs = 4;
    bool inputTypes[8] = { true, true, true, true, false, false, false, false };
    bool outputTypes[4] = { true, true, false, false };

    android::sp<Buffer> in0(new Buffer(16, 16, true));
    char* data0 = in0->getData();
    for (size_t i = 0; i < in0->getSize(); i++) {
        data0[i] = i;
    }
    android::sp<Buffer> in1(new Buffer(16, 16, true));
    char* data1 = in1->getData();
    for (size_t i = 0; i < in1->getSize(); i++) {
        data1[i] = i;
    }
    android::sp<Buffer> in2(new Buffer(8, 8, false));
    char* data2 = in2->getData();
    for (size_t i = 0; i < in2->getSize(); i++) {
        data2[i] = i;
    }
    android::sp<Buffer> in3(new Buffer(8, 8, false));
    char* data3 = in3->getData();
    for (size_t i = 0; i < in3->getSize(); i++) {
        data3[i] = i;
    }
    TaskCase::Value in4((int64_t)100);
    TaskCase::Value in5((int64_t)100);
    TaskCase::Value in6(1.0f);
    TaskCase::Value in7(1.0f);
    void* inputs[8] = { &in0, &in1, &in2, &in3, &in4, &in5, &in6, &in7 };

    android::sp<Buffer> out0(new Buffer(16, 16, true));
    char* outdata0 = out0->getData();
    for (size_t i = 0; i < out0->getSize(); i++) {
        outdata0[i] = 0xaa;
    }
    android::sp<Buffer> out1(new Buffer(8, 8, false));
    char* outdata1 = out1->getData();
    for (size_t i = 0; i < out1->getSize(); i++) {
        outdata1[i] = 0xbb;
    }
    TaskCase::Value out2((int64_t)1000);
    TaskCase::Value out3(-1.0f);
    void *outputs[4] = { &out0, &out1, &out2, &out3 };

    ASSERT_TRUE(mSp->run( functionName,
            nInputs, inputTypes, inputs,
            nOutputs, outputTypes, outputs) == TaskGeneric::EResultOK);
    ASSERT_TRUE(*(in0.get()) == *(out0.get()));
    ASSERT_TRUE(*(in2.get()) == *(out1.get()));
    ASSERT_TRUE(in4 == out2);
    ASSERT_TRUE(in6 == out3);
}
コード例 #6
0
ファイル: FirFilterDesigner.cpp プロジェクト: EQ4/dsp
void KaiserWindowDesigner::calculateWindow (RealArray &w, Real beta)
{
    size_t n = (1 + w.size()) / 2;
    size_t ieo = w.size() % 2;
    Real bes = in0 (beta);
    Real xind = pow ((w.size() - 1.0), 2);

    Real arg;

    for (size_t ii = 0; ii < n; ii++)
    {
        Real xi = ii;
        if (ieo == 0)
            xi += 0.5;
        size_t jj = n + ii - ieo;
        // there is a case do to floating point error when you end up with a very small negative number
        // therefore - ensure that the number is always non-negative so we can take the square root of it
        arg=std::max(1.0 - 4.0 * xi * xi / xind,0.0);
        w[n - 1 - ii] =
            w[jj] = in0 (beta * sqrt(arg)) / bes;
    }

}  // end calculateWindow
コード例 #7
0
void NEGEMMLowpAArch64V8P4Kernel::run(const Window &window, const ThreadInfo &info)
{
    ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this);
    ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(INEKernel::window(), window);

    const int lda = _input0->info()->strides_in_bytes().y();
    const int ldb = _input1->info()->strides_in_bytes().y();
    const int ldc = _output->info()->strides_in_bytes().y() / sizeof(uint32_t);

    const auto in1_ptr = reinterpret_cast<const gemm_u8_12x8::operand_type *>(_input1->buffer());

    const int M = std::min(_output->info()->tensor_shape().y(), static_cast<size_t>(window.y().end())) - window.y().start();
    const int N = _output->info()->tensor_shape().x();
    const int K = _input0->info()->tensor_shape().x();

    // Only iterate over batches
    Window win(window);
    win.set(0, Window::Dimension(0, 1, 1));
    win.set(1, Window::Dimension(0, 1, 1));

    Iterator in0(_input0, window);
    Iterator out(_output, window);

    GemmInterleaved<gemm_u8_12x8, gemm_u8_12x8::operand_type, gemm_u8_12x8::result_type> gemm(&info.cpu_info, M, N, K, !_transform_1, !_transform_1);

    constexpr size_t alignment      = 4096;
    const size_t     offset         = (gemm.get_working_size() + alignment - 1) * info.thread_id;
    void            *workspace      = _workspace->buffer() + offset;
    size_t           workspace_size = _workspace->info()->total_size();

    if(support::cpp11::align(alignment, gemm.get_working_size(), workspace, workspace_size) == nullptr)
    {
        ARM_COMPUTE_ERROR("Not enough space to align buffer!");
    }

    execute_window_loop(win, [&](const Coordinates & id)
    {
        gemm.execute(reinterpret_cast<const gemm_u8_12x8::operand_type *>(in0.ptr()), lda,
                     reinterpret_cast<const gemm_u8_12x8::operand_type *>(in1_ptr), ldb,
                     reinterpret_cast<gemm_u8_12x8::result_type *>(out.ptr()), ldc,
                     _alpha, _beta, workspace);
    },
    in0, out);
}
コード例 #8
0
TEST_F(SignalProcessingInterfaceTest, intsumTest) {
    android::String8 functionName("intsum");
    int nInputs = 2;
    int nOutputs = 1;
    bool inputTypes[2] = { false, false };
    bool outputTypes[1] = { false };

    TaskCase::Value in0((int64_t)10);
    TaskCase::Value in1((int64_t)100);
    void* inputs[2] = { &in0, &in1 };

    TaskCase::Value out0((int64_t)0);
    void *outputs[1] = { &out0 };

    ASSERT_TRUE(mSp->run( functionName,
            nInputs, inputTypes, inputs,
            nOutputs, outputTypes, outputs) == TaskGeneric::EResultOK);
    ASSERT_TRUE(out0.getInt64() == (in0.getInt64() + in1.getInt64()));
}
コード例 #9
0
ファイル: writer.cpp プロジェクト: lczech/genesis
/**
 * @brief Print an XML element.
 */
void XmlWriter::print_element (std::string& xml, const XmlElement* value, const int indent_level)
{
    // Prepare indention and opening tag.
    std::string in0 (indent_level * indent, ' ');
    xml += in0 + "<" + value->tag + print_attributes_list(value->attributes);

    // If it's an empty element, close it, and we are done.
    if (value->content.size() == 0) {
        xml += " />";
        return;
    }

    // If the element only contains a single markup, don't add new lines. However, if it contains
    // more data, put each element in a new line.
    xml += ">";
    if (value->content.size() == 1 && value->content[0]->is_markup()) {
        print_markup(xml, xml_value_to_markup(value->content[0].get()));
    } else {
        std::string in1 ((indent_level + 1) * indent, ' ');
        xml += "\n";

        for (auto& v : value->content) {
            if (v->is_comment()) {
                xml += in1;
                print_comment(xml, xml_value_to_comment(v.get()));
            } else if (v->is_markup()) {
                xml += in1;
                print_markup(xml, xml_value_to_markup(v.get()));
            } else if (v->is_element()) {
                print_element(xml, xml_value_to_element(v.get()), indent_level + 1);
            } else {
                // there are no other cases
                assert(0);
            }
            xml += "\n";
        }
        xml += in0;
    }

    xml += "</" + value->tag + ">";
}
コード例 #10
0
    // calculation function for a control rate frequency argument
    void next_k(int inNumSamples)
    {
        // get the pointer to the output buffer
        float *outBuf = out(0);

        // freq is control rate, so calculate it once.
        float freq = in0(0) * mFreqMul;

        // get phase from struct and store it in a local variable.
        // The optimizer will cause it to be loaded it into a register.
        double phase = mPhase;

        // since the frequency is not changing then we can simplify the loops
        // by separating the cases of positive or negative frequencies.
        // This will make them run faster because there is less code inside the loop.
        if (freq >= 0.f) {
            // positive frequencies
            for (int i=0; i < inNumSamples; ++i)
            {
                outBuf[i] = phase;
                phase += freq;
                if (phase >= 1.f) phase -= 2.f;
            }
        } else {
            // negative frequencies
            for (int i=0; i < inNumSamples; ++i)
            {
                outBuf[i] = phase;
                phase += freq;
                if (phase <= -1.f) phase += 2.f;
            }
        }

        // store the phase back to the struct
        mPhase = phase;
    }
コード例 #11
0
    MySaw2() {
        // 1. set the calculation function.
        if (isAudioRateIn(0)) {
            // if the frequency argument is audio rate
            set_calc_function<MySaw2,&MySaw2::next_a>();
        } else {    
        // if thene frequency argument is control rate (or a scalar).
            set_calc_function<MySaw2,&MySaw2::next_k>();
        }   

        // 2. initialize the unit generator state variables.
        // initialize a constant for multiplying the frequency
        mFreqMul = 2.0 * sampleDur();
        // get initial phase of oscillator
        mPhase = in0(1);

        // 3. calculate one sample of output.
        if (isAudioRateIn(0)) {
            next_a(1);
        } else {
            next_k(1);
        }
     
    }