Jump to content
Sign in to follow this  
AM

import pitches/chords from midi-file?

Recommended Posts

dear all

 

is there a quick way to import (or filter) only pitches and chords from a midi-file? if i only use these (nothing else from midi/xml)

 

thanx for a hint

andré

Share this post


Link to post
Share on other sites

Not directly. First you need to import the midi file to score and then extract the pitches with OMN function.

I like the idea, maybe we will add this functionality in the future.

Share this post


Link to post
Share on other sites

oh, this was simple 🙂 here is a small program, it works...

 

(defun get-pitch-from-midi (midipath)
  (loop for i in (flatten (compile-score
                           (midi-to-score midipath)
                           :output :score))
    when (or (chordp i)
             (pitchp i))
    collect i))



(get-pitch-from-midi "path/filename")

 

also with length?!

 

(defun get-length-from-midi (midipath)
  (loop for i in (flatten (compile-score
                           (midi-to-score midipath)
                           :output :score))
    when (and (lengthp i)
              (not (integerp i)))
    collect i))


(get-length-from-midi "path/filename")

 

but will not work with more then one voice / its not necessary for MY needs, so i coded only this simple solution - perhaps janusz will do it?

Share this post


Link to post
Share on other sites

What you are doing Andre is quite bad and unsafe.

I made already a function for it and it will be part of the next release:

(setf 000504b "~/Opusmodus/Media/MIDI/Bach/Chorals/000504b_")

(midi-to-omn 000504b :instrument 1)
=> ((-e g4 ff e. b4 s c5 e d5 f4 ab4 g4) (q e4 -s e4 g4 c4 e f4 ab4 ab4 f4)
    (e db4 db4 - c4 bb4 bb4 db5 c5) (e ab4 ab4 -s c4 f4 g4 e ab4 f4 e. b4 s c5)
    (q d5 -e g4 c5 a4 e. gb4 s g4) (e g4 d4 -h -e bb4)
    (e. bb4 s f4 e e g4 ab4 f4 d5 f4) (e eb4 c4 - c4 bb4 s c5 db5 -e c5)
    (q a4 -e bb4 bb4 g4 eb4 g4) (q ab4 -e eb4 s db5 bb4 e c5 - eb4)
    (e eb4 bb3 -q. e g4 bb4 eb4) (e ab4 -s f4 e d5 f4 q eb4 -e c4)
    (e. g4 s a4 bb4 bb4 bb4 c5 q db5 -e c5) (e a4 a4 c5 f4 ab4 ab4 b3 d4)
    (e f4 f4 - d4 g4 c4 e. b4 s c5) (e c5 g4))

(midi-to-omn 000504b :type :pitch :instrument 2)
=> ((c5 c5 d5) (eb5 f5 g5) (g5) (g5 f5 eb5 eb5) (d5) (d5) (eb5 f5 g5 g5)
    (f5 g5 g5) (eb5 f5 g5 g5) (f5 eb5) (g5) (bb5 g5 g5 g5) (f5 f5 f5)
    (g5 f5 eb5 f5) (d5 c5))

(midi-to-omn 000504b :type :length :instrument 2)
=> ((-1) (-1/4 1/4 1/4 1/4) (1/4 1/4 1/2) (-3/4 1/4) (1/4 1/4 1/4 1/4) (1/2 -1/2)
    (-3/4 1/4) (1/4 1/4 1/4 1/4) (1/2 1/4 1/4) (1/4 1/4 1/4 1/4) (1/2 1/4 -1/4)
    (-3/4 1/4) (1/4 1/4 1/4 1/4) (1/2 1/4 1/4) (1/4 1/4 1/4 1/4) (1/2 1/2))

(midi-to-omn 000504b :type :pitch)
=> (((g4 b4 c5 d5 f4 ab4 g4) (e4 e4 g4 c4 f4 ab4 ab4 f4)
     (db4 db4 c4 bb4 bb4 db5 c5) (ab4 ab4 c4 f4 g4 ab4 f4 b4 c5)
     (d5 g4 c5 a4 gb4 g4) (g4 d4 bb4) (bb4 f4 f4 g4 ab4 f4 d5 f4)
     (eb4 c4 c4 bb4 c5 db5 c5) (a4 bb4 bb4 g4 eb4 g4) (ab4 eb4 db5 bb4 c5 eb4)
     (eb4 bb3 g4 bb4 eb4) (ab4 f4 d5 f4 eb4 c4) (g4 a4 bb4 bb4 bb4 c5 db5 c5)
     (a4 a4 c5 f4 ab4 ab4 b3 d4) (f4 f4 d4 g4 c4 b4 c5) (c5 g4))
    ((c5 c5 d5) (eb5 f5 g5) (g5) (g5 f5 eb5 eb5) (d5) (d5) (eb5 f5 g5 g5)
     (f5 g5 g5) (eb5 f5 g5 g5) (f5 eb5) (g5) (bb5 g5 g5 g5) (f5 f5 f5)
     (g5 f5 eb5 f5) (d5 c5))
    ((b2) (bb2 ab2 f2) (g2 ab2 e2) (d2) (b2 c3) (d3 g2) (d3 b2) (c3 ab3 e3)
     (eb3 d3 db3) (c3 b2 bb2 a2) (bb2 eb2) (b2 c3) (db3 e2) (eb2 d2) (b2 c3 ab2)
     (gb2 g2 c2)))

