Example usage for java.lang Float intBitsToFloat

List of usage examples for java.lang Float intBitsToFloat

Introduction

In this page you can find the example usage for java.lang Float intBitsToFloat.

Prototype

@HotSpotIntrinsicCandidate
public static native float intBitsToFloat(int bits);

Source Link

Document

Returns the float value corresponding to a given bit representation.

Usage

From source file:uk.co.modularaudio.mads.base.oscillator.mu.OscillatorIOQueueBridge.java

@Override
public void receiveQueuedEventsToInstance(final OscillatorMadInstance instance,
        final ThreadSpecificTemporaryEventStorage tses, final long periodTimestamp,
        final IOQueueEvent queueEntry) {
    switch (queueEntry.command) {
    case COMMAND_IN_FREQUENCY: {
        // Is just a float
        final long value = queueEntry.value;
        final int truncVal = (int) value;
        final float freq = Float.intBitsToFloat(truncVal);
        instance.oscillationFrequency = freq;
        break;//from   w  w  w  . j  ava2  s.  c  om
    }
    case COMMAND_IN_FREQUENCY_IMMEDIATE: {
        // Is just a float
        final long value = queueEntry.value;
        final int truncVal = (int) value;
        final float freq = Float.intBitsToFloat(truncVal);
        instance.oscillationFrequency = freq;
        instance.runtimeOscillationFrequency = freq;
        break;
    }
    case COMMAND_IN_WAVE: {
        // Is just the integer index of the enum
        final long value = queueEntry.value;
        final int truncVal = (int) value;
        final OscillatorWaveShape waveShape = OscillatorWaveShape.values()[truncVal];
        instance.curWaveShape = waveShape;
        break;
    }
    default: {
        final String msg = "Unknown command passed on incoming queue: " + queueEntry.command;
        log.error(msg);
    }
    }
}

From source file:ByteConvert.java

public static final float[] byte2Float(byte[] inData, boolean byteSwap) {
    int j = 0, value;
    int length = inData.length / 4;
    float[] outData = new float[length];
    if (!byteSwap)
        for (int i = 0; i < length; i++) {
            j = i * 4;/*w  ww .j  ava  2s .c o  m*/
            value = (((inData[j] & 0xff) << 24) + ((inData[j + 1] & 0xff) << 16) + ((inData[j + 2] & 0xff) << 8)
                    + ((inData[j + 3] & 0xff) << 0));
            outData[i] = Float.intBitsToFloat(value);
        }
    else
        for (int i = 0; i < length; i++) {
            j = i * 4;
            value = (((inData[j + 3] & 0xff) << 24) + ((inData[j + 2] & 0xff) << 16)
                    + ((inData[j + 1] & 0xff) << 8) + ((inData[j] & 0xff) << 0));
            outData[i] = Float.intBitsToFloat(value);
        }

    return outData;
}

From source file:uk.co.modularaudio.mads.base.notetocv.mu.NoteToCvIOQueueBridge.java

@Override
public void receiveQueuedEventsToInstance(final NoteToCvMadInstance instance,
        final ThreadSpecificTemporaryEventStorage tses, final long periodTimestamp,
        final IOQueueEvent queueEntry) {
    switch (queueEntry.command) {
    case COMMAND_NOTE_ON_TYPE: {
        final int val = (int) queueEntry.value;
        final NoteOnType not = NoteOnType.values()[val];
        instance.setDesiredNoteOnType(not);
        break;/*from   www.  j a  v a 2 s. c om*/
    }
    case COMMAND_FREQ_GLIDE_MILLIS: {
        final float val = Float.intBitsToFloat((int) queueEntry.value);
        instance.setFrequencyGlideMillis(val);
        break;
    }
    case COMMAND_CHANNEL_NUM: {
        final int channelNum = (int) queueEntry.value;
        instance.setDesiredChannelNum(channelNum);
        break;
    }
    default: {
        final String msg = "Unknown command passed on incoming queue: " + queueEntry.command;
        log.error(msg);
    }
    }
}

From source file:uk.co.modularaudio.mads.base.interptester.mu.InterpTesterIOQueueBridge.java

