-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Identifying music note types #112
Comments
Hi, there is a class to AbcJSON which provides a method to get the music model as json. This is maintained by @moinejf and is a more stable access. You can save this JSON and investigate it to see which information is provided. why do you think that clear() is deprecated? I could not find a hint for this. Here is the Opal code I am using to extract the model. you can guess how it would be in a plain Javascript. #
# we use gen_json in to prepare
#
def _callback_get_abcmodel(tsfirst, voice_tb, music_types, info)
json_model = ""
%x{
var abcmidi = new AbcMIDI();
abcmidi.add(#{tsfirst}, #{voice_tb});
var to_json = new AbcJSON();
#{json_model} = to_json.gen_json(#{tsfirst}, #{voice_tb}, #{music_types}, #{info});
var to_audio = new ToAudio()
to_audio.add(#{tsfirst}, #{voice_tb})
#{@player_model} = to_audio.clear()
}
@abc_model = JSON.parse(json_model)
if $log.loglevel == "debug"
$log.debug(@abc_model.to_json)
end
@abc_model
end |
Hi @GitterHubber and @bwl21, The first functions are called when the symbols are generated, just before or after creating their SVG representation. The second function (get_abcmodel) is called just before the SVG generation of a tune. On the other side, there are two mechanisms for playing. The old mecanism which is still used (for some time) in abcemb{,1,2}.js, does two generations: a first one to create the SVG images, and a second one for playing. This second generation uses to_audio.add() in get_abcmodel() to create the 'play data' (array of floats). This array is returned by to_audio.clear(). The new mecanism is (actually) implemented in the simple editor only. There is only one generation. On anno_stop(), the symbol and its location in the source file are memorized. The source file is stored in the class of a rectangle drawn around the music symbol. This permits to identify the symbols in the page frame from mouse events. Then, for playing, the function abcplay.play() is called with the pointers to the start and stop symbols. Internally, on its first call, this function generates the MIDI pitches and other play attributes (ties, repeat sequences...) before following the time links and doing the sound generation. |
I say this because I think snd-1.js ,which is the new sound api, no longer uses clear, at least that's the indication I got.
@moinejf and @bwl21 |
Hi, I pasting an excerpt of the json string that I get symbol objects like so
I see that type 8 indicates that it is a "note". The duration will probably give information regarding the note, I mean we can compute the note type from the duration and tempo, but I was just wondering if you have already pre-computed and kept it available for use. |
Most of the constants are defined in the file core/abc2svg.js. The conversion between the note duration and its head type and its dots is done in the function 'identify_note() in core/music.js. More information about the attributes of the symbol above:
|
Thanks for the extended reply
I see that there are 2 different pitch values. One pitch value is in the Midi play data, which seem to be the Midi pitch numbers where middle C or C4 is 60. Secondly, |
The MIDI pitch is computed from the ABC pitch after handling the accidentals and the play transposition. I don't see what you mean by 'Midi play data array'. The JSON representation lacks a lot of information (pointers). For a correct rendering (display or play), it is better to use the raw structures. |
Is staff pitch number a universal concept or is it just used in abc2svg. |
I'd never imagined the staff pitch number to be searched on the web! Some country use C,D,E,F.., some other ones use Do,Re,Mi,Fa.. These are names that are not easy to use in computers. Instead, music software use numbers. |
Hi,
Is data of the note types rendered in SVG available and computed?
I mean if the first note is a crotchet and second a minim, would your library indicate that or compute that? Is that data accessible.
Secondly, If there is a chord present on the staff, Like C, E, G notes on the same vertical line, does abc2svg know that and is that data also available?
Currently I have access to the play data (array of floats) however that doesn't seem to have sufficient information. However, I see that there are 2 other data structures "tsfirst" and "voice_tb", it might be possible that one of them has the necessary information that I'm looking for?
I'm using code like this to get the array of floats
the toaudio.clear() function returns the play data. I see that the clear() function has now been deprecated in the newer versions?
The text was updated successfully, but these errors were encountered: