Login | Register 
FEATURES
APPLICATIONS
DOWNLOADS
EDUCATION
BLOG
WIKI
FORUM
STORE

How to send MIDI Notes from Table DAT ?

Still a little green? Ask your beginner's questions here

How to send MIDI Notes from Table DAT ?

Postby circat » Thu Mar 14, 2019 5:49 am

Hey lovely human beings ,

sorry for that newbie question but i don`t get it :oops: :

i want to send midi notes depending on a Table DAT.I searched the forum but couldn`t find a solution.

for example, the ROW is the note pitch and first column(0-1) is note on/off.

if value changes from 0 to 1 : note ON
if value changes from 1 to 0 : note OFF
Note Pitch = Row number.

i tried to Chopto the Table DAT and select the row/colums but now i`m stucked with a Dat Execute. :lol:


def onValueChange(channel, sampleIndex, val, prev):
midi = op('midiout1')
source = op('select3')
midi.sendNoteOn(1, 64)
return

the .toe is attached...

thank you guys,
circat
Attachments
pixeltonote_01.toe
(5.75 KiB) Downloaded 56 times
circat
 
Posts: 12
Joined: Fri Nov 02, 2018 5:45 pm
Location: Berlin

Re: How to send MIDI Notes from Table DAT ?

Postby circat » Thu Mar 14, 2019 8:41 pm

Update : i managed the Chop execute to send midi notes from the table DAT.still buggy,
i still need :
1. an array
2. note OFF on value 0
3. decrease maximum simultaneous notes

if somebody has a hint.... :) thank you.

This is my CHOP Execute :

Code: Select all
midi = op('midiout1')
source = op('select5')


def onValueChange(channel, sampleIndex, val, prev):
   
   if op('select5')[5,1] == 1:
      midi.sendNoteOn(1, 16,100)

   if op('select5')[7,1] == 1:
      midi.sendNoteOn(1, 17,100)

   if op('select5')[9,1] == 1:
      midi.sendNoteOn(1, 18,100)

   if op('select5')[11,1] == 1:
      midi.sendNoteOn(1, 19,100)

   if op('select5')[13,1] == 1:
      midi.sendNoteOn(1, 20,100)

   if op('select5')[15,1] == 1:
      midi.sendNoteOn(1, 21,100)
      
   if op('select5')[17,1] == 1:
      midi.sendNoteOn(1, 23,100)
      
   if op('select5')[19,1] == 1:
      midi.sendNoteOn(1, 25,100)
      
   if op('select5')[21,1] == 1:
      midi.sendNoteOn(1, 27,100)
   
   if op('select5')[23,1] == 1:
      midi.sendNoteOn(1, 28,100)
      
   if op('select5')[25,1] == 1:
      midi.sendNoteOn(1, 30,100)
      
   if op('select5')[27,1] == 1:
      midi.sendNoteOn(1, 32,100)
      
   if op('select5')[29,1] == 1:
      midi.sendNoteOn(1, 56,100)
   
   if op('select5')[31,1] == 1:
      midi.sendNoteOn(1, 58,100)
         
   if op('select5')[33,1] == 1:
      midi.sendNoteOn(1, 60,100)
   
   if op('select5')[35,1] == 1:
      midi.sendNoteOn(1, 61,100)
      
   if op('select5')[37,1] == 1:
      midi.sendNoteOn(1, 62,100)
      
   if op('select5')[39,1] == 1:
      midi.sendNoteOn(1, 63,100)
   
   if op('select5')[41,1] == 1:
      midi.sendNoteOn(1, 64,100)
      
   if op('select5')[43,1] == 1:
      midi.sendNoteOn(1, 65,100)
      
   if op('select5')[45,1] == 1:
      midi.sendNoteOn(1, 66,100)
   if op('select5')[47,1] == 1:
      midi.sendNoteOn(1, 67,100)
   if op('select5')[49,1] == 1:
      midi.sendNoteOn(1, 68,100)
   if op('select5')[51,1] == 1:
      midi.sendNoteOn(1, 69,100)
   if op('select5')[53,1] == 1:
      midi.sendNoteOn(1, 70,100)
   if op('select5')[55,1] == 1:
      midi.sendNoteOn(1, 71,100)
   if op('select5')[56,1] == 1:
      midi.sendNoteOn(1, 72,100)
   if op('select5')[57,1] == 1:
      midi.sendNoteOn(1, 73,100)
   if op('select5')[59,1] == 1:
      midi.sendNoteOn(1, 74,100)
   if op('select5')[60,1] == 1:
      midi.sendNoteOn(1, 75,100)
   
   return
   
circat
 
Posts: 12
Joined: Fri Nov 02, 2018 5:45 pm
Location: Berlin

Re: How to send MIDI Notes from Table DAT ?

Postby FaustoB » Wed Mar 20, 2019 5:24 am

Hi there,

I just had a look at the .toe file you have attached...

I see that from the title of this topic you are asking how to send MIDI notes from a Table DAT, but looking at your .toe file, it looks to me that you want to be able to control a circle on the screen using your mouse, and then having this circle to trigger MIDI notes on and off... is that correct?
If that's the case, I think that you should rethink your network, as it looks a little bit over complicated, and very hard to debug.

Regarding the Chop Execute code you have provided in your second post, I am no expert here, but what I can tell you is that it doesn't seem a very effective solution.
In my experience, a code that long, with that many if statements, is rarely a good sign that things are moving in the right direction.

I hope I don't come across as too harsh with my comments, but in fact, I'm happy to try to give you a hand if I can.

In order to do so, it's probably helpful to understand, what's the purpose of your network? what are you trying to achieve?
FaustoB
 
Posts: 64
Joined: Mon Jan 08, 2018 8:33 am
Location: Sydney, NSW

Re: How to send MIDI Notes from Table DAT ?

Postby circat » Thu Mar 21, 2019 6:35 am

Hey ,

sorry for the confusing toe file and thanks for the reply.
you got confused from the mouse in,it was only for testing the pixel movement ;)

What i try :

Get light values of night shots (i.e train night view ) or other movie files and for
all the selected rows or columns ( if pixel over theshhold ,table value ==1 )
send a MIDI note ( to ableton ) with pitch value depending on the row or column.

the midi send works a little bit...
i still need :

1. an MIDI Note array ( row 0-60 to note 10-70 )
2. note OFF on value 0 OR on long value 1 ( if a light is longer the notes are repeating,i have to get rid of the repeating notes,like "if 1 is longer avaiable than 10 frames,switch to note of...
3. decrease maximum simultaneous notes : if there is to much light at once,i get to much midi notes..

thanks :)
circat
 
Posts: 12
Joined: Fri Nov 02, 2018 5:45 pm
Location: Berlin

Re: How to send MIDI Notes from Table DAT ?

Postby FaustoB » Fri Mar 22, 2019 11:44 pm

Ok,

I think you need to break down your code, divide it in chunks, and attack/explore/clarify one section at the time.

1# how to read pixel values of an image
2# how to manipulate these values
3# how to output MIDI messages

I think that you should look up the documentation and examples on Topto CHOP, Shuffle CHOP, Math CHOP, Select CHOP, pattern matching and Midi out CHOP.

If you really want to go down the route of DATs, look up the Operator Snippets, and make little tests/exercises to familiarise on how to append rows, delete rows, clear a table, select specific rows/columns etc...

If you are on Mac, I recommend downloading an app called MIDI Monitor to help you out checking what MIDI messages you are sending out. I'd imagine that in Windows there might be an equivalent free app.

Now, looking at the file you have uploaded, I think you are sort of heading in the right direction until that topto CHOP. Past that point things get very confusing.

You can think about your incoming image to be a sort of array, made of rows, columns, and the value of each pixel represent the content of that array.
With a topto CHOP you can read and select the entire image, or a specific section of the image, or a specific row/column. Decide which one is the option that works best for what you are trying to do.

As a starting point, a black pixel could mean a note off (velocity=0), and a pixel with a colour could be intended as note on, and the pixel value could be used as velocity.
Maybe you could use a math CHOP to average R,G,B values, come up with one 0-1 value, and then range it to integer 0-127, which then becomes the velocity of your note.

Personally I don't see the need of getting a TOP image into a topto CHOP, and then "translate it" into a DAT (and then back to a CHOP again before sending to the midi out CHOP).
I think that what you are trying to do could be achieved without any DATs at all.

another thing that I have spotted is that I am not sure that your midi out CHOP is sending the correct message.
I think that in order to send a MIDI note you need to rename your channel to be something like ch1n64, where ch1 stands for the MIDI channel you are sending your information, and n stands for the MIDI note number. The value of this channel will represent the velocity.

In terms of MIDI I tend to prefer working with integers 0-127, but it looks like in TD you can receive and normalise values 0-1.

Lastly, when asking for help in a forum and uploading a file, I feel confident to say that it is good practise to tidy up your network, getting rid of any "dead" or irrelevant branches, and ideally leaving some comments here and there in the network to help readability. This will help greatly with debugging and will encourage more people to help you out.

I hope that any of the above is helpful to get you going,

cheers!
FaustoB
 
Posts: 64
Joined: Mon Jan 08, 2018 8:33 am
Location: Sydney, NSW

Re: How to send MIDI Notes from Table DAT ?

Postby circat » Tue Mar 26, 2019 12:20 pm

Hey Fausto ,

thank you so much for your help.

after some tests with your suggestions i ended with this code and it works fine exept there are to much midi notes if there`s to much light in the video and i dont know how to "reduce" the played notes...tried everything now...no idea :|

and i tried everything but could not get it to work without a table :D
but it works fine....

Code: Select all
#      
#            OSC Pixel to Midi
#   takes the number of rows in a table DAT and converts em to MIDI notes.
#
#   Table DAT comes from a Videofile,downsized to : 80x127pixels
#   Video--Rez--TOP to--Math--Chopto--Select Col (for note on of) :
#   Math to 127 ( Midi velocity value)
#   source : number of table Rows
#   arrayMidi : an array of X numbers depending on table rows
 

source = int(op('select12').numRows) # get number of  rows in the table as int
arrayMidi = [source] # number = nuberof Rows in the Table.
def onValueChange(channel, sampleIndex, val, prev):
   
   for x in range(0,source):
      if op('select12')[x,0] > 20:
         velocity = op('select12')[x,0]
         op('../AbletonSync/abletonMIDI1').SendMIDI('note', x, velocity-20)
   return



circat
 
Posts: 12
Joined: Fri Nov 02, 2018 5:45 pm
Location: Berlin

Re: How to send MIDI Notes from Table DAT ?

Postby FaustoB » Wed Mar 27, 2019 1:19 am

Hard to say without seeing your network,

but perhaps one way of reducing the amount of MIDI notes you want your network to output, could be to dynamically reduce the amount of rows you are selecting in your Select DAT?

If you have your table, with values scaled 0-127, perhaps you could sum these values up, and recalculate the amount of selected rows accordingly?

a low number (dark image) will output many MIDI notes, where an high number (bright image) will output less MIDI notes. Is that what you have in mind?

Thanks for sharing your code. One thing I don't understand is
if op('select12')[x,0] > 20:
what's that > 20 for?

if you are ok to share your network I could have a look and try to be more precise with my help.
FaustoB
 
Posts: 64
Joined: Mon Jan 08, 2018 8:33 am
Location: Sydney, NSW

Re: How to send MIDI Notes from Table DAT ?

Postby circat » Wed Jul 10, 2019 11:09 am

Hey Fausto ,
the > 20 was a kind of threshhold...its not longer in the code.
thank you !

i started another discussion about htis technique here :
https://www.derivative.ca/Forum/viewtopic.php?f=4&t=19625

greetz
circat
 
Posts: 12
Joined: Fri Nov 02, 2018 5:45 pm
Location: Berlin


Return to Beginners

Who is online

Users browsing this forum: barakooda and 10 guests