@Override
public void receiveQueuedEventsToInstance(final InterpTesterMadInstance instance,
        final ThreadSpecificTemporaryEventStorage tses, final long periodTimestamp,
        final IOQueueEvent queueEntry) {
    switch (queueEntry.command) {
    case COMMAND_AMP: {
        final long value = queueEntry.value;
        final int lower32Bits = (int) ((value) & 0xFFFFFFFF);
        final float amp = Float.intBitsToFloat(lower32Bits);
        instance.setDesiredAmp(amp);/*from   w  w  w  .j a v  a2  s . c o  m*/
        break;
    }
    case COMMAND_AMP_NOTS: {
        final long value = queueEntry.value;
        final int lower32Bits = (int) ((value) & 0xFFFFFFFF);
        final float amp = Float.intBitsToFloat(lower32Bits);
        instance.setDesiredAmpNoTs(amp);
        break;
    }
    case COMMAND_CHASE_MILLIS: {
        final float chaseMillis = Float.intBitsToFloat((int) queueEntry.value);
        instance.setChaseMillis(chaseMillis);
        break;
    }
    case COMMAND_SET_MODEL: {
        instance.setModelIndex((int) queueEntry.value);
        break;
    }
    case COMMAND_IMPULSE: {
        instance.startImpulse();
        break;
    }
    case COMMAND_UIACTIVE: {
        instance.setUiActive(queueEntry.value == 1);
        break;
    }
    default: {
        final String msg = "Unknown command passed on incoming queue: " + queueEntry.command;
        log.error(msg);
    }
    }
}

From source file:uk.co.modularaudio.mads.base.cvsurface.mu.CvSurfaceIOQueueBridge.java

@Override
public void receiveQueuedEventsToInstance(final CvSurfaceMadInstance instance,
        final ThreadSpecificTemporaryEventStorage tses, final long periodTimestamp,
        final IOQueueEvent queueEntry) {
    switch (queueEntry.command) {
    case COMMAND_NEWX: {
        // float//from ww w.  ja va2s.  co m
        final long value = queueEntry.value;
        final int truncVal = (int) value;
        final float aa = Float.intBitsToFloat(truncVal);
        instance.setDesiredX(aa);
        break;
    }
    case COMMAND_NEWY: {
        // float
        final long value = queueEntry.value;
        final int truncVal = (int) value;
        final float ab = Float.intBitsToFloat(truncVal);
        instance.setDesiredY(ab);
        break;
    }
    default: {
        final String msg = "Unknown command passed on incoming queue: " + queueEntry.command;
        log.error(msg);
    }
    }
}

From source file:uk.co.modularaudio.mads.base.bandlimitedoscillator.mu.BandLimitedOscillatorIOQueueBridge.java

@Override
public void receiveQueuedEventsToInstance(final BandLimitedOscillatorMadInstance instance,
        final ThreadSpecificTemporaryEventStorage tses, final long periodTimestamp,
        final IOQueueEvent queueEntry) {
    switch (queueEntry.command) {
    case COMMAND_FREQUENCY: {
        // Is just a float
        final long value = queueEntry.value;
        final int truncVal = (int) value;
        final float freq = Float.intBitsToFloat(truncVal);
        instance.setDesiredFrequency(freq);
        break;//from w ww .  j  av  a  2  s .  c  om
    }
    case COMMAND_FREQUENCY_IMMEDIATE: {
        // Is just a float
        final long value = queueEntry.value;
        final int truncVal = (int) value;
        final float freq = Float.intBitsToFloat(truncVal);
        instance.setDesiredFrequencyImmediate(freq);
        break;
    }
    case COMMAND_WAVE: {
        // Is just the integer index of the enum
        final long value = queueEntry.value;
        final int truncVal = (int) value;
        final OscillatorWaveShape waveShape = OscillatorWaveShape.values()[truncVal];
        instance.desiredWaveShape = waveShape;
        log.debug("Received wave shape change");
        break;
    }
    case COMMAND_PULSE_WIDTH: {
        final long value = queueEntry.value;
        final int truncVal = (int) value;
        final float pw = Float.intBitsToFloat(truncVal);
        instance.setDesiredPulseWidth(pw);
        break;
    }
    default: {
        final String msg = "Unknown command passed on incoming queue: " + queueEntry.command;
        log.error(msg);
    }
    }
}

From source file:uk.co.modularaudio.mads.base.sampleplayer.mu.SingleSamplePlayerIOQueueBridge.java

@Override
public void receiveQueuedEventsToInstance(SingleSamplePlayerMadInstance instance,
        ThreadSpecificTemporaryEventStorage tses, long periodTimestamp, IOQueueEvent queueEntry) {
    switch (queueEntry.command) {
    case COMMAND_ROOT_NOTE: {
        MidiNote relatedNote = MidiUtils.getMidiNoteFromNumberReturnNull((int) queueEntry.value);
        if (relatedNote != null) {
            instance.currentRootNoteFreq = relatedNote.getFrequency();
        }//from ww w.  ja  v a 2 s  . c o m
        break;
    }
    case COMMAND_START_POS: {
        float startPosMillis = Float.intBitsToFloat((int) queueEntry.value);
        int startPosFrameNum = AudioTimingUtils.getNumSamplesForMillisAtSampleRate(instance.sampleRate,
                startPosMillis);
        instance.currentStartPosFrameNum = startPosFrameNum;
        break;
    }
    default: {
        String msg = "Unknown command passed on incoming queue: " + queueEntry.command;
        log.error(msg);
    }
    }
}

