Search in sources :

Example 1 with Scales

use of de.mossgrabers.framework.scale.Scales in project DrivenByMoss by git-moss.

the class OSCWriter method getNoteColor.

private double[] getNoteColor(final int note) {
    final boolean isKeyboardEnabled = this.model.canSelectedTrackHoldNotes();
    if (!isKeyboardEnabled)
        return OSCColors.getColor(Scales.SCALE_COLOR_OFF);
    if (!this.model.isKeyPressed(note)) {
        final Scales scales = this.model.getScales();
        final String color = scales.getColor(this.model.getKeyTranslationMatrix(), note);
        return OSCColors.getColor(color);
    }
    final boolean isRecording = this.model.hasRecordingState();
    return isRecording ? OSCColors.COLOR_RED : OSCColors.COLOR_GREEN;
}
Also used : Scales(de.mossgrabers.framework.scale.Scales)

Example 2 with Scales

use of de.mossgrabers.framework.scale.Scales in project DrivenByMoss by git-moss.

the class MaschineControllerSetup method createScales.

/**
 * {@inheritDoc}
 */
@Override
protected void createScales() {
    this.scales = new Scales(this.valueChanger, 36, 52, 4, 4);
    this.scales.setDrumMatrix(DRUM_MATRIX);
}
Also used : Scales(de.mossgrabers.framework.scale.Scales)

Example 3 with Scales

use of de.mossgrabers.framework.scale.Scales in project DrivenByMoss by git-moss.

the class MidiModule method parseMidi.

/**
 * Parse virtual MIDI note commands.
 *
 * @param path The rest of the path
 * @param value The value
 * @throws MissingCommandException Could not find the sub-command
 * @throws UnknownCommandException Unknown sub-command
 * @throws IllegalParameterException Added an illegal parameter
 */
private void parseMidi(final LinkedList<String> path, final Object value) throws IllegalParameterException, UnknownCommandException, MissingCommandException {
    final OSCConfiguration conf = this.surface.getConfiguration();
    final String command = getSubCommand(path);
    switch(command) {
        case "velocity":
            final int numValue = toInteger(value);
            conf.setAccentEnabled(numValue > 0);
            if (numValue > 0)
                conf.setFixedAccentValue(numValue);
            return;
        case "noterepeat":
            this.parseNoteRepeat(path, value);
            return;
        default:
            // Fall through
            break;
    }
    int midiChannel;
    try {
        midiChannel = Math.min(Math.max(0, Integer.parseInt(command) - 1), 15);
    } catch (final NumberFormatException ex) {
        throw new UnknownCommandException(command);
    }
    final String subCommand = getSubCommand(path);
    final IMidiInput input = this.surface.getMidiInput();
    final Scales scales = this.model.getScales();
    switch(subCommand) {
        case "note":
            if (path.isEmpty()) {
                final Object[] array = (Object[]) value;
                final int note = ((Number) array[0]).intValue();
                final int velocity = ((Number) array[1]).intValue();
                this.sendNote(conf, midiChannel, input, note, velocity);
                return;
            }
            final String n = getSubCommand(path);
            switch(n) {
                case "+":
                    if (isTrigger(value)) {
                        scales.incOctave();
                        this.updateNoteMatrix(scales);
                    }
                    break;
                case "-":
                    if (isTrigger(value)) {
                        scales.decOctave();
                        this.updateNoteMatrix(scales);
                    }
                    break;
                default:
                    this.sendNote(conf, midiChannel, input, Integer.parseInt(n), toInteger(value));
                    break;
            }
            break;
        case "drum":
            final String n2 = getSubCommand(path);
            switch(n2) {
                case "+":
                    if (isTrigger(value)) {
                        scales.incDrumOctave();
                        this.surface.getDisplay().notify(scales.getDrumRangeText());
                    }
                    break;
                case "-":
                    if (isTrigger(value)) {
                        scales.decDrumOctave();
                        this.surface.getDisplay().notify(scales.getDrumRangeText());
                    }
                    break;
                default:
                    final int note = Integer.parseInt(n2);
                    int numValue = toInteger(value);
                    if (numValue > 0)
                        numValue = conf.isAccentActive() ? conf.getFixedAccentValue() : numValue;
                    final int data0 = this.model.getScales().getDrumMatrix()[note];
                    if (data0 >= 0)
                        input.sendRawMidiEvent(0x90 + midiChannel, data0, numValue);
                    break;
            }
            break;
        case "cc":
            if (path.isEmpty()) {
                this.host.println("Missing MIDI CC value.");
                return;
            }
            final int cc = Integer.parseInt(path.removeFirst());
            input.sendRawMidiEvent(0xB0 + midiChannel, cc, toInteger(value));
            break;
        case "aftertouch":
            int numValue = toInteger(value);
            if (numValue > 0)
                numValue = conf.isAccentActive() ? conf.getFixedAccentValue() : numValue;
            if (path.isEmpty()) {
                input.sendRawMidiEvent(0xD0 + midiChannel, 0, numValue);
                return;
            }
            final int note = Integer.parseInt(path.removeFirst());
            input.sendRawMidiEvent(0xA0 + midiChannel, this.surface.getKeyTranslationTable()[note], numValue);
            break;
        case "pitchbend":
            input.sendRawMidiEvent(0xE0 + midiChannel, 0, toInteger(value));
            break;
        default:
            throw new UnknownCommandException(command);
    }
}
Also used : OSCConfiguration(de.mossgrabers.controller.osc.OSCConfiguration) IMidiInput(de.mossgrabers.framework.daw.midi.IMidiInput) UnknownCommandException(de.mossgrabers.controller.osc.exception.UnknownCommandException) Scales(de.mossgrabers.framework.scale.Scales)

