[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Denemo-devel] Scheme question
From: |
Richard Shann |
Subject: |
Re: [Denemo-devel] Scheme question |
Date: |
Mon, 10 Nov 2014 11:15:29 +0000 |
While looking up that procedure ash it occurred to me I should really
implement the extension to d-PutMidi to take a list.
I've done this now so
(let* ((midi (d-GetMidi #f))
(command (list-ref midi 0))
(note (list-ref midi 1))
(velocity (list-ref midi 2)))
(disp command note velocity)
(d-PutMidi (list command note velocity)))
should do just as well and much simpler.
Richard
On Sun, 2014-11-09 at 21:00 +0100, Andreas Schneider wrote:
> Thank you for your help. A similar code works. My input filter is now as
> follows:
>
> ;;; Master keyboard filter
> (let ((midi "")
> (command 0)
> (bank 0)
> (note 0)
> (velocity 0)
> (midivalue 0)
> (keyboardactive 1)
> (isstop 0)
> (loop 0))
> (d-InputFilterNames (_ "Master Keyboard MIDI Filter"))
> (d-SetMidiCapture #t)
> (set! loop (lambda ()
> (begin
> (set! midi (d-GetMidi #f))
> (set! command (bit-extract (list-ref midi 0) 4 8))
> (set! bank (bit-extract(list-ref midi 0) 0 4))
> (set! note (list-ref midi 1))
> (set! velocity (list-ref midi 2))
> (disp "command " command ", bank " bank ", note " note ",
> velocity "
> velocity)
> (set! midivalue (+ (ash velocity 16) (ash note 8) (ash command
> 4)))
> (disp "midi value " midivalue)
> (if (and (= command #x9)(= bank 0)) ; NoteOn message on bank 0
> (begin
> (if keyboardactive (d-PutMidi midivalue))
> ))
> (if (and (= command #x9)(= bank 1)) ; NoteOn message on bank 1
> ->
> trigger pads
> (begin
> (disp "trigger pad " note)
> (case note
> ((36)(d-Set0))
> ((37)(d-Set1))
> ((38)(d-Set2))
> ((39)(d-Set3))
> ((43)(d-Set4))
> ((40)(d-SetBreve))
> )
> ))
> (if (= command #x0B) ; ControlChange message
> (begin
> (case note
> ((119)(set! keyboardactive (not
> keyboardactive))) ; record button
> ((118)(d-DenemoPlayCursorToEnd)) ; play button
> ((117)(d-Stop)) ; stop button
> ((115)(d-MoveToMeasureLeft)) ; rewind button
> ((116)(d-MoveToMeasureRight)) ; forward button
> ((114)(set! isstop 1)) ; loop button
> (else (if keyboardactive (d-PutMidi midivalue)))
> )
> ))
> (if (or (= command 0) (= isstop 1))
> (display "Filter stopping")
> (loop)))))
> (loop))
> (d-SetMidiCapture #f)
>
>
> Andreas
>
>
> Am 09.11.2014 um 19:04 schrieb Richard Shann:
> > On Sun, 2014-11-09 at 18:07 +0100, Andreas Schneider wrote:
> >> How can I convert the byte list from (d-GetMidi #f) to something that I
> >> can issue to d-PutMidi? I was not able to come up with something usable.
> >
> > (let* ((midi (d-GetMidi #f))
> > (value #f)
> > (command (list-ref midi 0))
> > (note (list-ref midi 1))
> > (velocity (list-ref midi 2)))
> > (set! value (+ (ash velocity 16) (ash note 8) command))
> > (d-PutMidi value))
> >
> > I think the values required in d-PutMidi are in the opposite to expected
> > order (packed inside the integer).
> > It would be good to have a wrapper that takes the three numbers and
> > executes d-PutMidi after doing the (set! value (+ (ash velocity 16) (ash
> > note 8) command)) step, thus hiding the poor design of d-PutMidi (if I'm
> > right about the order of the bytes).
> >
> > Richard
>
>
> _______________________________________________
> Denemo-devel mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/denemo-devel