Jump to content
Sign in to follow this  
Jorvd

Convert OMN to OSC Data (to SuperCollider)

Recommended Posts

Hi everyone,


For the past two days I've been messing around with SuperCollider and OM.
I want to be able to write my score in OMN format and send it via OSC to SuperCollider.
So far I have this in OM:

(defparameter to-sc '(127.0.0.1 57120))
(setf thd1 (create-osc-thread "thread1" to-sc))
(send-osc-data thd1 '( 
                      (12 1/2) (2 1/2) (0 1/2) (3 1/2)
                      (14 1/2) (2 1/2) (0 1/2) (3 1/2)
                      (8 1/2) (2 1/2) (0 1/2) (3 1/2)
                      (7 1/2) (2 1/2) (0 1/2) (3 1/2)
                      ))

And this in SuperCollider

(OSCdef.new(
	\toggle,
	{
		arg msg, time, addr, port;
		[msg, time, addr, port].postln;
		Synth(\synth1, [pitch:msg[1]+60]);
	},
	'/thread1'
);
)
(
SynthDef('synth1', {
    arg pitch=60, amp=0.2, ffreq=15000;
	var linen, env, sig1, sig2;
    linen = Env.linen(0.01, sustainTime:0, releaseTime:1);
    env = EnvGen.kr(linen, doneAction:2);
	sig1 = Mix(VarSaw.ar([pitch.midicps], 0, 0.5));
	sig2 = LPF.ar(sig1, ffreq);
    Out.ar(0, sig2* env * amp);
}).add;
)

And this works great! However I would like to write my OM script in regular OMN format and then convert it to integers, which SuperCollider understands.

I've tried to do this like so:

(setf convert-test '(
                       (q a3 e4 c4 f4)
                       (q e3 b4 a3 c4)))

(setf data (gen-osc-data 16
                         (pitch-to-midi (omn :pitch convert-test))
                         :time (flatten (omn :length convert-test))
                         :min 0
                         :max 127))

However, it seems like "gen-osc-data" really wants to use floating values, adding the Min and Max does seem to convert these values in the range 0-127 but still I end up having the wrong notes:

(setf data (gen-osc-data 16
                         (pitch-to-midi (omn :pitch convert-test))
                         :time '(1/2 1/4 1/12 1/12 1/12)
                         :min 0
                         :max 127))

>> (((0 91 127) 1/2) ((27 127 0) 1/4) ((0 106 127) 1/12) ((0 127 64) 1/12) ((0 91 127) 1/12) ((27 127 0) 1/2) ((0 106 127) 1/4) ((0 127 118) 1/12) ((0 127 118) 1/12) ((0 127 118) 1/12)....

 

Any ideas on a straightforward method to deal with this? I hope my question is understandable, this is by far the most challenging project I've tried in OM, any help would be very appreciated!

NOTE: I know that I can just send MIDI notes to SC however I would like to control my Synth Parameters via OSC and I'm a big fan of consistency, therefor it would be great if the Pitch and Length information also could be converted and send via OSC messages.


Thanks very much in advance!

- Jor

Share this post


Link to post
Share on other sites

Yes but for this project I would love to use native SC language, and not write everything in Lisp. CL-Collider only uses the server side (synths & FX)of SC but not the language side, which has a lot of good stuff as well.
Following up on my previous question:
Is there a way to send multiple messages to one Thread? In SC it's great to be able to filter out messages like so [1], [2]. Wich will get the first and the second message send to a specific thread. Is this possible with the current OSC implementation? I tried sending multiple messages with send-osc-data but I can't figure out how to format the messages in that case.
 

Share this post


Link to post
Share on other sites

What would be the output (values) in your example, what you are looking for.

Is this what you are looking for: (<midi value> <time>)

(setf data (gen-osc-data 8
                         (flatten (pitch-to-midi (omn :pitch convert-test)))
                         :time '(1/2 1/4 1/12 1/12 1/12)
                         :min 1
                         :max 127))

=> ((34 1/2) (81 1/4) (54 1/12) (87 1/12) (1 1/12) (127 1/2) (34 1/4)
    (54 1/12) (54 1/12) (54 1/12) (54 1/2) (54 1/4) (54 1/12) (54 1/12)
    (54 1/12) (54 1/2) (54 1/4) (54 1/12) (54 1/12) (54 1/12) (54 1/2)
    (54 1/4) (54 1/12) (54 1/12) (54 1/12) (54 1/2) (54 1/4) (54 1/12)
    (54 1/12) (54 1/12) (54 1/2) (54 1/4) (54 1/12) (54 1/12) (54 1/12)
    (54 1/2) (54 1/4) (54 1/12) (54 1/12) (54 1/12))

 

Or I could add an extra keyword to allow send given values:

(setf midi-values '(57 64 60 65 52 71 57 60))
(setf data (gen-osc-data 8 midi-values
                         :time '(1/2 1/4 1/12 1/12 1/12)
                         :values :midi
                         :loop t))
=> ((57 1/2) (64 1/4) (60 1/12) (65 1/12) (52 1/12) (71 1/2) (57 1/4)
    (60 1/12) (57 1/12) (64 1/12) (60 1/2) (65 1/4) (52 1/12) (71 1/12)
    (57 1/12) (60 1/2) (57 1/4) (64 1/12) (60 1/12) (65 1/12) (52 1/2)
    (71 1/4) (57 1/12) (60 1/12) (57 1/12) (64 1/2) (60 1/4) (65 1/12)
    (52 1/12) (71 1/12) (57 1/2) (60 1/4) (57 1/12) (64 1/12) (60 1/12)
    (65 1/2) (52 1/4) (71 1/12) (57 1/12) (60 1/12))

 

Share this post


Link to post
Share on other sites

Those examples are very helpful, thank you!
Right now my output (SC input) is this:

[ [ /thread1, 3, 1 ], 666.1542108, a NetAddr(127.0.0.1, 57796), 57120 ]

Which I believe is, [[ ThreadName, Note Number, Gate], Time, Address, Port] 

Ideally what I want to be able to do is to send the Pitch/Gate and some other values (Filter Modulation, Pitchbend, etc.) to the same thread.

So for example [[/thread1, NoteNumber, 1, val1, val2, val3] etc.]]


In a perfect world they would also have independent Time values, they just should end up at the same Thread in SC.
Probably this is very simple, I would just need to combine the lists in OM before sending it with send-osc-data , I just can't really figure out how to do this.
Hope the example is clear enough 🙂

Thanks again!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Similar Topics

    • By hujairi
      Hello,
       
      I am trying to find different ways of importing partials/frames data into Opusmodus. I am currently trying to use spectral analysis to analyzes certain music/audio phenomena I haven't really seen analyzed before to adapt into my own composition process. The sounds are generally archival or things I have synthesized on the computer through software myself (in .wav format), and are usually between 1 - 5 seconds in length. Is this a good length of time to analyze the spectral data of sounds? 
       
      I just wanted to understand the following information about spectral tools within Opusmodus. I really would appreciate it if anyone could help me out.
       
      1. Is it only Spear that we can use for spectral analysis? Is something like Audiosculpt also useable?
       
      2. Looking at Spear, when we explore the data, which of the following export formats do we use: 1. Text - Resampled Frames, 2. Text - Partials, 3. SDIF 1 TRC - Resampled Frames, 4. SDIF 1 TRC - Exact Interpolated, or 5. SDIF RBEP?
       
      3. Once I have the data in the correct format, I think I want to create a library of the datasets I important so that I can reinterpret them in the future. If I want to use the "get-tuning" function, for example, and then mapping it across certain instruments within my planned orchestration. What would be an effective way of doing this?
       
      One of my main challenges is finding a way to keep all my data organized every time I want to use Opusmodus for a new project. I still find myself using Opusmodus in little blocks as I compose, and I hope to eventually get to the point in which I can compose entire pieces using only Opusmodus. 
       
      I really appreciate your help.
    • By Andy
      I have converted many of my scores made in Notion to music xml in order to display them in the Assistant..which is very nice indeed.
       
      I'm wondering if I can convert those xml scores to an Opusmodus score direct or do I have to re-import them as midi? I see I can go the other way..xml to Notion, but cannot find how to go this way or if it's possible.
       
      Thanks
    • By hujairi
      Hello,
       
      I am working on a sound installation for two voices (using Soniccouture's Geosonics VST plugin and a vibraphone VST plugin running through a computer). The source of the data is taken live from the internet and is actually API weather data from a city in South Korea. The piece will play for 2 hours every night between early December and early March. 
       
      The trouble I am having is how to transform the different fragments of weather data into data I could use within Opusmodus. Here's the type of data that I get according to each parameter (the options are either floating points, integers, or T/F). All of this is on my computer as OSC signals.
       
      1. wind direction: floating points, between 0 and 360.0
      2. wind speed: floating points
      3. sky code (i.e., clear, cloudy, rain, snow): integers
      4. precipitation type: integers (codes for each type of precipitation) 
      5. temperature (celcius): floating points
      6. temperature minimum: floating points
      7. temperature maximum: floating points
      8. humidity: floating points (representing percentage, example 31.1% = 31.1)
      9. pressure: float points (time of writing this, pressure of the place I was looking at was 1008.9 while here in Seoul, the pressure is 922.8)
      10. lightning: True or False option
       
       
      My questions are: 
      - How can I receive OSC signals within Opusmodus? Is there a function that allows me to do this?
      - I've never used the Live Coding function in Opusmodus although I've got a basic knowledge of live coding within other environments such as SuperCollider, Sonic Pi, and Max/MSP. I would like to have the data control the live coding functions modulate the music as it plays live. 
       
      I would really, really appreciate any advice I may get on this. I don't mean to have the community here 'do everything' for me, but I'd appreciate any direction I may get in successfully accomplishing this project.  
       
      Thanks very much and sorry for any trouble,
      Hasan
×
×
  • Create New...