Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Good job! #2

Open
benwadub opened this issue Apr 3, 2020 · 10 comments
Open

Good job! #2

benwadub opened this issue Apr 3, 2020 · 10 comments

Comments

@benwadub
Copy link

benwadub commented Apr 3, 2020

Hello, i just start my investigation to make my first teensy synth and I called on your project it seems very good!
Is it possible to use only the teensy .ino to play the synth with a teensy controller already built or an existing midi keyboard?
I m looking for a project to start with cause I m really new to programming so I need to learn and didn’t find how to use the audio library with my midi keyboard :-(
Sorry for my poor English I m French!

@troisiemetype
Copy link
Owner

Hi Ben.

Pas de problème pour l'anglais, je ne relève pas, je suis français aussi ! ;)
(but I'll go on in english, sorry...)

You can use only the Teensy part, yes. You'll have some minor modifications to do, as :

  • implement the MIDI-in part if you want to use MIDI DIN connectors. It should be straightforward, you just have to create a hardware Serial (there are 7 on the Teensy 4.0, choose whichever you need). If you want to make the synth without the keyboard part, you just have to map note on and note off, pitchbend, and mod wheel. For modwheel you may need to create a handler new handler for CC and implement only modwheel in it, so the external midi don't mess with other CC that are used internally. If you want to control others things, you should as well implement them. Some controls I used have a different CC number, but 7 bits was not enough to me for some controls.
  • Remember MIDI plugs have to be isolated with an optocoupler. You find schematics on the web. And maybe modules too.
  • Teensy has not enough IO for every switches and potentiometers, that's why I used two others Mega boards. But the Audio part uses around 5% of the CPU time, so you can use a port expander or multiplexer to connect everything and handle it with Teensy. There's plenty of room for it.

Hope that answers to your questions !

@benwadub
Copy link
Author

benwadub commented Apr 4, 2020

No problem to continue in English, It s better for everyone that ´ll read this later! I ll check the teensy code, no problem for me to make a midi in/out/thru I already built one for my controler!
I ll try to make an expander version of your synth to sequence it with my elektron digitakt!
Merci du Jura

@benwadub
Copy link
Author

benwadub commented Apr 4, 2020

hi just a question, if my midi notes come from a sequencer via midi din does the teensy recognize all note on and note off? If not I don t know how to setup each midi note if they don t come from a pin or mux

@troisiemetype
Copy link
Owner

Hi,

If you look at the code, you will see that are too handlers for note on and note off.

  • One is the internal handler. It takes every notes coming for the first Arduino mega, offset them (the mega sends pitch from 0 to 30), echo them to MIDI out, then sends them to :
  • global handler, which is also the external handler. This one handles note priority priority mode, and calls note on and note off functions when needed.

It's the same for note off messages.

On the two tracks I've recorded with the synth, I've recorded the midi parts with Ardour, then quantize them and played back trough the synth to record audio. ;)

@benwadub
Copy link
Author

benwadub commented Apr 4, 2020

ok so if I understand well it should work out of the box!
I just have to compile your code and mine and I could control your synth with my controller!
does my code interest you? it s a midi mixer with 8 midi channels 40 pots 8 faders and 8 encoders, 8 midi notes and 8 buttons for mute using the great tttapa control surface library
I can give it to you if you want!

@troisiemetype
Copy link
Owner

Yeah, it could be usefull ! I was thinking about making a midi mixer for easier use of Ardour ! Don't you have a repository for it ?

@benwadub
Copy link
Author

benwadub commented Apr 4, 2020

i don t have a repository, I m a very noob at all this! I m a food truck owner so with this corona crisis I get time to learn things here is my code

#include <Encoder.h>


// celà doit etre écrit avant la library control surface
#include <Control_Surface.h> // Inclu la library control surface téléchargeable ici https://github.com/tttapa/Control-Surface en cliquant le bouton vert a droite
 //USBDebugMIDI_Interface midi = 115200; // enlever les // en début de ligne pour entrer en mode debug usb et voir dans le panneau de control si vos controler envoient bien les infos

//auto &serial = Serial1;// Selectionne le port série à utiliser remplacer par serial pour une arduino
USBMIDI_Interface usbmidi;// enlever les / en debut de ligne pour activer l'interface usb, penser à désactiver l'interface série(din)
//SerialMIDI_Interface<decltype(serial)> midi = {serial, MIDI_BAUD

//};// démarre une interface midi serial au midi baud rate par defaut


 
//  ces lignes midi servent à activer un bouton qui envoit une note midi enlever les // sur ces 5 lignes pour l'activer

// démarrer une touche midi

CD74HC4067 mux1 = {
  A2,       // numéro de broche de l'arduino
  {2, 3, 4, 5} // numéro de pins de l'arduino sur lesquels sont branchés tous les multiplexeurs apellés mux S0, S1, S2
};
Bank<2> bank2 = {8}; // active 2 bank avec 8 adresses par bank
//démarre un multiplexeur pour 8 boutons mute
Bankable::CCButtonLatched <8> buttonmute[] = { //ces lignes déclarent le mux
  {{bank2,BankType::CHANGE_CHANNEL}, mux1.pin(0), {94, CHANNEL_1}},//numéro de bank correspondant/indique que le changement de bank change le canal midi (+8 car on a 8 adresses par bank)/pin sur laquelle le controleur est branché/numéro de cc/numéro de canal midi
  {{bank2,BankType::CHANGE_CHANNEL},mux1.pin(1), {94, CHANNEL_2}},
  {{bank2,BankType::CHANGE_CHANNEL},mux1.pin(2), {94, CHANNEL_3}},
  {{bank2,BankType::CHANGE_CHANNEL},mux1.pin(3), {94, CHANNEL_4}},
  {{bank2,BankType::CHANGE_CHANNEL},mux1.pin(4), {94, CHANNEL_5}},
  {{bank2,BankType::CHANGE_CHANNEL},mux1.pin(5), {94, CHANNEL_6}},
  {{bank2,BankType::CHANGE_CHANNEL},mux1.pin(6), {94, CHANNEL_7}},
  {{bank2,BankType::CHANGE_CHANNEL},mux1.pin(7), {94, CHANNEL_8}},
};

Bank<2> bank1 = {-8}; // 2 banks, 8 addresse per banks

CD74HC4067 mux2 = {// deuxième multiplexeur cette fois si avec 16 entrées
  A0,              // analog pin
  {2, 3, 4, 5}, // numero de pin du mux S0, S1, S2, S3
  // 7, // Optionally, specify the enable pin
};
//Instantiate multiplexer for 16 switch
Bankable::CCPotentiometer fx [] = {
  {{bank1, BankType::CHANGE_ADDRESS},mux2.pin(0), {83, CHANNEL_1}},
  {{bank1, BankType::CHANGE_ADDRESS},mux2.pin(1), {83, CHANNEL_2}},
  {{bank1, BankType::CHANGE_ADDRESS},mux2.pin(2), {83, CHANNEL_3}},
  {{bank1, BankType::CHANGE_ADDRESS},mux2.pin(3), {83, CHANNEL_4}},
  {{bank1, BankType::CHANGE_ADDRESS},mux2.pin(4), {83, CHANNEL_5}},
  {{bank1, BankType::CHANGE_ADDRESS},mux2.pin(5), {83, CHANNEL_6}},
  {{bank1, BankType::CHANGE_ADDRESS},mux2.pin(6), {83, CHANNEL_7}},
  {{bank1, BankType::CHANGE_ADDRESS},mux2.pin(7), {83, CHANNEL_8}},
  {{bank1, BankType::CHANGE_ADDRESS},mux2.pin(8), {82, CHANNEL_1}},
  {{bank1, BankType::CHANGE_ADDRESS},mux2.pin(9), {82, CHANNEL_2}},
  {{bank1, BankType::CHANGE_ADDRESS},mux2.pin(10), {82, CHANNEL_3}},
  {{bank1, BankType::CHANGE_ADDRESS},mux2.pin(11), {82, CHANNEL_4}},
  {{bank1, BankType::CHANGE_ADDRESS},mux2.pin(12), {82, CHANNEL_5}},
  {{bank1, BankType::CHANGE_ADDRESS},mux2.pin(13), {82, CHANNEL_6}},
  {{bank1, BankType::CHANGE_ADDRESS},mux2.pin(14), {82, CHANNEL_7}},
  {{bank1, BankType::CHANGE_ADDRESS},mux2.pin(15), {82, CHANNEL_8}},
};

Bank <2> bank3 = {8}; // 2 banks, 8 addresse per banks


  //Instantiate second multiplexer for 8 potentiometer
CD74HC4067 mux3 = {
  A1
  ,       // Analog input pin
  {2, 3, 4, 5} // Address pins S0, S1, S2};

};
Bankable::CCPotentiometer fader [] = { //ici on déclare les faders avec comme vu plus haut le numéro de CC et le canal
  {{bank3, BankType::CHANGE_CHANNEL}, mux3.pin(0), {7, CHANNEL_1}},
  {{bank3, BankType::CHANGE_CHANNEL}, mux3.pin(1), {7, CHANNEL_2}},
  {{bank3, BankType::CHANGE_CHANNEL}, mux3.pin(2), {7, CHANNEL_3}},
  {{bank3, BankType::CHANGE_CHANNEL}, mux3.pin(3), {7, CHANNEL_4}},
  {{bank3, BankType::CHANGE_CHANNEL}, mux3.pin(4), {7, CHANNEL_5}},
  {{bank3, BankType::CHANGE_CHANNEL}, mux3.pin(5), {7, CHANNEL_6}},
  {{bank3, BankType::CHANGE_CHANNEL}, mux3.pin(6), {7, CHANNEL_7}},
  {{bank3, BankType::CHANGE_CHANNEL}, mux3.pin(7), {7, CHANNEL_8}},

 
  
};


CCAbsoluteEncoder encoder [16] = {
  {{6, 7}, {85, CHANNEL_16},8, 4,},// pins sur lesquels sont branchés les encodeurs/numero cc/canal midi/multiplicateur de vitesse/ nombre de cran par tic de l'encodeur
  {{8, 9}, {86, CHANNEL_16}, 16, 4,},
  {{10, 11}, {87, CHANNEL_16}, 16, 4,},
  {{12, 13}, {88, CHANNEL_16}, 16, 4,},
  {{17, 18}, {89, CHANNEL_16}, 16, 4,},
  {{19, 20}, {90, CHANNEL_16}, 16, 4,},
  {{21, 22}, {91, CHANNEL_16}, 16, 4,},
  {{24, 25}, {92, CHANNEL_16}, 16, 4,},
  /*
  {{26, 27}, {24, CHANNEL_16}, 16, 4,},
  {{28, 29}, {25, CHANNEL_16}, 16, 4,},
  {{30, 31}, {26, CHANNEL_16}, 16, 4,},
  {{32, 33}, {27, CHANNEL_16}, 16, 4,},
  {{34, 35}, {28, CHANNEL_16}, 16, 4,},
  {{36, 37}, {29, CHANNEL_16}, 16, 4,},
  {{38, 39}, {30, CHANNEL_16}, 16, 4,},
  {{A21, A22}, {31, CHANNEL_16}, 16, 4,},
*/
};

using namespace MIDI_Notes;

NoteButton pads[] = {
  {5, {note(C, 2), CHANNEL_1}},
  {6, {note(C, 2), CHANNEL_2}},
  {7, {note(C, 2), CHANNEL_3}},
  {8, {note(C, 2), CHANNEL_4}},
  {9, {note(C, 2), CHANNEL_5}},
  {10, {note(C, 2), CHANNEL_6}},
  {11, {note(C, 2), CHANNEL_7}},
  {12, {note(C, 2), CHANNEL_8}},// Note C4 on MIDI channel 1
};
void setup() {
  Control_Surface.begin(); // initialise la library surface de control

 

}                           
void loop() {
  

  Control_Surface.loop(); // Update the Control Surface

}```
feel free to use it mod it and share it
there is usb midi or serial you ll find easily how to switch!

@benwadub
Copy link
Author

benwadub commented Apr 4, 2020

I can t find how to send midi from usb with the teensy code and receive audio from usb too,
I changed the audio input in audio setup of the code
Ableton Live recognize the teensy as audio device
I included midiusb.h
but can't hear anything from the synth, could you explain all the midi interface in the sketch please?
I thought that the way I did I should send midi to teensy via usb and take the audio from teensy via usb
if you have can show me where I must investigate it would be nice!
(i don t have the teensy audio board for the moment it s why I d like to test via usb only for the moment!)

@troisiemetype
Copy link
Owner

For MIDI in, you have nothing to do, it already works as is. At least for note triggering.
Every step in the audio chain is initialized, so you should hear something.
As you don't have external controls for now, you should comment out the two internal midi (that receive from Mega 1 and Mega 2) handler in setup.

You have to modify the audio_setup to replace I2S out by USB out. And you have to set the USB type to MIDI + audio in the IDE before uploading your program to the board.

If you haven't seen it, there are explanations about how the audio library works, as well as a video tutorial that is worth the time.

Note : the stable version of Teensy loader doesn't include the option for USB audio on Teensy 4.0 yet, as it's under testing. But there is a beta version available (go and check the forum) which has it working.

@benwadub
Copy link
Author

benwadub commented Apr 5, 2020

i m on teensy3.5, I replaced audio output by usb and thought about the ice configuration too
i ll recheck the audio tutorial!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants