Search in sources :

Example 1 with UGen

use of net.beadsproject.beads.core.UGen in project narchy by automenta.

the class PolyLimit method in.

/**
 * Overrides {@link UGen#in(UGen)} such that if a new UGen pushes the total number of
 * connected UGens above the upper limit, the oldest UGen is removed.
 */
@Override
public UGen in(UGen sourceUGen) {
    if (existingInputs.contains(sourceUGen)) {
        existingInputs.remove(sourceUGen);
        existingInputs.add(sourceUGen);
    } else {
        if (steal) {
            if (existingInputs.size() >= maxInputs) {
                UGen deadUGen = existingInputs.poll();
                removeAllConnections(deadUGen);
            }
            existingInputs.add(sourceUGen);
            super.in(sourceUGen);
        } else {
            // must check for deleted and remove
            Collection<UGen> copy = new LinkedList<>();
            copy.addAll(existingInputs);
            for (UGen ug : copy) {
                if (ug.isDeleted())
                    existingInputs.remove(ug);
            }
            if (existingInputs.size() < maxInputs) {
                existingInputs.add(sourceUGen);
                super.in(sourceUGen);
            }
        }
    }
    return this;
}
Also used : UGen(net.beadsproject.beads.core.UGen) LinkedList(java.util.LinkedList)

Example 2 with UGen

use of net.beadsproject.beads.core.UGen in project narchy by automenta.

the class Spatial method gen.

/* (non-Javadoc)
     * @see net.beadsproject.beads.core.UGen#calculateBuffer()
     */
@Override
public void gen() {
    synchronized (sources) {
        for (Map.Entry<UGen, Location> uGenLocationEntry : sources.entrySet()) {
            Location location = uGenLocationEntry.getValue();
            location.mixInAudio(bufOut);
            if ((uGenLocationEntry.getKey()).isDeleted()) {
                deadSources.add(uGenLocationEntry.getKey());
            }
        }
        for (UGen source : deadSources) {
            sources.remove(source);
        }
        deadSources.clear();
    }
}
Also used : UGen(net.beadsproject.beads.core.UGen)

Example 3 with UGen

use of net.beadsproject.beads.core.UGen in project narchy by automenta.

the class SoundEventManager method play.

/**
 * Play the {@link SoundEvent} specified by the {@link Map} argument. The {@link SoundEvent}
 * to be played is specified by an entry in the {@link Map} with key "class" and value the class of
 * the {@link SoundEvent}.
 *
 * @param output     the {@link UGen} to which this {@link SoundEvent} should connect.
 * @param parameters the parameters for the {@link SoundEvent}.
 * @return the {@link UGen} at the root of the {@link SoundEvent}.
 */
@SuppressWarnings("unchecked")
public static UGen play(UGen output, Map<String, Object> parameters) {
    try {
        Class<? extends SoundEvent> soundEventClass = (Class<? extends SoundEvent>) parameters.get("class");
        if (soundEventClass == null)
            System.out.println("could not find class for SoundEvent");
        Method playMethod = soundEventClass.getMethod("play", UGen.class, Map.class);
        SoundEvent event = soundEventClass.newInstance();
        return (UGen) playMethod.invoke(event, output, parameters);
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
Also used : Method(java.lang.reflect.Method) UGen(net.beadsproject.beads.core.UGen)

Example 4 with UGen

use of net.beadsproject.beads.core.UGen in project narchy by automenta.

the class Clip method sendData.

/**
 * Sets the Clip parameters according to the properties "maximum" and/or
 * "minimum" in the specified DataBead.
 *
 * @param db The parameter DataBead.
 * @return This DataBeadReceiver instance.
 */
@Override
public DataBeadReceiver sendData(DataAuvent db) {
    if (db != null) {
        UGen u = db.getUGen("maximum");
        if (u == null) {
            setMaximum(db.getFloat("maximum", max));
        } else {
            setMaximum(u);
        }
        u = db.getUGen("minimum");
        if (u == null) {
            setMinimum(db.getFloat("minimum", min));
        } else {
            setMinimum(u);
        }
    }
    return this;
}
Also used : UGen(net.beadsproject.beads.core.UGen)

Aggregations

UGen (net.beadsproject.beads.core.UGen)4 Method (java.lang.reflect.Method)1 LinkedList (java.util.LinkedList)1