There are lots of ways of creating notes because the specifics depend on
what information you are starting with.  Like sometimes you have a pitch
but don't know what note name it is or staff line to display it on; other
times; other times you have a note name but don't know how to map it to a
pitch or staff line; other times you have a staff line but don't know what
note name or pitch it is; plus you may or may not already know the exact
duration or may need to infer it from the toolbar or you may need to figure
out how to break the note into multiple tied notes, etc.  Also keep in
mind, there is no such thing as an empty measure normally - they should
have a full measure already.  So part of the process of adding notes is
normally deleting whatever was already there to make room for the note(s)
you are adding, but the process for doing that may different for voice 1
versus other voices, also may differ depending on whether you can predict
in advance how big a space you will need in total or whether you need to
create the space one note at a time.

So there are lots of different fuinctions involved, and no
one-size-fits-all solution.

But for one example of a very simple use case, see:


https://github.com/musescore/MuseScore/blob/f1b0364106c8a0e7b1ce06cdf097c168d20a1e84/libmscore/cmd.cpp#L2712

This is the handler for the "Fill with slashes" command, which fills a
measure with quarter notes (marked as "slash" style, but they are created
as normal notes first).  See in particular the use of makeGapVoice() to
create space one note at a time, and setNoteRest() to insert the note.  I'm
using noteValForPosition() to construct the parameters for the note because
I start out knowing the line I want but not pitch or note name.  That's
probably not the case for you, though, so the process will be different.

On Tue, May 19, 2015 at 1:22 PM, Jim Newton <[email protected]> wrote:

> Can someone please point me to a skeleton of how to create notes in an
> empty
> measure programmatically?
> In my case I have the staff object (or pointer), and a parallel staff which
> has notes in it.  I want to derive notes/chords in one staff based on notes
> from another staff.
>
> Basically I'm looking for the model such as:
>
> seg = addSegment(staff,tick);
> track = getVoice(staff,0);  // get the track number of voice 1 of the staff
> chord = createChord(seg,track,tick,duration);
> createNote(chord,ppitch1);
> chreateNote(chord,ppitch2);
> chreateNote(chord,ppitch3);
>
>
>
> --
> View this message in context:
> http://dev-list.musescore.org/creating-notes-programmatically-tp7579377.html
> Sent from the MuseScore Developer mailing list archive at Nabble.com.
>
>
> ------------------------------------------------------------------------------
> One dashboard for servers and applications across Physical-Virtual-Cloud
> Widest out-of-the-box monitoring support with 50+ applications
> Performance metrics, stats and reports that give you Actionable Insights
> Deep dive visibility with transaction tracing using APM Insight.
> http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
> _______________________________________________
> Mscore-developer mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/mscore-developer
>



-- 
Marc Sabatella
[email protected]
------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Mscore-developer mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mscore-developer

Reply via email to