@libraz/libcantus - v1.1.0
    Preparing search index...

    Function toMeterData

    • Resolve any meter-shaped value to the plain meter data the library reads.

      The counterpart of toNoteData for meters: an entry point takes whatever form the caller has — the signature a meter field holds, the data the meter module returns, the map of a piece that changes meter, or a Meter instance — and gets one of two shapes back. An instance is accepted through its toJSON method rather than by its type, so the core layer can read a class it cannot import.

      Text is read by parseTimeSignature and nothing else, so every entry point that takes a meter accepts exactly the signatures that parser accepts, the additive '2+2+3/8' included and nothing besides. A meter map has no text form — it is a run of changes, each with the beat it starts at — so text always names a single signature.

      Parameters

      • value: MeterLike

        A signature text, a plain time signature, a meter map, or a value whose toJSON returns one of those.

      • name: string = 'meter'

        What the meter is called in an error message, so a caller that holds several of them hears which one was malformed.

      Returns MeterData

      The validated signature, or the validated map, freshly allocated down to every grouping array — so a caller may keep and edit what it gets back without editing the meter it passed in, and without any two calls handing out the same object.

      If the value names no meter, or the meter it names is malformed.