sscore_playdata.h

Includes:

Introduction

The C interface to play information in SeeScoreLib

The barindex parameter is zero-based. ie 0 is the first bar in the score. All times are in milliseconds



C Pseudoclasses

sscore_playdata

hidden score data



Groups

sscore_playdata

Group members:

sscore_pd_disposeplaydata

dispose the playdata

sscore_pd_firstbaranacrusis

detect partial first bar (anacrusis)

sscore_pd_getusertempo

get user tempo struct

sscore_pd_maxdynamic

maximum value of any sound dynamic value in all bars

sscore_pd_newplaydata

create playdata which provides iterators for bar and note access

sscore_pd_numparts
sscore_pd_updatetempo

warning of user tempo change

 

sscore_pd_barnotes_iterator

Group members:

sscore_pd_bi_begin

an iterator to notes in the current and next bar

sscore_pd_bi_endnext

an iterator 1 past the last note in next bar so begin->endnext includes all notes in 2 bars so that the bar transition is covered

sscore_pd_bi_endthis

an iterator 1 past the last note in the bar/part

sscore_pd_bi_metronome_begin

an iterator to pseudo metronome notes in the current and next bar

sscore_pd_bi_metronome_endnext

an iterator 1 past the last note in the metronome sequence for this bar and the next bar

sscore_pd_bi_metronome_endthis

an iterator 1 past the last note in the metronome sequence for the bar

sscore_pd_bni_dec

decrement the barnotes iterator so sscore_pd_bni_getnote returns the previous note

sscore_pd_bni_equal

compare 2 iterators

sscore_pd_bni_getnote

get the note information at the current iterator position

sscore_pd_bni_inc

increment the barnotes iterator so sscore_pd_bni_getnote returns the next note

sscore_pd_bni_less

compare 2 iterators

 

sscore_pd_bar_iterator

all functions must be called on a single thread

Group members:

sscore_pd_begin

an iterator to the start bar of the piece (viz STL container)

sscore_pd_bi_barduration

the duration of the current bar in ms

sscore_pd_bi_barindex

get the index of the current bar

sscore_pd_bi_changebar

move the bar iterator to the given bar index

sscore_pd_bi_countin

is this iterator in the count-in before the first bar?

sscore_pd_bi_dec

move the bar iterator to the previous bar accounting for repeats. Unchanged if at beginning

sscore_pd_bi_equal

compare 2 iterators

sscore_pd_bi_getnotesampleinfo

get information about notes required for preloading note samples ahead of time

sscore_pd_bi_inc

move the bar iterator to the next bar accounting for repeats. Unchanged if at end

sscore_pd_bi_less

compare 2 iterators

sscore_pd_bi_nextbarindex

index of next bar

sscore_pd_bi_seqindex

play index of bar in nondecreasing sequence

sscore_pd_end

an iterator to 1 past the end bar of the piece


Functions

sscore_pd_actualbeatsforbar

get the effective time signature information for a bar

sscore_pd_bartypeforbar

get information about a partial bar with fewer beats than the time signature (anacrusis or double-barline bar)

sscore_pd_begin

an iterator to the start bar of the piece (viz STL container)

sscore_pd_bi_barduration

the duration of the current bar in ms

sscore_pd_bi_barindex

get the index of the current bar

sscore_pd_bi_begin

an iterator to notes in the current and next bar

sscore_pd_bi_changebar

move the bar iterator to the given bar index

sscore_pd_bi_countin

is this iterator in the count-in before the first bar?

sscore_pd_bi_dec

move the bar iterator to the previous bar accounting for repeats. Unchanged if at beginning

sscore_pd_bi_endnext

an iterator 1 past the last note in next bar so begin->endnext includes all notes in 2 bars so that the bar transition is covered

sscore_pd_bi_endthis

an iterator 1 past the last note in the bar/part

sscore_pd_bi_equal

compare 2 iterators

sscore_pd_bi_getnotesampleinfo

get information about notes required for preloading note samples ahead of time

sscore_pd_bi_inc

move the bar iterator to the next bar accounting for repeats. Unchanged if at end

sscore_pd_bi_less

compare 2 iterators

sscore_pd_bi_metronome_begin

an iterator to pseudo metronome notes in the current and next bar

sscore_pd_bi_metronome_endnext

an iterator 1 past the last note in the metronome sequence for this bar and the next bar

sscore_pd_bi_metronome_endthis

an iterator 1 past the last note in the metronome sequence for the bar

sscore_pd_bi_nextbarindex

index of next bar

sscore_pd_bi_seqindex

play index of bar in nondecreasing sequence

sscore_pd_bni_dec

decrement the barnotes iterator so sscore_pd_bni_getnote returns the previous note

sscore_pd_bni_equal

compare 2 iterators

sscore_pd_bni_getnote

get the note information at the current iterator position

sscore_pd_bni_inc

increment the barnotes iterator so sscore_pd_bni_getnote returns the next note

sscore_pd_bni_less

compare 2 iterators

sscore_pd_converttempotobpm

convert a tempo with a given beat type to the given time sig beat type

sscore_pd_disposeplaydata

dispose the playdata

sscore_pd_end

an iterator to 1 past the end bar of the piece

sscore_pd_firstbaranacrusis

detect partial first bar (anacrusis)

sscore_pd_getbarbeats

get the beats and divisions in a bar and the duration

sscore_pd_getusertempo

get user tempo struct

sscore_pd_hasdefinedtempo

is tempo defined in the score?

sscore_pd_maxdynamic

maximum value of any sound dynamic value in all bars

sscore_pd_metronomeforbar

get any metronome defined in or before a bar

sscore_pd_newplaydata

create playdata which provides iterators for bar and note access

sscore_pd_numparts
sscore_pd_tempoatbar

get any tempo applying at the start of the given bar

sscore_pd_tempoatstart

get any tempo applying at the start of the score

sscore_pd_timesigforbar

get information about the notated time signature which applies to a bar

sscore_pd_updatetempo

warning of user tempo change


sscore_pd_actualbeatsforbar


get the effective time signature information for a bar

EXPORT enum sscore_error sscore_pd_actualbeatsforbar(
    const sscore *sc,
    int barindex,
    sscore_timesig *timesig);  
Parameters
sc

the score

barindex

the index of the bar

timesig

receives the effective time signature by counting divisions in (top part) bar

Return Value

any error

Discussion

This should return the same value as sscore_timesigforbar for a full bar, less for a partial bar


sscore_pd_bartypeforbar


get information about a partial bar with fewer beats than the time signature (anacrusis or double-barline bar)

EXPORT enum sscore_bartype_e sscore_pd_bartypeforbar(
    const sscore *sc,
    int barindex);  
Parameters
sc

the score

barindex

the index of the bar (the first bar has index 0)

Return Value

type of partial bar

Discussion

it is important to know if a partial bar contains the first beat or the last beat


sscore_pd_begin


an iterator to the start bar of the piece (viz STL container)

Parameters
pd

the playdata

Return Value

an iterator to the start bar of the piece

Discussion

increment the iterator to move to the next bar in play order allowing for repeats


sscore_pd_bi_barduration


the duration of the current bar in ms

Parameters
bi

the bar iterator

Return Value

duration of bar in ms


sscore_pd_bi_barindex


get the index of the current bar

Parameters
bi

the bar iterator

Return Value

the index of the bar which the iterator refers to (0 during count-in and first bar)


sscore_pd_bi_begin


an iterator to notes in the current and next bar

Parameters
bi

the bar iterator

partindex

the part index

Return Value

the start barnotes iterator pointing to the first played note in the bar.

Discussion

increment the returned iterator (sscore_pd_bni_inc) to move to the next note in time order in the given part 'dereference' the iterator (sscore_pd_bni_getnote) to get the note information NB The iterator never returns the right hand note of a tie, as that only modifies the duration of the first tied note


sscore_pd_bi_changebar


move the bar iterator to the given bar index

EXPORT bool sscore_pd_bi_changebar(
    sscore_pd_bar_iterator *bi,
    int barindex);  
Parameters
bi

the bar iterator

barindex

the new bar index - if repeat it is the closest repeat to the current position

Return Value

true if successful


sscore_pd_bi_countin


is this iterator in the count-in before the first bar?

EXPORT bool sscore_pd_bi_countin(
    const sscore_pd_bar_iterator *bi);  
Parameters
bi

the bar iterator

Return Value

true during count-in before first bar


sscore_pd_bi_dec


move the bar iterator to the previous bar accounting for repeats. Unchanged if at beginning

Parameters
bi

the iterator to be updated.


sscore_pd_bi_endnext


an iterator 1 past the last note in next bar so begin->endnext includes all notes in 2 bars so that the bar transition is covered

Parameters
bi

the bar iterator

partindex

the part index

Return Value

the past-end barnotes iterator

Discussion

compare a barnotes iterator with this to detect the end of sequence


sscore_pd_bi_endthis


an iterator 1 past the last note in the bar/part

Parameters
bi

the bar iterator

partindex

the part index

Return Value

the past-end barnotes iterator

Discussion

compare a barnotes iterator with this to detect the end of sequence for the bar


sscore_pd_bi_equal


compare 2 iterators

EXPORT bool sscore_pd_bi_equal(
    const sscore_pd_bar_iterator *bi1,
    const sscore_pd_bar_iterator *bi2);  
Parameters
bi1
bi2
Return Value

true if iterators are equal (point to the same bar, same repeat)


sscore_pd_bi_getnotesampleinfo


get information about notes required for preloading note samples ahead of time

EXPORT enum sscore_error sscore_pd_bi_getnotesampleinfo(
    const sscore_pd_bar_iterator *bi,
    int numbars,
    const sscore_pd_partset *partset,
    sscore_pd_notesamples *rval);  
Parameters
bi

the bar iterator

numbars

the number of bars to collect note sample data for, ahead of the current bar (1 for just the current bar)

partset

the set of parts to harvest information from (eg the set of parts played by a particular instrument for precacheing notes for that instrument)

rval

on return contains the information about notes required in coming numbars. NB The maximum time for any particular note is returned

Return Value

any error


sscore_pd_bi_inc


move the bar iterator to the next bar accounting for repeats. Unchanged if at end

Parameters
bi

the iterator to be updated.


sscore_pd_bi_less


compare 2 iterators

EXPORT bool sscore_pd_bi_less(
    const sscore_pd_bar_iterator *bi1,
    const sscore_pd_bar_iterator *bi2);  
Parameters
bi1
bi2
Return Value

true if bi1 is at an earlier bar than bi2


sscore_pd_bi_metronome_begin


an iterator to pseudo metronome notes in the current and next bar

Parameters
bi

the bar iterator

Return Value

the barnotes iterator

Discussion

the metronome is modelled as a series of notes, 1 per beat in each bar. The correct bar sequence time signature changes are followed


sscore_pd_bi_metronome_endnext


an iterator 1 past the last note in the metronome sequence for this bar and the next bar

Parameters
bi

the bar iterator

Return Value

the barnotes iterator


sscore_pd_bi_metronome_endthis


an iterator 1 past the last note in the metronome sequence for the bar

Parameters
bi

the bar iterator

Return Value

the barnotes iterator


sscore_pd_bi_nextbarindex


index of next bar

Parameters
bi

the iterator

Return Value

index of the next bar after inc if canadvance, else sscore_pd_kAfterEndBarIndex


sscore_pd_bi_seqindex


play index of bar in nondecreasing sequence

Parameters
bi

the iterator

Return Value

sequential play index of the bar accounting for any repeats


sscore_pd_bni_dec


decrement the barnotes iterator so sscore_pd_bni_getnote returns the previous note

Parameters
bni

the iterator


sscore_pd_bni_equal


compare 2 iterators

Parameters
bni1
bni2
Return Value

true if iterators are equal


sscore_pd_bni_getnote


get the note information at the current iterator position

Parameters
bni

the barnotes iterator

Return Value

play information about a note


sscore_pd_bni_inc


increment the barnotes iterator so sscore_pd_bni_getnote returns the next note

Parameters
bni

the iterator

Discussion

notes are returned in non-decreasing start time order


sscore_pd_bni_less


compare 2 iterators

Parameters
bni1
bni2
Return Value

true if bni1 is earlier in the score than bni2 (assuming same playdata and part)


sscore_pd_converttempotobpm


convert a tempo with a given beat type to the given time sig beat type

EXPORT int sscore_pd_converttempotobpm(
    const sscore_pd_tempo *tempo,
    const sscore_timesig *timesig);  
Parameters
tempo

the tempo value to convert

timesig

the time signature for conversion

Return Value

beats per minute

Discussion

this is useful for converting sound tempo values, which are always crotchet relative (beat = 4) to the current time signature


sscore_pd_disposeplaydata


dispose the playdata

Parameters
pd

the playdata

Discussion

dispose the memory allocated for this by sscore_pd_newplaydata


sscore_pd_end


an iterator to 1 past the end bar of the piece

Parameters
pd

the playdata

Return Value

an iterator to 1 past the end bar of the piece

Discussion

if the iterator is equal to this then the play is finished


sscore_pd_firstbaranacrusis


detect partial first bar (anacrusis)

EXPORT bool sscore_pd_firstbaranacrusis(
    const sscore_playdata *pd);  
Parameters
pd

the sscore_playdata

Return Value

true if 1st bar starts after first beat


sscore_pd_getbarbeats


get the beats and divisions in a bar and the duration

EXPORT enum sscore_error sscore_pd_getbarbeats(
    const sscore *sc,
    int barindex,
    int bpm,
    enum sscore_bartype_e bartype,
    sscore_pd_barbeats *barbeats);  
Parameters
sc

the score

barindex

the index of the bar

bpm

the beats-per-minute value

bartype

use sscore_bartype_full_bar to get all the beats in the time signature, or sscore_bartype_default to get the actual number

barbeats

receives the number and duration of beats in the given bar with the given beats per minute

Return Value

any error


sscore_pd_getusertempo


get user tempo struct

Parameters
pd

the sscore_playdata

Return Value

the user tempo


sscore_pd_hasdefinedtempo


is tempo defined in the score?

EXPORT bool sscore_pd_hasdefinedtempo(
    const sscore *sc);  
Parameters
sc

the score

Return Value

true if the score defines tempo (metronome or sound tempo element).

Discussion

If this returns true then sscore_pd_usertempo.get_user_tempo_scaling will be called, else sscore_pd_usertempo.get_user_bpm will be used


sscore_pd_maxdynamic


maximum value of any sound dynamic value in all bars

EXPORT float sscore_pd_maxdynamic(
    const sscore_playdata *pd);  
Parameters
pd

the sscore_playdata

Return Value

max sound dynamic value in score or 0 if none defined


sscore_pd_metronomeforbar


get any metronome defined in or before a bar

EXPORT enum sscore_error sscore_pd_metronomeforbar(
    const sscore *sc,
    int barindex,
    sscore_pd_tempo *tempo);  
Parameters
sc

the score

barindex

the index of the bar

tempo

on exit contains any metronome defined at the bar, or 0 if undefined

Return Value

sscore_ItemNotFoundError if no metronome value defined


sscore_pd_newplaydata


create playdata which provides iterators for bar and note access

EXPORT sscore_playdata *sscore_pd_newplaydata(
    const sscore *sc, 
    const sscore_pd_usertempo *usertempo, 
    int countinbars, 
    const sscore_libkeytype *key);  
Parameters
sc

the score

usertempo

callbacks for realtime user defined tempo

countinbars

defines number of bars for count in when playing from start

key

the key defining licenses owned by the user. If this key does not include a playdata licence then this will operate in evaluation mode and a limited number of notes will be returned after the app is started, after which every sscore_pd_note returned from sscore_pd_bni_getnote will have all fields set to 0

Return Value

pointer to new playdata


sscore_pd_numparts


EXPORT int sscore_pd_numparts(
    const sscore_playdata *pd);  
Return Value

number of parts in score


sscore_pd_tempoatbar


get any tempo applying at the start of the given bar

EXPORT enum sscore_error sscore_pd_tempoatbar(
    const sscore *sc,
    int barindex,
    sscore_pd_tempo *tempo);  
Parameters
sc

the score

tempo

on exit contains any tempo value defined

Return Value

sscore_ItemNotFoundError if no tempo value defined

Discussion

this returns in tempo a) any metronome value or b) any sound tempo value defined at the start of the given bar


sscore_pd_tempoatstart


get any tempo applying at the start of the score

EXPORT enum sscore_error sscore_pd_tempoatstart(
    const sscore *sc,
    sscore_pd_tempo *tempo);  
Parameters
sc

the score

tempo

on exit contains any tempo defined at the start of the piece

Return Value

sscore_ItemNotFoundError if no tempo value defined

Discussion

this returns in tempo a) any metronome value or b) any sound tempo value defined at the start of the score


sscore_pd_timesigforbar


get information about the notated time signature which applies to a bar

EXPORT enum sscore_error sscore_pd_timesigforbar(
    const sscore *sc,
    int barindex,
    sscore_timesig *timesig);  
Parameters
sc

the score

barindex

the index of the bar

timesig

receives the time signature info for the given bar (the first bar has index 0)

Return Value

any error


sscore_pd_updatetempo


warning of user tempo change

Parameters
pd

the sscore_playdata


Typedefs

get_user_tempo_scaling

define realtime user tempo specification

sscore_barbeats

number and duration of beats in a bar

sscore_pd_bar_iterator

private bar iterator for accessing bars in correct sequence when playing

sscore_pd_barbeats

number and duration of beats in a bar

sscore_pd_barnotes_iterator

private bar notes iterator for playing

sscore_pd_note

midi-type information about a note for playing

sscore_pd_notesample

information required for pre-loading a note sample

sscore_pd_notesamples

information required for pre-loading note samples

sscore_pd_partset

define playing parts

sscore_pd_tempo

tempo information


get_user_tempo_scaling


define realtime user tempo specification

typedef struct sscore_pd_usertempo {  
    sscore_pd_int_fn get_user_bpm;   
    sscore_pd_float_fn get_user_tempo_scaling;   
    void *context; 
    unsigned dummy[8]; 
} sscore_pd_usertempo;  
Parameters
context

context pointer to use as an argument to the above functions

Return Value

a scaling value defined by the user to multiply tempo values specified in the score


sscore_barbeats


number and duration of beats in a bar

typedef struct sscore_pd_barbeats { 
    int beatsinbar; 
    int beattime; // ms 
} sscore_pd_barbeats;  

See Also


sscore_pd_bar_iterator


private bar iterator for accessing bars in correct sequence when playing

typedef struct sscore_pd_bar_iterator { 
    // private fields 
    const sscore_playdata *pd; 
    int idx; 
    unsigned dummy[8]; 
} sscore_pd_bar_iterator;  
Discussion

this is not multi-thread safe. ie all functions using this must be called on a single thread


sscore_pd_barbeats


number and duration of beats in a bar

typedef struct sscore_pd_barbeats { 
    int beatsinbar; 
    int beattime; // ms 
} sscore_pd_barbeats;  

See Also


sscore_pd_barnotes_iterator


private bar notes iterator for playing

typedef struct sscore_pd_barnotes_iterator { 
    // private fields 
    sscore_pd_bar_iterator bi; 
    int pidx; 
    int nidx; 
    unsigned dummy[8]; 
} sscore_pd_barnotes_iterator;  
Discussion

this provides notes sequentially with non-decreasing start time from the start of the bar to the end of the _following_ bar, ie notes in 2 bars, so that there is not an inter-bar discontinuity when using non-bar-aligned buffers NB This must be used with the supplied functions. The private fields should not be tampered with


sscore_pd_note


midi-type information about a note for playing

typedef struct sscore_pd_note { 
    int midipitch; // 60 = C4. 0 = unpitched (eg percussion) 
    int startbarindex; // index of bar in which this note starts (may be tied) 
    int start; // start time from start of bar (milliseconds) 
    int duration; // (ms) may be longer than a bar if tied 
    int dynamic; // [0..100] value of the last dynamic 
    enum sscore_pd_grace_e grace; // set for grace note 
    sscore_item_handle item_h; // item handle used in sscore_contents 
    unsigned dummy[8]; // future 
} sscore_pd_note;  
Discussion

NB The right-hand note of a tie is included in the duration of the left hand note and omitted from the list


sscore_pd_notesample


information required for pre-loading a note sample

typedef struct sscore_pd_notesample { 
    int midipitch; // 60 = C4. 0 = unpitched (eg percussion) 
    int duration; // (ms) may be longer than a bar if tied 
    unsigned dummy[2]; 
} sscore_pd_notesample;  

sscore_pd_notesamples


information required for pre-loading note samples

typedef struct sscore_pd_notesamples { 
    int num; 
    sscore_pd_notesample samples[sscore_pd_MaxNoteSamples]; 
    unsigned dummy[8]; 
} sscore_pd_notesamples;  

sscore_pd_partset


define playing parts

typedef struct sscore_pd_partset { 
    int num; // the number of parts 
    bool parts[sscore_kMaxParts]; // play value per part 
} sscore_pd_partset;  

sscore_pd_tempo


tempo information

typedef struct sscore_pd_tempo { 
    int bpm; 
    int beattype; 
    bool dot; 
    bool usebeattype; // set if this is a beat type from a metronome mark and should be displayed, else it is a standard 4 for a sound tempo and is irrelevant to the beat 
    unsigned dummy[8]; 
} sscore_pd_tempo;  

Enumerated Types

sscore_bartype_e

categorise partial bars


sscore_bartype_e


categorise partial bars

enum sscore_bartype_e { 
    sscore_bartype_full_bar, // normal full bar 
    sscore_bartype_partial_first_bar, // partial bar is first bar in score (ie anacrusis) 
    sscore_bartype_partial_bar_start, // partial bar including beat 1 (ie before repeat mark) 
    sscore_bartype_partial_bar_end, // partial bar missing beat 1 (ie after repeat mark) 
    sscore_bartype_default // for default argument 
};  

Macro Definitions

sscore_pd_kAfterEndBarIndex

special value to indicate beyond the last bar in the piece


sscore_pd_kAfterEndBarIndex


special value to indicate beyond the last bar in the piece

Value

0x7fffffff (2147483647)