Welcome to %s forums

BrainModular Users Forum

Login Register

Teensy 2.0 with Usine to stretch a Sampler Yeahh

General Discussion about whatever fits..
Post Reply
thomaschamotte
Member
Posts: 172
Location: Toronto
Contact:

Unread post by thomaschamotte » 19 Aug 2017, 04:35

Hi everyone,

I had a discussion with Oli_Lab to know if it was possible to create a midi solution to stretch my Digitech JamMan Stereo.
Follow this topic: http://www.sensomusic.org/forums/viewtopic.php?id=5812

To sum up :
I use Usine and the sampler Digitech JamMan Stereo.
With Footswitch FS3X ( who is a propriety of Digitech) you can stretch the JamMan in real time.

What i wanted to do is to let Usine Stretch the JamMan in clock.

Oli_Lab told me to use a Teensy 2.0 with Arduino.
I finally found all the micro electronic components. And i built the circuit as the Footswitch FS3X but with Optocouplers to replace the switches of the footswitch and the Teensy 2.0 to communicate in midi with Usine.

Here is the chronologie to visualize where i am.

1 - i build the circuit as a footswitch with the Teensy
2 - Installation of the Teensy
3 - Installation of Arduino
4 - Installation of the Teensyduino

5 - Configurate Arduino
Tools -> . Board : Teensy 2.0
. USB Type : Midi
. CPU Speed : 16MHz
. Keyboard Layout : French

6 - Create a Patch in Usine

Now, when i open Usine the Teensy is recognized as an interface Midi.
So Usine and the Teensy can communicate.

But i'm copletely locked because i don't know how to create the patch properly...

Can you help me please ?

Thank you for reading.

User avatar
oli_lab
Member
Posts: 1263
Location: Brittany, France
Contact:

Unread post by oli_lab » 19 Aug 2017, 14:19

Good work !
yes I will help.
but need more infos :
- did you manage to programm the teensy so it receive MIDI controlers ?
- if you only have trouble with patching Usine :
[q]- put the midi out device of the teensy at the bottom of your rack
- use a midi out inside your patch[/q]
http://oli-lab.org

Win11 Ryzen9/32GB RAM - RME MADIFACE - SSL alpha link 4-16 - OSC capable interfaces

follow OLI_LAB adventures on Mastodon
@olivar_premier@mastodon.social

thomaschamotte
Member
Posts: 172
Location: Toronto
Contact:

Unread post by thomaschamotte » 19 Aug 2017, 17:01

oli_lab wrote:Good work !
yes I will help.
but need more infos :
- did you manage to programm the teensy so it receive MIDI controlers ?
- if you only have trouble with patching Usine :
[q]- put the midi out device of the teensy at the bottom of your rack
- use a midi out inside your patch[/q]
I try to answer to your questions so i did few prints screens to think about it.
Now, my way of thinking is maybe not the good one, because it is the first time of my life i am front of Arduino (i never heard about this soft before... ) and because i did'nt found the good way to do a patch.
But now i doubt. Maybe i don't have to do a patch in Usine ? Maybe i juste Have to code in Arduino... ??
And this is what i did


This is the code i have puted in the Teensy with Arduino.
Image

Image


Do i have to send a midi clock ?
Image

This is the beginning...

Image

User avatar
oli_lab
Member
Posts: 1263
Location: Brittany, France
Contact:

Unread post by oli_lab » 19 Aug 2017, 19:09

ok
first thing to do is having a correct program for the teensy, and from what I saw, you need help ! ;-)

on the teensy side, you need a program that gets midi and commands digital outputs for the optocouplers :

#define channel_opto 1
#define opto1 1 //change to another digital pin to fit your schematics
#define opto2 2 // idem
#define opto3 3 // idem

#define CCopto1 100 //CC#100 commande opto 1
#define CCopto2 102
#define CCopto3 103

#define impulseLength 100 //impulse is 100ms wide
byte token1 = 0;
byte token2 = 0;
byte token3 = 0;

#define MIDI_ON

void setup() {
// put your setup code here, to run once:
pinMode(opto1, OUTPUT);
pinMode(opto2, OUTPUT);
pinMode(opto3, OUTPUT);
#ifdef MIDI_ON
usbMIDI.setHandleControlChange(OnControlChange); //will handle control change only
#endif
} //end setup