(midi-to-omn 000504b)
=> (((-e g4 ff e. b4 s c5 e d5 f4 ab4 g4) (q e4 -s e4 g4 c4 e f4 ab4 ab4 f4)
     (e db4 db4 - c4 bb4 bb4 db5 c5) (e ab4 ab4 -s c4 f4 g4 e ab4 f4 e. b4 s c5)
     (q d5 -e g4 c5 a4 e. gb4 s g4) (e g4 d4 -h -e bb4)
     (e. bb4 s f4 e e g4 ab4 f4 d5 f4) (e eb4 c4 - c4 bb4 s c5 db5 -e c5)
     (q a4 -e bb4 bb4 g4 eb4 g4) (q ab4 -e eb4 s db5 bb4 e c5 - eb4)
     (e eb4 bb3 -q. e g4 bb4 eb4) (e ab4 -s f4 e d5 f4 q eb4 -e c4)
     (e. g4 s a4 bb4 bb4 bb4 c5 q db5 -e c5) (e a4 a4 c5 f4 ab4 ab4 b3 d4)
     (e f4 f4 - d4 g4 c4 e. b4 s c5) (e c5 g4))
    ((-w) (-q c5 ff c5 d5) (q eb5 f5 h g5) (-h. q g5) (q g5 f5 eb5 eb5) (h d5 -)
     (-h. q d5) (q eb5 f5 g5 g5) (h f5 q g5 g5) (q eb5 f5 g5 g5) (h f5 q eb5 -)
     (-h. q g5) (q bb5 g5 g5 g5) (h f5 q q) (q g5 f5 eb5 f5) (h d5 c5))
    ((w b2 ff) (h bb2 q ab2 f2) (q g2 ab2 h e2) (w d2) (h b2 c3) (-q d3 h g2)
     (h d3 b2) (q c3 ab3 h e3) (q eb3 d3 h db3) (q c3 b2 bb2 a2) (-q bb2 h eb2)
     (h b2 c3) (h db3 e2) (h eb2 d2) (h b2 q c3 ab2) (q gb2 g2 h c2)))
     
(midi-to-omn 000504b :instrument 1 :bars '(1..4))
=> ((-e g4 ff e. b4 s c5 e d5 f4 ab4 g4) (q e4 -s e4 g4 c4 e f4 ab4 ab4 f4)
    (e db4 db4 - c4 bb4 bb4 db5 c5) (e ab4 ab4 -s c4 f4 g4 e ab4 f4 e. b4 s c5))

Janusz

 

Share this post


Link to post
Share on other sites

"What you are doing Andre is quite bad and unsafe"

very friendly, your answer 🤨

 

...and i knew that, but i didn't found some hints (jn the tutorials) how to extract OMN from def-score. of course it is not good, but it took me only 2 minutes to briefly the problem for my specific application. i have not written any official opusmodus-function (which can do anything) but a simple solution which helps me.

 

Share this post


Link to post
Share on other sites

The midi system and the conversion to score is very complex indeed.

There is not an easy solutions to extract individual midi instruments (tracks).

Anyway, it is done MIDI-TO-OMN and hopefully useful to others.

 

"What you are doing Janusz is quite bad and unsafe"  - I heard this very often and still I am, it is part of programming 😎

Share this post


Link to post
Share on other sites

dear janusz

 

when will be the next update (with midi-to-omn)?

 

and it would be also nice to GET from midi:

 

bpm

duration (of the whole midi, as a result of tempo/bpm and the lengths/rests)

 

...if possible...

 

 

thanx

a.

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 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 Deb76
      Hello,
      I have a problem, I can not finalize an import of a midi file in OPMO. As you can see in the screenshot, the file is imported into the piano-roll, it is correctly read but when in the File menu I want to access "Midi to Partition", this function remains inactive. Do you have an idea to solve this problem?
      Thank you in advance.
      Didier

    • By terekita
      Hello,
       
      I'm trying to import Goldberg Variation No 26 into omn (to then process further), and I'm getting a bunch of fairly crazy rhythms (it certainly is a complicated midi file with ornaments, etc). I've tried both with the midi file included in the distro, and also with the attached. Essentially, I'd love to be able to see pretty much the same rhythms that I see when looking at these midi files in, say, Sibelius, once I export from omn. Anyone able to import that file successfully with respect to rhythmic notation (also, am I correct that there's no way to import musicxml into omn currently), and/or have any tips to offer?
       
      thanks very much, michael
       
      988-v26.mid
×
×
  • Create New...