musipedia.org// ?
Deutsch  English  Français  中文 
 

Logging in is required for posting.

Special forum features: inserting music notation, posting audio recordings.

All Categories > Musipedia > Musipedia General > Convert keyboard search notation to triplets(onset time, MIDI pitch, duration)
Total Posts: 3 - Pages (1): [1]
Author: yohann
Posted: Mar 07 2014 - 11:32 AM
Subject: re: Convert keyboard search notation to triplets(onset time, MIDI pitch, duration)
Thanks !!!

This is my JavaScript method. I decide to use contour like you ! :

getContourFromLily = function ($lily) {
var i,
$pc = "",
$lil = $lily.split(" "),
$li,
$pitch = -1,
$midival,
$oct,
$np;

for (i = 0; i < $lil.length; i++) {
$li = $lil[i];
$midival = -2;
if ($li.substr(0, 1) === 'c') {
$midival = 0;
}
if ($li.substr(0, 1) === 'd') {
$midival = 2;
}
if ($li.substr(0, 1) === 'e') {
$midival = 4;
}
if ($li.substr(0, 1) === 'f') {
$midival = 5;
}
if ($li.substr(0, 1) === 'g') {
$midival = 7;
}
if ($li.substr(0, 1) === 'a') {
$midival = 9;
}
if ($li.substr(0, 1) === 'b') {
$midival = 11;
}
if ($li.substr(0, 1) === 'r') {
$midival = -1;
}
$li = $li.substr(1);
if ($li.substr(0, 2) === "is") {
$midival++;
$li = $li.substr(2);
}
$oct = 5;
while ($li.substr(0, 1) === ",") {
$oct--;
$li = $li.substr(1);
}
while ($li.substr(0, 1) === "'") {
$oct++;
$li = $li.substr(1);
}
if ($midival >= 0) {
$np = $midival + $oct * 12;
if ($pitch > -1) {
if ($np > $pitch) {
$pc += "U";
} else if ($np < $pitch) {
$pc += "D";
} else {
$pc += "R";
}
}
$pitch = $np;
}
}
return $pc;
};
user picture Author: rt
Posted: Mar 05 2014 - 08:49 AM
Subject: re: Convert keyboard search notation to triplets(onset time, MIDI pitch, duration)
well, you could slightly modify the following function (which extracts just a rough contour):

function getContourFromLily($lily) {
$pc = "";

$lil = explode(" ", $lily);
#print_r($lil);
$pitch = -1;
foreach ($lil as $li) {
$midival = -2;
if (substr($li, 0, 1) == 'c')
$midival = 0;
if (substr($li, 0, 1) == 'd')
$midival = 2;
if (substr($li, 0, 1) == 'e')
$midival = 4;
if (substr($li, 0, 1) == 'f')
$midival = 5;
if (substr($li, 0, 1) == 'g')
$midival = 7;
if (substr($li, 0, 1) == 'a')
$midival = 9;
if (substr($li, 0, 1) == 'b')
$midival = 11;
if (substr($li, 0, 1) == 'r')
$midival = -1;
$li = substr($li, 1);
if (substr($li, 0, 2) == "is") {
$midival++;
$li = substr($li, 2);
}
$oct = 5;
while (substr($li, 0, 1) == ",") {
$oct--; $li = substr($li, 1);
}
while (substr($li, 0, 1) == "'") {
$oct++; $li = substr($li, 1);
}
if ($midival >= 0) {
$np = $midival + $oct * 12;
if ($pitch > -1) {
if ($np > $pitch)
$pc .= "U";
else if ($np < $pitch)
$pc .= "D";
else
$pc .= "R";
#print $pc." ";
}
$pitch = $np;
}
}
return $pc;
}
Author: yohann
Posted: Mar 04 2014 - 06:32 PM
Subject: Convert keyboard search notation to triplets(onset time, MIDI pitch, duration)
Hi,

I need to know the algorithm to convert keyboard search notation like this "g'8 e'8 g'8 c''8 a'2 f'8 d'8 f'8 c''8 g'8 f'8 e'8" for the parameter q2query(melody : a sequence of triplets of onset time, MIDI pitch, duration, e. g. "3.2,82,0.3;3.8,82,0.2;4,64,1") of the soap webservices.

Could you help me please ?
Total Posts: 3 - Pages (1): [1]
You must login to post a message to this conference.

How to insert music:

Add a bit of sheet music, along with a MIDI file, simply by entering note names in Lilypond syntax between the [L] and [/L] tags.
For example, you can try what happens if you enter: [l]g'4 g'4 d''4 d''4 e''4 e''4 d''2[/l] (use the Preview function if you don't actually want to post this).
You can create these lists of note names by clicking on piano keys here.

How to post an audio recording:

If you just want to sing, whistle, or play a melody so that other forum visitors can hear it, follow these steps:

  1. Record your audio here.
  2. You should notice a 32-character hash code, something like: 2a40281c5001c5a7d8c9f57fcdeccfaf
  3. copy this hash code and paste it into a forum post, enclosed in the audio tags, for example: [audio]2a40281c5001c5a7d8c9f57fcdeccfaf[/audio]

How to mark a thread as solved:

If the original question in a thread is solved, please mark it as solved using the "solved" icon (or by just typing [solved] into your post). This makes life easier for people who are willing to identify melodies, since unsolved problems are easier to spot that way. If a problem turns out to not be solved after all, just write [/solved] in a new post, and the thread will be labeled accordingly.

melbet online