Skip to content
Snippets Groups Projects
Commit 9e19933d authored by dronus's avatar dronus
Browse files

send MIDI CC instead of MIDI Notes

parent 580b44c7
Branches
No related tags found
No related merge requests found
......@@ -4,9 +4,10 @@
"fps": 40,
"shutter_milliseconds":25,
"contrast_limit":3.0,
"threshold": 3,
"bins":14,
"pitch_min":20,
"pitch_step":2
"threshold": 2,
"bins":19,
"removed_top_bins":3,
"pitch_min":0,
"pitch_step":1
}
#!/usr/bin/python3
# SOUNDOFWOOD wood scanner
#
# drives midi notes in respect to the texture of a log of wood moving along under a line scanned by the camera
#
# Developed by Abhilash Nagisetty, Paul Geisler and Prateek Vijan
# import the necessary packages
#from pyimagesearch.tempimage import TempImage
import math
......@@ -27,6 +20,7 @@ import jack
# First 4 bits of status byte:
NOTEON = 0x9
NOTEOFF = 0x8
CC = 0xB
client = jack.Client("Woodsound Scanner")
outport = client.midi_outports.register("output")
......@@ -160,19 +154,24 @@ for f in camera.capture_continuous(rawCapture, format="bgr", use_video_port=True
index=0
index=1
for pixel in np.nditer(histogram[0:-conf['removed_top_bins']]):
last_pixel=last_histogram[index]
if pixel>=threshold and last_pixel<threshold:
packet=((NOTEON <<4), conf["pitch_min"]+index*conf["pitch_step"], 99)
out_queue.append(packet)
pixel_count+=1
if pixel<threshold and last_pixel>=threshold:
packet=((NOTEOFF<<4), conf["pitch_min"]+index*conf["pitch_step"], 99)
out_queue.append(packet)
pixel_count-=1
velocity=pixel-threshold
if velocity>127:
velocity=127
if velocity<=0:
velocity=0
packet=((CC<<4), index, velocity)
out_queue.append(packet)
index+=1
print("Pixels on: "+str(pixel_count)+":"+str(histogram))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment