2012/10/12 Peter M. Brigham <pmb...@gmail.com>:
> Instead of delving into PlayCommand Agent X (whatever that is, and my 
> ignorance may make this comment useless), could you not just write your own 
> simpler custom play command in LC, to mirror what you get from shakobox, 
> something along the lines of:
>
> local tChannel, tVolume, tNote, tInstrument, tID, tTempo
>
> on mbPlay tInstrument, tTempo, tNotes
>    -- handle default assignments here
>    -- get duration from the tTempo variable
>    repeat for each item tNote in tNotes
>       SunnYmidi.Play tChannel, tDuration, tVolume, tNote
>    end repeat
> end mbPlay
>
> Probably too crude, but you get the idea. Am I out in left field thinking I'm 
> playing soccer?
>  I usually look for an LC-native way of doing things.

Yes Peter, you are right.

Here is the code I posted yesterday on my 3 minutes to emulate Agent X,
which just do what you are saying:

on SBplay instrument, _tempo, notestring
   sunnYmidi.Set 1, "instrument", instrumentID( instrument)
   sunnymidi.HCplay 1, _tempo, notestring
end SBplay

on SBstartNote instrument, pitch, velocity
   sunnYmidi.Set 1, "instrument", instrumentID( instrument)
   sunnYmidi.Play, 1, -1, velocity, pitch
end SBstartNote

on SBstopNote instrument,pitch
   sunnYmidi.Set 1, "instrument", instrumentID( instrument)
   sunnYmidi.Play, 1, 0, 0, pitch
end SBstopNote

private function  instrumentID instrument
   -- assuming the ID is correct
   if instrument is a number then return instrument
   -- custom prop containing on each line:  IDinstrument,InstrumentName
   get the GM_Instruments of this stack
   filter IT with "*," & instrument
   if IT is empty then return 1 -- piano
   return item 1 of IT -- the ID
end instrumentID

With the proof: ( copy-paste this script from Shakobox documentation)

on mouseup
  --    "Nic's Russian Tune (Katyushka)" from "Knit Your Own Yoghurt"
  put "e4q. f#4e g4q. e4e gq f#e ee f#q b3q f#q. ge aq. f#e aq ge f#eeq rq " & \
    "b4q e5q d5q e5e d5e c5q b4e a4e b4q e4q c5q. a4e b4q. g4e a4q
g4ef# 4e e4h " & \
    "g4q. a4e b4q. g4e b4q a4e g4e f#4q a4q a4q. b4e c5q. b4e c5q b4e
a4e g4q rq " & \
    "e5q g5q b4q b4e d5e e5q d5e c5e e5q b4q e5q. c5e e4q. b4e d#5q
e5e f#5e e5h"  \
        into theSong
  sbplay 24,125,theSong
end mouseup


Thierry

_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to