.. _moduleNoteworthy.translate:

music21.noteworthy.translate
============================

.. WARNING: DO NOT EDIT THIS FILE: AUTOMATICALLY GENERATED. Edit the .py file directly

.. module:: music21.noteworthy.translate


Module to translate Noteworthy Composer's NWCTXT format to music21.





NoteworthyTranslator
--------------------



.. class:: NoteworthyTranslator()


    stores all the data about the current parse context (whether we're in a slur, tuplet, etc.)



    **NoteworthyTranslator** **attributes**

        .. attribute:: score

            A Stream subclass for handling multi-part music.

            Absolutely optional (the largest containing Stream in a piece could be
            a generic Stream, or a Part, or a Staff).  And Scores can be
            embedded in other Scores (in fact, our original thought was to call
            this class a Fragment because of this possibility of continuous
            embedding), but we figure that many people will like calling the largest
            container a Score and that this will become a standard.



        .. attribute:: currentKey


            A KeySignature object specifies the signature to be used for a piece; it takes
            in zero, one, or two arguments.  The first argument is an int giving the number of sharps,
            or if negative the number of flats.  The second argument (deprecated -- do not use)
            specifies the mode of the piece ('major', 'minor', or None for unknown).

            If you are starting with the name of a key, see the :class:`~music21.key.Key` object.



            >>> from music21 import *
            ⁠ 
            >>> A = key.KeySignature(3)
            >>> A
            <music21.key.KeySignature of 3 sharps>



            >>> Eflat = key.KeySignature(-3)
            >>> Eflat
            <music21.key.KeySignature of 3 flats>


            If you want to get a real Key, then use the :class:`~music21.key.Key` object instead:



            >>> illegal = key.KeySignature('c#')
            Traceback (most recent call last):
            KeySignatureException: Cannot get a KeySignature from this "number" of sharps: "c#"; did you mean to use a key.Key() object instead?
            ⁠ 
            >>> legal = key.Key('c#')
            >>> legal.sharps
            4
            >>> legal
            <music21.key.Key of c# minor>



        Attributes without Documentation: `activeAccidentals`, `lyrics`, `currentPart`, `currentMeasure`, `currentClef`, `beginningSlurNote`, `withinSlur`, `withinTie`, `lyricPosition`

    **NoteworthyTranslator** **methods**

        .. method:: createBarlines(attributes)


            Translates bar lines into music21.




            >>> from music21 import *
            ⁠ 
            >>> nwt = noteworthy.translate.NoteworthyTranslator()
            >>> nwt.currentPart = stream.Part()
            >>> nwt.currentMeasure = stream.Measure()
            >>> nwt.createBarlines({"Style":"MasterRepeatOpen"})
            >>> nwt.currentMeasure
            <music21.stream.Measure 0 offset=0.0>
            >>> nwt.currentMeasure.leftBarline
            <music21.bar.Repeat direction=start>




        .. method:: createClef(attributes)


            Add a new clef to the current measure and return the currentClef.


            Clef lines should look like: \|Clef\|Type:ClefType  or
            \|Clef\|Type:ClefType\|OctaveShift:Octave Down (or Up)




            >>> from music21 import *
            >>> nwt = noteworthy.translate.NoteworthyTranslator()
            >>> nwt.currentMeasure = stream.Measure()
            >>> nwt.createClef({"Type": "Treble"})
            >>> nwt.currentMeasure.show('text')
            {0.0} <music21.clef.TrebleClef>
            >>> nwt.currentClef
            'TREBLE'
            >>> nwt.createClef({"Type" : "Bass", "OctaveShift" : "Octave Down"})
            >>> nwt.currentMeasure.show('text')
            {0.0} <music21.clef.TrebleClef>
            {0.0} <music21.clef.Bass8vbClef>




            If no clef can be found then it raises a NoteworthyTranslate exception




            >>> nwt.createClef({"Type" : "OBonobo"})
            Traceback (most recent call last):
            NoteworthyTranslateException: Did not find a proper clef in type, OBonobo




        .. method:: createDynamicVariance(attributes)


            Adding dynamics like "crescendo" to the measure.



            >>> from music21 import *
            >>> nwt = noteworthy.translate.NoteworthyTranslator()
            >>> nwt.currentMeasure = stream.Measure()
            >>> nwt.createDynamicVariance({"Style" : "Crescendo", "Pos": "-6"})
            >>> nwt.currentMeasure.show('text')
            {0.0} <music21.spanner.Crescendo >



        .. method:: createDynamics(attributes)


            Adding dynamics like "fff", "pp", ... to the measure.



            >>> from music21 import *
            >>> nwt = noteworthy.translate.NoteworthyTranslator()
            >>> nwt.currentMeasure = stream.Measure()
            >>> nwt.createDynamics({"Style":"fff","Pos":"-8"})
            >>> nwt.currentMeasure[0]
            <music21.dynamics.Dynamic fff >



        .. method:: createKey(attributes)


            Adds a new key signature to the given measure.  Returns the number of sharps (negative for flats)




            >>> from music21 import *
            >>> measureIn = stream.Measure()
            >>> measureIn.append(note.Rest(quarterLength = 3.0))
            ⁠ 
            >>> nwt = noteworthy.translate.NoteworthyTranslator()
            >>> nwt.currentMeasure = measureIn
            >>> nwt.createKey({'Signature':'F#,C#,G#,D#'})
            >>> nwt.currentKey.sharps
            4
            >>> measureIn.show('text')
            {0.0} <music21.note.Rest rest>
            {3.0} <music21.key.KeySignature of 4 sharps>



        .. method:: createLyrics(attributes)


            Get a list of lyrics from a Lyric line



            >>> from music21 import *
            ⁠ 
            >>> nwt = noteworthy.translate.NoteworthyTranslator()
            >>> Lyricslist = nwt.createLyrics({'Text':'"Hello world"'})
            >>> Lyricslist[0]
            'Hello'



        .. method:: createOtherRepetitions(attributes)


            Repetitions like "Coda", "Segno" and some others.


            >>> from music21 import *
            ⁠ 
            >>> nwt = noteworthy.translate.NoteworthyTranslator()
            >>> nwt.currentMeasure = stream.Measure()
            >>> nwt.createOtherRepetitions({"Style" : "ToCoda", "Pos": "8", "Wide":"Y","Placement":"BestFitForward"})
            >>> "Coda" in nwt.currentMeasure[0].classes
            True



        .. method:: createPart()


            Add a new part to the score.



        .. method:: createTimeSignature(attributes)


            Adding a time signature in the score.


            >>> from music21 import *
            ⁠ 
            >>> measure = stream.Measure()
            >>> nwt = noteworthy.translate.NoteworthyTranslator()
            >>> nwt.currentMeasure = measure
            >>> nwt.createTimeSignature({"Signature":"4/4"})
            >>> measure[0]
            <music21.meter.TimeSignature 4/4>



        .. method:: getMultiplePitchesFromPositionInfo(posInfo)


            returns a list of pitch objects given the Pos:... info
            for a chord.



            >>> from music21 import *
            >>> nwt = noteworthy.translate.NoteworthyTranslator()
            >>> nwt.currentClef = 'BASS'
            >>> pList = nwt.getMultiplePitchesFromPositionInfo('1,b3,5')
            >>> pList
            [E3, G-3, B3]



        .. method:: getOnePitchFromPosition(pos)


            get one pitch from a position...



            >>> from music21 import *
            >>> nwt = noteworthy.translate.NoteworthyTranslator()
            >>> nwt.currentClef = 'BASS'
            >>> p = nwt.getOnePitchFromPosition('b3')
            >>> p
            G-3
            >>> p.ps
            54.0



        .. method:: getPitchFromPositionInfo(posInfo)


            returns a pitch object given the Pos: info

            removes ties and alteration signs.  Otherwise
            is same as getOnePitchFromPosition()



            >>> from music21 import *
            >>> nwt = noteworthy.translate.NoteworthyTranslator()
            >>> nwt.currentClef = 'BASS'
            >>> p = nwt.getPitchFromPositionInfo('b3^') # removes ties
            >>> p
            G-3



        .. method:: getStepAndOctaveFromPosition(positionnote)


            Given an int representing the position on the staff for the
            current clef,
            returns a string for the step and an int for the octave



            >>> from music21 import *
            >>> nwt = noteworthy.translate.NoteworthyTranslator()
            >>> nwt.currentClef = 'BASS'
            >>> (step, octave) = nwt.getStepAndOctaveFromPosition(3)
            >>> (step, octave)
            ('G', 3)



        .. method:: parseFile(filePath)

            No documentation.


        .. method:: parseList(dataList)


            Parses a list where each element is a line from a nwctxt file.

            Returns a :class:`~music21.stream.Score` object




            >>> from music21 import *
            >>> data = []
            >>> data.append("!NoteWorthyComposer(2.0)\n")
            >>> data.append("|AddStaff|\n")
            >>> data.append("|Clef|Type:Bass\n")
            >>> data.append("|TimeSig|Signature:4/4\n")
            >>> data.append("|Note|Dur:Whole|Pos:1\n")
            ⁠ 
            >>>
            >>> nwt = noteworthy.translate.NoteworthyTranslator()
            >>> s = nwt.parseList(data)
            >>> s.show('text')
            {0.0} <music21.stream.Part ...>
                {0.0} <music21.stream.Measure 0 offset=0.0>
                    {0.0} <music21.clef.BassClef>
                    {0.0} <music21.meter.TimeSignature 4/4>
                    {0.0} <music21.note.Note E>




        .. method:: parseString(data)

            No documentation.


        .. method:: setDurationForObject(generalNote, durationInfo)


            generalNote could be a Note, Chord, or Rest

            DurationInfo is a string like:

                Whole,Dotted,Slur




        .. method:: setTieFromPitchInfo(noteOrChord, pitchInfo)


            sets the tie status for a noteOrChord from the pitchInfo



        .. method:: translateChord(attributes)


            Translation of a music21 chord from a NWC one.


            >>> from music21 import *
            >>> measure = stream.Measure()
            ⁠ 
            >>> nwt = noteworthy.translate.NoteworthyTranslator()
            >>> nwt.currentMeasure = measure
            >>> nwt.translateChord({'Dur': 'Half', 'Pos': '1,3,#5'})
            >>> measure[0]
            <music21.chord.Chord C5 E5 G#5>

            Chords also inherit accidentals:


            >>> nwt.translateChord({'Dur': 'Half', 'Pos': '1,3,5'})
            >>> measure[1]
            <music21.chord.Chord C5 E5 G#5>




        .. method:: translateNote(attributes)


            Translation of a music21 note from a NWC note.



            >>> from music21 import *
            ⁠ 
            >>> measure = stream.Measure()
            >>> nwt = noteworthy.translate.NoteworthyTranslator()
            >>> nwt.currentMeasure = measure
            >>> nwt.translateNote({'Dur': 'Half', 'Pos': '#-3'})
            >>> measure[0]
            <music21.note.Note F#>

            Note that the next note in the measure with the same position should
            inherit the last position's accidental:



            >>> nwt.translateNote({'Dur': 'Half', 'Pos': '-3'})
            >>> measure[1]
            <music21.note.Note F#>




        .. method:: translateRest(attributes)


            Translation of a music21 rest.  Adds the rest to the given measure.




            >>> from music21 import *
            >>> measureIn = stream.Measure()
            >>> measureIn.append(note.HalfNote("C#4"))
            ⁠ 
            >>> nwt = noteworthy.translate.NoteworthyTranslator()
            >>> nwt.currentMeasure = measureIn
            >>> nwt.translateRest({'Dur': '8th,Dotted'})
            >>> nwt.translateRest({'Dur': '4th'})
            >>> measureIn.show('text')
            {0.0} <music21.note.Note C#>
            {2.0} <music21.note.Rest rest>
            {2.75} <music21.note.Rest rest>





