Skip to content

Commit

Permalink
Impulse 25 support (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
tlipinski authored Jun 15, 2017
1 parent 32072c3 commit 0d2764a
Show file tree
Hide file tree
Showing 13 changed files with 119 additions and 25 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Bitwig Novation Impulse 49/61
Novation Impulse 49/61 controller script
# Bitwig Novation Impulse 25/49/61
Novation Impulse 25/49/61 controller script

## Installation
1. Go to Releases page (https://github.com/tlipinski/bitwig-novation-impulse/releases) and download zip archive with latest script version.
2. Unzip archive and place `NovationImpulse4961.bwextension` file in:
2. Unzip archive and place `NovationImpulse.bwextension` file in:
- OSX
`Documents/Bitwig Studio/Extensions`
- Windows
Expand Down
2 changes: 1 addition & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ test:
override:
- mvn clean package
post:
- cp target/NovationImpulse4961.bwextension $CIRCLE_ARTIFACTS
- cp target/NovationImpulse.bwextension $CIRCLE_ARTIFACTS
2 changes: 1 addition & 1 deletion install-extension.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env bash

cp target/NovationImpulse4961.bwextension ~/Bitwig\ Studio/Extensions
cp target/NovationImpulse.bwextension ~/Bitwig\ Studio/Extensions
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.tlipinski</groupId>
<artifactId>bitwig-novation-impulse-49-61</artifactId>
<artifactId>bitwig-novation-impulse</artifactId>
<packaging>jar</packaging>
<name>Novation Impulse 49/61</name>
<name>Novation Impulse</name>
<version>1.0-beta.3-SNAPSHOT</version>

<repositories>
Expand Down Expand Up @@ -57,7 +57,7 @@
</goals>
<configuration>
<sourceFile>${project.build.directory}/${project.build.finalName}.jar</sourceFile>
<destinationFile>${project.build.directory}/NovationImpulse4961.bwextension</destinationFile>
<destinationFile>${project.build.directory}/NovationImpulse.bwextension</destinationFile>
</configuration>
</execution>
</executions>
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/net/tlipinski/bitwig/controller/Controller.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.tlipinski.bitwig.controller;

import com.bitwig.extension.controller.api.*;
import net.tlipinski.bitwig.controller.observers.ImpulseModel;

public class Controller {

Expand Down Expand Up @@ -62,6 +63,14 @@ public EncoderMixerModePage getEncoderMixerPage() {
return encoderMixerPage;
}

public void setModel(ImpulseModel model) {
this.model = model;
}

public ImpulseModel getModel() {
return model;
}

private final ControllerHost host;
private final Tracks tracks;
private final SysexSend sysexSend;
Expand All @@ -70,5 +79,6 @@ public EncoderMixerModePage getEncoderMixerPage() {
private EncoderMode encoderMode = EncoderMode.PLUGIN;
private boolean shiftPressed = false;
private EncoderMixerModePage encoderMixerPage = new EncoderMixerModePage();
private ImpulseModel model;

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
import java.util.Arrays;
import java.util.List;

public class NovationImpulse4961Extension extends ControllerExtension {
protected NovationImpulse4961Extension(final NovationImpulse4961ExtensionDefinition definition, final ControllerHost host) {
public class NovationImpulseExtension extends ControllerExtension {

private Controller controller;

protected NovationImpulseExtension(final NovationImpulseExtensionDefinition definition, final ControllerHost host) {
super(definition, host);
}

Expand All @@ -26,12 +29,13 @@ public void init() {

Tracks tracks = new Tracks(host);

Controller controller = new Controller(host, tracks, sysexSend, prefs);
controller = new Controller(host, tracks, sysexSend, prefs);

List<MidiCommand> midiCommands = Arrays.asList(
new SceneUpCommand(controller),
new SceneDownCommand(controller),
new SceneLaunchCommand(controller),
new FaderCursorCommand(controller, midiSend, sysexSend),
new FaderCommand(controller, midiSend, sysexSend),
new ButtonsModeCommand(controller, midiSend, sysexSend),
new SingleMuteCommand(controller, midiSend, sysexSend),
Expand Down Expand Up @@ -70,20 +74,18 @@ public void init() {
host.getMidiInPort(0).setMidiCallback(new MidiCallback(host, prefs, midiCommands));
host.getMidiInPort(1).setMidiCallback(new MidiCallback(host, prefs, midiCommands));

host.getMidiInPort(0).setSysexCallback(new SysexCallback(host, prefs));
host.getMidiInPort(1).setSysexCallback(new SysexCallback(host, prefs));
host.getMidiInPort(0).setSysexCallback(new SysexCallback(host, controller, prefs));
host.getMidiInPort(1).setSysexCallback(new SysexCallback(host, controller, prefs));

NoteInput noteInputs0 = createNoteInputs(host, 0);
NoteInput noteInputs1 = createNoteInputs(host, 1);

host.showPopupNotification("Novation Impulse 49 Initialized");

sysexSend.initController();
}

@Override
public void exit() {
getHost().showPopupNotification("Novation Impulse 49 Exited");
getHost().showPopupNotification("Novation Impulse " + controller.getModel().keys + " Exited");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@

import java.util.UUID;

public class NovationImpulse4961ExtensionDefinition extends ControllerExtensionDefinition
public class NovationImpulseExtensionDefinition extends ControllerExtensionDefinition
{
private static final UUID DRIVER_ID = UUID.fromString("c502ace6-b694-4037-a924-4476f9062b0f");

public NovationImpulse4961ExtensionDefinition()
public NovationImpulseExtensionDefinition()
{
}

@Override
public String getName()
{
return "Novation Impulse 49/61";
return "Novation Impulse";
}

@Override
Expand Down Expand Up @@ -47,7 +47,7 @@ public String getHardwareVendor()
@Override
public String getHardwareModel()
{
return "Impulse 49/61";
return "Impulse 25/49/61";
}

@Override
Expand Down Expand Up @@ -89,8 +89,8 @@ else if (platformType == PlatformType.LINUX) {
}

@Override
public NovationImpulse4961Extension createInstance(final ControllerHost host)
public NovationImpulseExtension createInstance(final ControllerHost host)
{
return new NovationImpulse4961Extension(this, host);
return new NovationImpulseExtension(this, host);
}
}
16 changes: 15 additions & 1 deletion src/main/java/net/tlipinski/bitwig/controller/SysexCallback.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@

import com.bitwig.extension.callback.SysexMidiDataReceivedCallback;
import com.bitwig.extension.controller.api.ControllerHost;
import net.tlipinski.bitwig.controller.observers.ImpulseModel;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class SysexCallback implements SysexMidiDataReceivedCallback {

public SysexCallback(ControllerHost host, Preferences prefs) {
public SysexCallback(ControllerHost host, Controller controller, Preferences prefs) {
this.host = host;
this.controller = controller;
this.prefs = prefs;
}

Expand All @@ -15,8 +20,17 @@ public void sysexDataReceived(String data) {
if (prefs.debug()) {
host.println("Received sysex: " + data);
}

Matcher matcher = impulseWelcome.matcher(data);
if (matcher.matches()) {
int model = Integer.valueOf(matcher.group(1), 16);
controller.setModel(ImpulseModel.get(model));
host.showPopupNotification("Novation Impulse " + model + " Initialized");
}
}

private Pattern impulseWelcome = Pattern.compile("f00020296707(..)f7");
private final ControllerHost host;
private final Controller controller;
private final Preferences prefs;
}
2 changes: 1 addition & 1 deletion src/main/java/net/tlipinski/bitwig/controller/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
public class Version {
public static String get() {
try {
String pomProperties = "/META-INF/maven/net.tlipinski/bitwig-novation-impulse-49-61/pom.properties";
String pomProperties = "/META-INF/maven/net.tlipinski/bitwig-novation-impulse/pom.properties";
Properties props = new Properties();
props.load(new InputStreamReader(Version.class.getResourceAsStream(pomProperties)));
return props.getProperty("version");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public FaderCommand(Controller controller, MidiSend midiSend, SysexSend sysexSen
@Override
public Stream<Boolean> triggersWhen(int statusByte, int data1, int data2) {
return Stream.of(
controller.getModel().isImpulse49or61(),
statusByte == 0xB0,
data1 >= 0,
data1 <= 8
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package net.tlipinski.bitwig.controller.commands;

import com.bitwig.extension.controller.api.Track;
import net.tlipinski.bitwig.controller.Controller;
import net.tlipinski.bitwig.controller.MidiCommand;
import net.tlipinski.bitwig.controller.MidiSend;
import net.tlipinski.bitwig.controller.SysexSend;

import java.util.stream.Stream;

public class FaderCursorCommand implements MidiCommand {

public FaderCursorCommand(Controller controller, MidiSend midiSend, SysexSend sysexSend) {
this.controller = controller;
this.midiSend = midiSend;
this.sysexSend = sysexSend;

controller.getTracks().getCursorTrack().name().markInterested();
}

@Override
public Stream<Boolean> triggersWhen(int statusByte, int data1, int data2) {
return Stream.of(
controller.getModel().isImpulse25(),
statusByte == 0xB0,
data1 == 8
);
}

@Override
public void handle(int data1, int data2) {
Track t = this.controller.getTracks().getCursorTrack();
t.getVolume().set(data2, 128);
this.sysexSend.displayText(t.name().get());

// this will display volume value
this.midiSend.send(0xB0, data1, data2);
}

private Controller controller;
private final MidiSend midiSend;
private SysexSend sysexSend;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package net.tlipinski.bitwig.controller.observers;

public enum ImpulseModel {
IMPULSE_25(25), IMPULSE_49(49), IMPULSE_61(61);

ImpulseModel(int keys) {
this.keys = keys;
}

public boolean isImpulse25() {
return this == IMPULSE_25;
}

public boolean isImpulse49or61() {
return this == IMPULSE_49 || this == IMPULSE_61;
}

public static ImpulseModel get(int keys) {
return ImpulseModel.valueOf("IMPULSE_" + keys);
}

public final int keys;
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
net.tlipinski.bitwig.controller.NovationImpulse4961ExtensionDefinition
net.tlipinski.bitwig.controller.NovationImpulseExtensionDefinition

0 comments on commit 0d2764a

Please sign in to comment.