~ubuntu-branches/ubuntu/oneiric/lmms/oneiric

« back to all changes in this revision

Viewing changes to plugins/ladspa_effect/calf/src/organ.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Артём Попов
  • Date: 2011-02-14 20:58:36 UTC
  • mfrom: (1.1.10 upstream) (3.1.9 sid)
  • Revision ID: james.westby@ubuntu.com-20110214205836-2u41xus1d2mj8nfz
Tags: 0.4.10-1ubuntu1
* Merge from debian unstable (LP: #718801).  Remaining changes:
  - Replace build-dep on libwine-dev with wine1.2-dev to build
    against the newer Wine.

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
}
63
63
 
64
64
void organ_audio_module::params_changed() {
65
 
    for (int i = 0; i < param_count - var_count; i++)
 
65
    for (int i = 0; i < param_count; i++)
66
66
        ((float *)&par_values)[i] = *params[i];
67
67
 
68
68
    unsigned int old_poly = polyphony_limit;
611
611
    }
612
612
}
613
613
 
 
614
void scanner_vibrato::reset()
 
615
{
 
616
    legacy.reset();
 
617
    for (int i = 0; i < ScannerSize; i++)
 
618
        scanner[i].reset();
 
619
    lfo_phase = 0.f;
 
620
}
 
621
 
 
622
void scanner_vibrato::process(organ_parameters *parameters, float (*data)[2], unsigned int len, float sample_rate)
 
623
{
 
624
    if (!len)
 
625
        return;
 
626
    
 
627
    int vtype = (int)parameters->lfo_type;
 
628
    if (!vtype || vtype > organ_enums::lfotype_cvfull)
 
629
    {
 
630
        legacy.process(parameters, data, len, sample_rate);
 
631
        return;
 
632
    }
 
633
    
 
634
    // I bet the original components of the line box had some tolerance,
 
635
    // hence two different values of cutoff frequency
 
636
    scanner[0].set_lp_rbj(4000, 0.707, sample_rate);
 
637
    scanner[1].set_lp_rbj(4200, 0.707, sample_rate);
 
638
    for (int t = 2; t < ScannerSize; t ++)
 
639
    {
 
640
        scanner[t].copy_coeffs(scanner[t & 1]);
 
641
    }
 
642
    
 
643
    float lfo_phase2 = lfo_phase + parameters->lfo_phase * (1.0 / 360.0);
 
644
    if (lfo_phase2 >= 1.0)
 
645
        lfo_phase2 -= 1.0;
 
646
    float vib_wet = parameters->lfo_wet;
 
647
    float dphase = parameters->lfo_rate / sample_rate;
 
648
    static const int v1[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 8 };
 
649
    static const int v2[] = { 0, 1, 2, 4, 6, 8, 9, 10, 12 };
 
650
    static const int v3[] = { 0, 1, 3, 6, 11, 12, 15, 17, 18, 18, 18 };
 
651
    static const int vfull[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 18 };
 
652
    static const int *vtypes[] = { NULL, v1, v2, v3, vfull };
 
653
    const int *vib = vtypes[vtype];
 
654
    
 
655
    float vibamt = 8 * parameters->lfo_amt;
 
656
    if (vtype == organ_enums::lfotype_cvfull)
 
657
        vibamt = 17 * parameters->lfo_amt;
 
658
    for (unsigned int i = 0; i < len; i++)
 
659
    {
 
660
        float line[ScannerSize + 1];
 
661
        float v0 = (data[i][0] + data[i][1]) * 0.5;
 
662
        
 
663
        line[0] = v0;
 
664
        for (int t = 0; t < ScannerSize; t++)
 
665
            line[t + 1] = scanner[t].process(line[t]) * 1.03;
 
666
        
 
667
        float lfo1 = lfo_phase < 0.5 ? 2 * lfo_phase : 2 - 2 * lfo_phase;
 
668
        float lfo2 = lfo_phase2 < 0.5 ? 2 * lfo_phase2 : 2 - 2 * lfo_phase2;
 
669
        
 
670
        float pos = vibamt * lfo1;
 
671
        int ipos = (int)pos;
 
672
        float vl = lerp(line[vib[ipos]], line[vib[ipos + 1]], pos - ipos);
 
673
        
 
674
        pos = vibamt * lfo2;
 
675
        ipos = (int)pos;
 
676
        float vr = lerp(line[vib[ipos]], line[vib[ipos + 1]], pos - ipos);
 
677
        
 
678
        lfo_phase += dphase;
 
679
        if (lfo_phase >= 1.0)
 
680
            lfo_phase -= 1.0;
 
681
        lfo_phase2 += dphase;
 
682
        if (lfo_phase2 >= 1.0)
 
683
            lfo_phase2 -= 1.0;
 
684
        
 
685
        data[i][0] += (vl - v0) * vib_wet;
 
686
        data[i][1] += (vr - v0) * vib_wet;
 
687
    }
 
688
    for (int t = 0; t < ScannerSize; t++)
 
689
    {
 
690
        scanner[t].sanitize();
 
691
    }
 
692
}
614
693
//////////////////////////////////////////////////////////////////////////////////////////////////////
615
694
 
616
695
void organ_voice::update_pitch()
950
1029
{
951
1030
    if (!strcmp(key, "map_curve"))
952
1031
    {
 
1032
        if (!value)
 
1033
            value = "2\n0 1\n1 1\n";
953
1034
        var_map_curve = value;
954
1035
        stringstream ss(value);
955
1036
        int i = 0;
992
1073
 
993
1074
void drawbar_organ::render_separate(float *output[], int nsamples)
994
1075
{
995
 
    float buf[4096][2];
 
1076
    float buf[MAX_SAMPLE_RUN][2];
996
1077
    dsp::zero(&buf[0][0], 2 * nsamples);
997
1078
    basic_synth::render_to(buf, nsamples);
998
1079
    if (dsp::fastf2i_drm(parameters->lfo_mode) == organ_voice_base::lfomode_global)