[CM] recording MIDI input

Landspeedrecord landspeedrecord at gmail.com
Fri Dec 16 20:09:26 PST 2011


Whoops...

I figured out 1 thing I was doing wrong... this start and stop code
specified mm:on which was a mistake, it should be this:

;to begin recording:
begin
 variable incoming-midi = {}
 variable first-note-time = #f
 send("mp:receive", midi-recorder)
end

;to stop the recording
send("mp:receive", #f)

On Fri, Dec 16, 2011 at 10:49 PM, Landspeedrecord <landspeedrecord at gmail.com
> wrote:

> Hi,
>
> I think I have a bit of midi-recording code working in SAL... But the
> values I am getting for the time seem wrong, in particular the very first
> time recorded is a really weird incredibly small number instead of just
> being 0.
>
> Any help is appreciated, or if there is cleaner or better way that would
> be even better.  Here is my code so far:
>
> variable incoming-midi = {}
> variable first-note-time = #f
>
> function midi-recorder (mididata)
>   begin
>     with current = now(),
>          opcode = first(mididata),
>          channel = second(mididata),
>          keynum = third(mididata),
>          velocity = fourth(mididata)
>     if (! first-note-time)
>       set first-note-time = current, current = 0
>     else
>       set current = (current - first-note-time)
>     set incoming-midi &= list(current, opcode, channel, keynum, velocity)
>     end
>   end
> end
>
>
> ;to begin recording:
> begin
>  variable incoming-midi = {}
>  variable first-note-time = #f
>  send("mp:receive", mm:on, midi-recorder)
> end
>
> ;to stop the recording
> send("mp:receive", mm:on, #f)
>
> And here is an example of what got recorded into the global variable
> ("incoming-midi") after a test run using a midi file created from the reich
> tutorial example:
> {{4.3472355173435e-005 9 0 64 63} {0.86995516913521 9 0 66 63}
> {0.87000498120688 9 0 66 63} {0.87003215142977 9 0 71 63} {0.87007109541264
> 9 0 71 63} {0.87009781279812 9 0 73 63} {0.87015079472985 9 0 73 63}
> {0.87018068197176 9 0 74 63} {0.87021781461044 9 0 74 63} {0.8702449848297
> 9 0 66 63} {0.87029162704494 9 0 66 63} {0.8703192501016 9 0 64 63}
> {0.87035592990287 9 0 64 63} {0.87038445863436 9 0 73 63} {0.87042113843199
> 9 0 73 63} {0.87044740298006 9 0 71 63} {0.87048453561692 9 0 71 63}
> {0.87051080016317 9 0 66 63} {0.87054793280004 9 0 66 63} {1.2680038943981
> 9 0 74 63} {1.268050989449 9 0 74 63} {1.2680808766945 9 0 73 63}
> {1.2681343114618 9 0 73 63} {1.2682103880816 9 0 64 63} {1.2682579359698 9
> 0 64 63} {1.2682783136352 9 0 66 63} {1.2683104650641 9 0 66 63}
> {1.2683322012417 9 0 71 63} {1.2683638998333 9 0 71 63} {1.2683860888465 9
> 0 73 63} {1.2684182402754 9 0 73 63} {1.268439976453 9 0 74 63}
> {1.2684725807194 9 0 74 63} {1.2684943168952 9 0 66 63} {1.2685260154867 9
> 0 66 63} {1.2685477516661 9 0 64 63} {1.6363184349957 9 0 64 63}
> {1.6363383598236 9 0 73 63} {1.6363859077119 9 0 73 63} {1.6364185119783 9
> 0 71 63} {1.6366259113347 9 0 71 63} {1.6366530815576 9 0 66 63}
> {1.6367001766066 9 0 66 63} {1.6367309695252 9 0 74 63} {1.6367776117386 9
> 0 74 63} {1.6368097631675 9 0 73 63} {1.8736562061313 9 0 73 63}
> {1.8736820178437 9 0 64 63} {1.8737300185676 9 0 64 63} {1.8737617171573 9
> 0 66 63} {1.8738119820682 9 0 66 63} {1.8738445863346 9 0 71 63}
> {1.8738894172002 9 0 71 63} {2.0213331521991 9 0 73 63} {2.0213829642726 9
> 0 73 63} {2.0214101344936 9 0 74 63} {2.021451795501 9 0 74 63}
> {2.1085146945625 9 0 66 63} {2.1085577140784 9 0 66 63} {2.1509378254777 9
> 0 64 63} {2.1825856994074 9 0 64 63} {2.2213720961827 9 0 73 63}
> {2.2673853190245 9 0 73 63} {2.3044518407823 9 0 71 63} {2.3515957976742 9
> 0 71 63} {2.387618077255 9 0 66 63} {2.4386953765352 9 0 66 63}
> {2.4715867409323 9 0 74 63} {2.5225698501126 9 0 74 63} {2.5556355567642 9
> 0 73 63} {2.6074994339542 9 0 73 63} {2.6385549970582 9 0 64 63}
> {2.6925666802526 9 0 64 63} {2.7229207988057 9 0 66 63} {2.7776004166099 9
> 0 66 63} {2.8049295838427 9 0 71 63} {2.8623878096278 9 0 71 63}
> {2.8909908074093 9 0 73 63} {2.9475401892869 9 0 73 63} {2.9730715935348 9
> 0 74 63} {3.0325182266915 9 0 74 63} {3.0595693519899 9 0 66 63}
> {3.1184879771772 9 0 66 63} {3.1458429561208 9 0 64 63} {3.2025567178371 9
> 0 64 63} {3.2284268441799 9 0 73 63} {3.287489924378 9 0 73 63}
> {3.3141271566365 9 0 71 63} {3.3714735316771 9 0 71 63} {3.3980025358869 9
> 0 66 63} {3.4577444187835 9 0 66 63} {3.484926413983 9 0 74 63}
> {3.5425426798902 9 0 74 63} {3.5707888420966 9 0 73 63} {3.6366508173705 9
> 0 73 63} {3.654834035231 9 0 64 63} {3.712540415705 9 0 64 63}
> {3.739727844948 9 0 66 63} {3.7975338495671 9 0 66 63} {3.8253167594994 9 0
> 71 63} {3.882491056469 9 0 71 63} {3.909039532673 9 0 73 63}
> {3.9675098492062 9 0 73 63} {3.9950120001813 9 0 74 63} {4.051609835622 9 0
> 74 63} {4.0781465380605 9 0 66 63} {4.1374609428076 9 0 66 63}
> {4.1554195535045 9 0 64 63} {4.2225367930096 9 0 64 63} {4.2505728388369 9
> 0 73 63} {4.3077548340352 9 0 73 63} {4.3354114024369 9 0 71 63}
> {4.3916216093821 9 0 66 63} {4.8541221754294 9 0 71 63}}
>
>
> Thanks,
> Charles
>
>
>
> On Tue, Dec 13, 2011 at 10:57 AM, Heinrich Taube <taube at illinois.edu>wrote:
>
>> im sorry its taking so long to get to this.  you are correct you use a
>> hook and push data onto a "recoding list" .
>> if you cant get this going i'll send a demo out early next week once the
>> end-of-semester madness is over!
>> --rick
>>
>>
>>
>> On Dec 6, 2011, at 9:17 PM, Landspeedrecord wrote:
>>
>>  Hi,
>>>
>>> I have a newbie question...
>>>
>>> I am looking to record midi input to grace...  I am guessing by the
>>> "input hooks" sal tutorial that this is done by defining a midi receiver
>>> (call it "myrecorder") and then running it with a send("mp:receive",
>>> myrecorder) command.  I was hoping someone already had some code created to
>>> do it... If not, having "myrecorder" shove the midi note information into a
>>> list isn't difficult and I suppose each note on or note off can be paired
>>> with the output of a call to the now() function... Is there a better method?
>>>
>>> In related matters, is there a way to exchange midi tempo and other
>>> information between a DAW and Grace (besides using OSC)?  I am on a PC for
>>> what it is worth.
>>>
>>> Thanks,
>>> Charles
>>> ______________________________**_________________
>>> Cmdist mailing list
>>> Cmdist at ccrma.stanford.edu
>>> http://ccrma-mail.stanford.**edu/mailman/listinfo/cmdist<http://ccrma-mail.stanford.edu/mailman/listinfo/cmdist>
>>>
>>
>>
>
>
> --
>
> Reality <http://en.wikipedia.org/wiki/Reality> is the original Rorschach.
> Verily! So much for all that.
> —Malaclypse the Younger, *Principia Discordia*, Pages 00049–00050
>
>


-- 

Reality <http://en.wikipedia.org/wiki/Reality> is the original Rorschach.
Verily! So much for all that.
—Malaclypse the Younger, *Principia Discordia*, Pages 00049–00050
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://ccrma-mail.stanford.edu/pipermail/cmdist/attachments/20111216/a0d8ac04/attachment-0001.html 


More information about the Cmdist mailing list