Example 4 with Scales

use of de.mossgrabers.framework.scale.Scales in project DrivenByMoss by git-moss.

the class OSCControllerSetup method createScales.

/**
 * {@inheritDoc}
 */
@Override
protected void createScales() {
    this.scales = new Scales(this.valueChanger, 0, 128, 128, 1);
    this.scales.setChromatic(true);
}
Also used : Scales(de.mossgrabers.framework.scale.Scales)

Example 5 with Scales

use of de.mossgrabers.framework.scale.Scales in project DrivenByMoss by git-moss.

the class GenericFlexiControllerSetup method createScales.

/**
 * {@inheritDoc}
 */
@Override
protected void createScales() {
    this.scales = new Scales(this.valueChanger, 0, 128, 128, 1);
    this.scales.setChromatic(true);
}
Also used : Scales(de.mossgrabers.framework.scale.Scales)

Aggregations

Scales (de.mossgrabers.framework.scale.Scales)26 ICursorDevice (de.mossgrabers.framework.daw.ICursorDevice)3 ViewManager (de.mossgrabers.framework.view.ViewManager)3 PlayView (de.mossgrabers.controller.ni.maschine.mk3.view.PlayView)2 ITextDisplay (de.mossgrabers.framework.controller.display.ITextDisplay)2 ITrack (de.mossgrabers.framework.daw.data.ITrack)2 INoteMode (de.mossgrabers.framework.mode.INoteMode)2 AbstractSequencerView (de.mossgrabers.framework.view.AbstractSequencerView)2 View (de.mossgrabers.framework.view.View)2 DrumView (de.mossgrabers.launchpad.view.DrumView)2 PlayView (de.mossgrabers.launchpad.view.PlayView)2 RaindropsView (de.mossgrabers.launchpad.view.RaindropsView)2 SequencerView (de.mossgrabers.launchpad.view.SequencerView)2 OscAddressSpace (com.bitwig.extension.api.opensoundcontrol.OscAddressSpace)1 OscModule (com.bitwig.extension.api.opensoundcontrol.OscModule)1 ControllerHost (com.bitwig.extension.controller.api.ControllerHost)1 GenericFlexiConfiguration (de.mossgrabers.controller.generic.GenericFlexiConfiguration)1 FlexiHandlerException (de.mossgrabers.controller.generic.flexihandler.utils.FlexiHandlerException)1 MaschineConfiguration (de.mossgrabers.controller.ni.maschine.mk3.MaschineConfiguration)1 DrumView (de.mossgrabers.controller.ni.maschine.mk3.view.DrumView)1