// midi callbacks :
void OnControlChange(byte channel, byte control, byte value) {
if (channel == channel_opto) {
switch (control) {
case CCopto1: //make a impulse
if (value > 64 && token1 == 0) {
digitalWrite(opto1, HIGH);
delay(impulseLength);
digitalWrite(opto1, LOW);
}
else if (value < 64 && token1 == 1) {
token1 == 0;
}
break;
case CCopto2: //make a impulse
if (value > 64 && token2 == 0) {
digitalWrite(opto2, HIGH);
delay(impulseLength);
digitalWrite(opto2, LOW);
}
else if (value < 64 && token2 == 1) {
token2 == 0;
}
break;
case CCopto3: //make a impulse
if (value > 64 && token3 == 0) {
digitalWrite(opto3, HIGH);
delay(impulseLength);
digitalWrite(opto3, LOW);
}
else if (value < 64 && token3 == 1) {
token3 == 0;
}
break;

default :
break;
}
}
else {}
}

void loop() {
// put your main code here, to run repeatedly:
// nada
}
http://oli-lab.org

Win11 Ryzen9/32GB RAM - RME MADIFACE - SSL alpha link 4-16 - OSC capable interfaces

follow OLI_LAB adventures on Mastodon
@olivar_premier@mastodon.social

thomaschamotte
Member
Posts: 172
Location: Toronto
Contact:

Unread post by thomaschamotte » 19 Aug 2017, 19:38

oli_lab wrote:ok
first thing to do is having a correct program for the teensy, and from what I saw, you need help ! ;-)

on the teensy side, you need a program that gets midi and commands digital outputs for the optocouplers :

#define channel_opto 1
#define opto1 1 //change to another digital pin to fit your schematics
#define opto2 2 // idem
#define opto3 3 // idem

#define CCopto1 100 //CC#100 commande opto 1
#define CCopto2 102
#define CCopto3 103

#define impulseLength 100 //impulse is 100ms wide
byte token1 = 0;
byte token2 = 0;
byte token3 = 0;

#define MIDI_ON

void setup() {
// put your setup code here, to run once:
pinMode(opto1, OUTPUT);
pinMode(opto2, OUTPUT);
pinMode(opto3, OUTPUT);
#ifdef MIDI_ON
usbMIDI.setHandleControlChange(OnControlChange); //will handle control change only
#endif
} //end setup

// midi callbacks :
void OnControlChange(byte channel, byte control, byte value) {
if (channel == channel_opto) {
switch (control) {
case CCopto1: //make a impulse
if (value > 64 && token1 == 0) {
digitalWrite(opto1, HIGH);
delay(impulseLength);
digitalWrite(opto1, LOW);
}
else if (value < 64 && token1 == 1) {
token1 == 0;
}
break;
case CCopto2: //make a impulse
if (value > 64 && token2 == 0) {
digitalWrite(opto2, HIGH);
delay(impulseLength);
digitalWrite(opto2, LOW);
}
else if (value < 64 && token2 == 1) {
token2 == 0;
}
break;
case CCopto3: //make a impulse
if (value > 64 && token3 == 0) {
digitalWrite(opto3, HIGH);
delay(impulseLength);
digitalWrite(opto3, LOW);
}
else if (value < 64 && token3 == 1) {
token3 == 0;
}
break;

default :
break;
}
}
else {}
}

void loop() {
// put your main code here, to run repeatedly:
// nada
}
Indeed you are right :) i couldn't start without your light.

I read the code with attention and i understand now.
If i change the beginning of the code like this it make sens ?
Because i use the pin 0,1 and 2 in the Teensy.

Image

thomaschamotte
Member
Posts: 172
Location: Toronto
Contact:

Unread post by thomaschamotte » 19 Aug 2017, 20:12

thomaschamotte wrote:
oli_lab wrote:ok
first thing to do is having a correct program for the teensy, and from what I saw, you need help ! ;-)

on the teensy side, you need a program that gets midi and commands digital outputs for the optocouplers :

#define channel_opto 1
#define opto1 1 //change to another digital pin to fit your schematics
#define opto2 2 // idem
#define opto3 3 // idem

#define CCopto1 100 //CC#100 commande opto 1
#define CCopto2 102
#define CCopto3 103

#define impulseLength 100 //impulse is 100ms wide
byte token1 = 0;
byte token2 = 0;
byte token3 = 0;

#define MIDI_ON

void setup() {
// put your setup code here, to run once:
pinMode(opto1, OUTPUT);
pinMode(opto2, OUTPUT);
pinMode(opto3, OUTPUT);
#ifdef MIDI_ON
usbMIDI.setHandleControlChange(OnControlChange); //will handle control change only
#endif
} //end setup

