Search in sources :

Example 1 with Granulize

use of spacegraph.audio.granular.Granulize in project narchy by automenta.

the class SoNAR method update.

private boolean update(@NotNull Concept c, Sound s) {
    // float p = nar.pri(k);
    // if (p == p && p > 0) {
    // v.setAmplitude(0.1f * p);
    Truth b = nar.goalTruth(c, now);
    // System.out.println(c + " "+ b + " " + nar.time() + " " + nar.dur());
    float thresh = 0.55f;
    if (b != null && b.freq() > thresh) {
        if (s.producer instanceof Granulize) {
            float stretchFactor = (b.freq() - 0.5f) * 2f;
            if (stretchFactor > 0 && stretchFactor < 0.05f)
                stretchFactor = 0.05f;
            else if (stretchFactor < 0 && stretchFactor > -0.05f)
                stretchFactor = -0.05f;
            ((Granulize) s.producer).setStretchFactor(stretchFactor);
        }
        if (s.producer instanceof SoundProducer.Amplifiable) {
            // v.setAmplitude(1f);
            ((SoundProducer.Amplifiable) s.producer).setAmplitude(2f * (b.freq() - 0.5f));
        }
        // v.play();
        return true;
    } else {
        if (s.producer instanceof SoundProducer.Amplifiable) {
            ((SoundProducer.Amplifiable) s.producer).setAmplitude(0f);
        }
        return false;
    // v.stop();
    // v.setStretchFactor(1f);
    }
// 
// v.setStretchFactor();
// v.pitchFactor.setValue(1f / Math.log(c.volume()));
// g.setStretchFactor(1f/(1f+kk.volume()/4f));
// }
// v.stop();
// return false;
}
Also used : Granulize(spacegraph.audio.granular.Granulize) Truth(nars.truth.Truth)

Aggregations

Truth (nars.truth.Truth)1 Granulize (spacegraph.audio.granular.Granulize)1