From source file:uk.co.modularaudio.mads.base.moogfilter.mu.MoogFilterIOQueueBridge.java

@Override
public void receiveQueuedEventsToInstance(final MoogFilterMadInstance instance,
        final ThreadSpecificTemporaryEventStorage tses, final long periodTimestamp,
        final IOQueueEvent queueEntry) {
    switch (queueEntry.command) {
    case COMMAND_FILTER_MODE: {
        // float/*from w  ww .j a  v a2 s .co  m*/
        final long value = queueEntry.value;
        final int truncVal = (int) value;
        instance.setDesiredFilterMode(FrequencyFilterMode.values()[truncVal]);
        break;
    }
    case COMMAND_CUTOFF: {
        // float
        final long value = queueEntry.value;
        final int truncVal = (int) value;
        final float floatVal = Float.intBitsToFloat(truncVal);
        instance.setDesiredNormalisedCutoff(floatVal);
        break;
    }
    case COMMAND_Q: {
        // float
        final long value = queueEntry.value;
        final int truncVal = (int) value;
        final float floatVal = Float.intBitsToFloat(truncVal);
        instance.setDesiredNormalisedQ(floatVal);
        break;
    }
    default: {
        final String msg = "Unknown command passed on incoming queue: " + queueEntry.command;
        log.error(msg);
    }
    }
}

From source file:uk.co.modularaudio.mads.base.djeq.mu.DJEQIOQueueBridge.java

@Override
public void receiveQueuedEventsToInstance(final DJEQMadInstance instance,
        final ThreadSpecificTemporaryEventStorage tses, final long periodTimestamp,
        final IOQueueEvent queueEntry) {
    //      log.debug("Received queued event : " + queueEntry.command);
    switch (queueEntry.command) {
    case COMMAND_IN_ACTIVE: {
        final boolean active = (queueEntry.value == 1);
        instance.setActive(active);/*from w  w w.  j a v a 2 s  .co  m*/
        break;
    }
    case COMMAND_IN_HP_AMP: {
        final int lower32Bits = (int) queueEntry.value;
        final float ampVal = Float.intBitsToFloat(lower32Bits);
        instance.setDesiredHpAmp(ampVal);
        break;
    }
    case COMMAND_IN_BP_AMP: {
        final int lower32Bits = (int) queueEntry.value;
        final float ampVal = Float.intBitsToFloat(lower32Bits);
        instance.setDesiredBpAmp(ampVal);
        break;
    }
    case COMMAND_IN_LP_AMP: {
        final int lower32Bits = (int) queueEntry.value;
        final float ampVal = Float.intBitsToFloat(lower32Bits);
        instance.setDesiredLpAmp(ampVal);
        break;
    }
    case COMMAND_IN_FADER_AMP: {
        final int lower32Bits = (int) queueEntry.value;
        final float ampVal = Float.intBitsToFloat(lower32Bits);
        instance.setDesiredFaderAmp(ampVal);
        break;
    }
    default: {
        final String msg = "Unknown command passed on incoming queue: " + queueEntry.command;
        log.error(msg);
    }
    }
}

From source file:uk.co.modularaudio.mads.base.rbjfilter.mu.RBJFilterIOQueueBridge.java

@Override
public void receiveQueuedEventsToInstance(final RBJFilterMadInstance instance,
        final ThreadSpecificTemporaryEventStorage tses, final long periodTimestamp,
        final IOQueueEvent queueEntry) {
    switch (queueEntry.command) {
    case COMMAND_FILTER_MODE: {
        // float/*  w w  w .j a v  a 2s .co  m*/
        final long value = queueEntry.value;
        final int truncVal = (int) value;
        instance.desiredFilterMode = FrequencyFilterMode.values()[truncVal];

        instance.recomputeFilterParameters();
        break;
    }
    case COMMAND_FREQUENCY: {
        // float
        final long value = queueEntry.value;
        final int truncVal = (int) value;
        final float floatVal = Float.intBitsToFloat(truncVal);
        instance.desiredFrequency = floatVal;

        instance.recomputeFilterParameters();
        break;
    }
    case COMMAND_Q: {
        // float
        final long value = queueEntry.value;
        final int truncVal = (int) value;
        final float floatVal = Float.intBitsToFloat(truncVal);
        instance.desiredQ = floatVal;

        instance.recomputeFilterParameters();
        break;
    }
    default: {
        final String msg = "Unknown command passed on incoming queue: " + queueEntry.command;
        log.error(msg);
    }
    }
}