// midi callbacks :
void OnControlChange(byte channel, byte control, byte value) {
if (channel == channel_opto) {
switch (control) {
case CCopto1: //make a impulse
if (value > 64 && token1 == 0) {
digitalWrite(opto1, HIGH);
delay(impulseLength);
digitalWrite(opto1, LOW);
}
else if (value < 64 && token1 == 1) {
token1 == 0;
}
break;
case CCopto2: //make a impulse
if (value > 64 && token2 == 0) {
digitalWrite(opto2, HIGH);
delay(impulseLength);
digitalWrite(opto2, LOW);
}
else if (value < 64 && token2 == 1) {
token2 == 0;
}
break;
case CCopto3: //make a impulse
if (value > 64 && token3 == 0) {
digitalWrite(opto3, HIGH);
delay(impulseLength);
digitalWrite(opto3, LOW);
}
else if (value < 64 && token3 == 1) {
token3 == 0;
}
break;

default :
break;
}
}
else {}
}

void loop() {
// put your main code here, to run repeatedly:
// nada
}
Indeed you are right :) i couldn't start without your light.

I read the code with attention and i understand now.
If i change the beginning of the code like this it make sens ?
Because i use the pin 0,1 and 2 in the Teensy.

http://www.sensomusic.com/forums/upload ... ino_pg.jpg
Now i have to do the patch in Usine based on the code. Doesn't it ?

User avatar
oli_lab
Member
Posts: 1263
Location: Brittany, France
Contact:

Unread post by oli_lab » 19 Aug 2017, 20:58

you don't need the channel_opto 2 and 3 as it is the midi receiving channel
just leave channel_opto 1 and the teensy will receive on midi channel 1

the Usine patch :

Image
http://oli-lab.org

Win11 Ryzen9/32GB RAM - RME MADIFACE - SSL alpha link 4-16 - OSC capable interfaces

follow OLI_LAB adventures on Mastodon
@olivar_premier@mastodon.social

thomaschamotte
Member
Posts: 172
Location: Toronto
Contact:

Unread post by thomaschamotte » 21 Aug 2017, 00:41

oli_lab wrote:you don't need the channel_opto 2 and 3 as it is the midi receiving channel
just leave channel_opto 1 and the teensy will receive on midi channel 1

the Usine patch :

http://www.sensomusic.com/forums/upload ... xemple.PNG
Hi Oli_Lab,

I don't know why but it doesn't work yet...

I have screened shot my configuration to show you.
I have followed all your instructions word after word so i don't think the problem come from the numeric side.

Image
Image
Image

If you see any problem i have to bring my self to do an other Circuit.
I would be surprised if the problem come from my Circuit because it is very clean and correct...

User avatar
oli_lab
Member
Posts: 1263
Location: Brittany, France
Contact:

Unread post by oli_lab » 21 Aug 2017, 20:06

can you show me the schematic ?
plz
http://oli-lab.org

Win11 Ryzen9/32GB RAM - RME MADIFACE - SSL alpha link 4-16 - OSC capable interfaces

follow OLI_LAB adventures on Mastodon
@olivar_premier@mastodon.social

thomaschamotte
Member
Posts: 172
Location: Toronto
Contact:

Unread post by thomaschamotte » 21 Aug 2017, 22:17

oli_lab wrote:can you show me the schematic ?
plz
Image

I have taken your picture

User avatar
oli_lab
Member
Posts: 1263
Location: Brittany, France
Contact:

Unread post by oli_lab » 22 Aug 2017, 21:56

what could be great is to check the outputs of the teensy, when sending CC :
on each pin (0,1,2) put a LED with a 180 Ohms resistor in series INSTEAD of the optocoupler
check if they lit OK
or if any, check between 1 and 2 of the optocouplers with a voltmeter.
http://oli-lab.org

Win11 Ryzen9/32GB RAM - RME MADIFACE - SSL alpha link 4-16 - OSC capable interfaces

follow OLI_LAB adventures on Mastodon
@olivar_premier@mastodon.social

thomaschamotte
Member
Posts: 172
Location: Toronto
Contact:

Unread post by thomaschamotte » 23 Aug 2017, 17:04

oli_lab wrote:what could be great is to check the outputs of the teensy, when sending CC :
on each pin (0,1,2) put a LED with a 180 Ohms resistor in series INSTEAD of the optocoupler
check if they lit OK
or if any, check between 1 and 2 of the optocouplers with a voltmeter.
Hi Oli_Lab,

I have looked for Hack Lab in Toronto with https://hacklab.to/about.
So yesterday i was to them open office door.
A great peaceful place with lot off geeks who really want to help you.

I have explained everything about my Teensy/Usine/Sampler project and one of the geek has helped me.

So your schematic was good and my capacities to make a circuit is ok.
The Usine patch was good too.

Wherever there wasn't good was the Arduino Code.
We have worked on it together with the HackLab Man and finally it works !!!

I give you the good code here and invite you to put an eye on, it's very interesting:

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
#define channel_opto 1
#define opto1 0 //change to another digital pin to fit your schematics
#define opto2 1 // idem
#define opto3 2 // idem
#define LEDPIN 11 // the LED is on pin 11

#define CCopto1 100 //CC#100 commande opto 1
#define CCopto2 102 //CC#102 commande opto 2
#define CCopto3 103 //CC#103 commande opto 3

#define impulseLength 100 //impulse is 100ms wide
byte token1 = 0;
byte token2 = 0;
byte token3 = 0;

long lastBlink = 0;
byte LEDON = 0; // Set to 1 when the LED is on.

#define MIDI_ON

void setup() {
// put your setup code here, to run once:
pinMode(opto1, OUTPUT);
pinMode(opto2, OUTPUT);
pinMode(opto3, OUTPUT);
pinMode(LEDPIN, OUTPUT); // LED pin

Serial.begin(9600); // initialize the serial port at 9600 baud
Serial.println("Starting up...");



#ifdef MIDI_ON
usbMIDI.setHandleControlChange(OnControlChange); //will handle control change only
#endif
} //end setup

// midi callbacks :
void OnControlChange(byte channel, byte control, byte value) {

//Serial.println("MIDI control change arrived!");

// Every time data is received, blink the LED.
digitalWrite(LEDPIN, HIGH);
LEDON = 255;

if (channel == channel_opto) {
switch (control) {
case CCopto1: //make a impulse
if (value > 64 && token1 == 0) {
digitalWrite(opto1, HIGH);
delay(impulseLength);
digitalWrite(opto1, LOW);
Serial.print("pressing 100");
token1 = 1; // mark that the output is ON -- prevents it from sending more than once.
}
else if (value < 64 && token1 == 1) {
Serial.println("releasing 100");
token1 = 0;
}
break;
case CCopto2: //make a impulse
if (value > 64 && token2 == 0) {
digitalWrite(opto2, HIGH);
delay(impulseLength);
digitalWrite(opto2, LOW);
Serial.println("pressing 101");
token2 = 1;
}
else if (value < 64 && token2 == 1) {
token2 = 0;
Serial.println("releasing 101");

}
break;
case CCopto3: //make a impulse
if (value > 64 && token3 == 0) {
digitalWrite(opto3, HIGH);
delay(impulseLength);
digitalWrite(opto3, LOW);
Serial.println("pressing 102");

token3 = 1;
}
else if (value < 64 && token3 == 1) {
token3 = 0;
Serial.println("releasing 102");

}
break;

default :
break;
}
}
else {}
}

void loop() {
// put your main code here, to run repeatedly:


// Check the USB Midi to see if any messages have been received:
usbMIDI.read();

if (LEDON > 0)
{
// If the LED is on, we want to turn it off.
LEDON--;
if (LEDON == 0) digitalWrite(LEDPIN, LOW);
}


if (millis() - lastBlink > 5000) // has it been 1000ms since our last blink?
{
// Time to blink the LED
lastBlink = millis();
digitalWrite(LEDPIN, HIGH);
LEDON = 255;
}




}

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

So it works.
What does it mean it works.
It means when Usine says to the Teensy :
- Put On Mode (1st Optocoupler) : the Sampler immediately undoing and redoing the last recorded overdub

- Put On Down (2nd Optocoupler) : The sampler play the recorded phrase in reverse

- Put On Up (3rd Optocoupler) : the sampler set the tempo of a new loop change the tempo (time stretch) of a stored loop. Playback tempo can be changed even while the loop is playing using this Teensy.

BUT
What i hadn't noticed well when i begun to built everything it is : "The footswitch can be used to set the tempo of a new loop or change the tempo of a stored loop."

- Set the tempo of a new loop means you put the tempo and after you play on it.
- Change the tempo of a stored loop means you already have stored a loop.

!!! But you can't record a loop without have stored it and change the tempo in real time !!!
There is a subtle difference but if you use the hardware this difference is huge.

To Finish,
if i want that Usine put a tempo all the time to the JamMan, i thought i must to make up in Clock Module the original Up Button in the Patch.
But if the module send a clock signal all the time to the Teensy -> Jam Man, the loop can have some weird cracks or jumps.
The interesting thing is that Jam Man know what is the tempo with a minimum of two impulses.
So i have to creat in a patch a clock who give to the Teensy/JamMan two impulses all the 50 or 100 impulses...
I don't know yet i have to try it.


Anyway,
Thank you a lot for your real big help Oli_Lab.
Even we never see each other and the complexity of the Teensy/Usine/JamMan communication project in relation to my skills it is a success !!
So we have the proof of the Power of the Usine Community !

Bye Bye.

User avatar
nay-seven
Site Admin
Posts: 5684
Location: rennes France
Contact:

Unread post by nay-seven » 23 Aug 2017, 17:33

Congrats guys !!

Post Reply

Who is online

Users browsing this forum: No registered users and 20 guests