2727 * @classdesc methods are imported by a importMethod function call from MusicBlocks class.
2828 */
2929class PitchBlocksAPI {
30+ /**
31+ * Plays a note with specified pitch and octave.
32+ * @param {string } note - The note name to play (e.g., 'C', 'D', etc.)
33+ * @param {number } octave - The octave number for the note
34+ * @returns {Promise } Command execution promise
35+ */
3036 playPitch ( note , octave ) {
3137 const args = JSInterface . validateArgs ( "playPitch" , [ note , octave ] ) ;
3238 return this . runCommand ( "playPitch" , [ args [ 0 ] , args [ 1 ] , 0 , this . turIndex , MusicBlocks . BLK ] ) ;
3339 }
3440
41+ /**
42+ * Steps the pitch up or down by a specified value.
43+ * @param {number } value - The number of steps to move (positive for up, negative for down)
44+ * @returns {Promise } Command execution promise
45+ */
3546 stepPitch ( value ) {
3647 const args = JSInterface . validateArgs ( "stepPitch" , [ value ] ) ;
3748 return this . runCommand ( "stepPitch" , [ args [ 0 ] , this . turIndex ] ) ;
3849 }
3950
51+ /**
52+ * Plays the nth pitch in the current modal scale.
53+ * @param {number } number - The scale degree to play
54+ * @param {number } octave - The octave number
55+ * @returns {Promise } Command execution promise
56+ */
4057 playNthModalPitch ( number , octave ) {
4158 const args = JSInterface . validateArgs ( "playNthModalPitch" , [ number , octave ] ) ;
4259 return this . runCommand ( "playNthModalPitch" , [
@@ -47,59 +64,116 @@ class PitchBlocksAPI {
4764 ] ) ;
4865 }
4966
67+ /**
68+ * Plays a pitch specified by its number value.
69+ * @param {number } number - The pitch number to play
70+ * @returns {Promise } Command execution promise
71+ */
5072 playPitchNumber ( number ) {
5173 const args = JSInterface . validateArgs ( "playPitchNumber" , [ number ] ) ;
5274 return this . runCommand ( "playPitchNumber" , [ args [ 0 ] , this . turIndex , MusicBlocks . BLK ] ) ;
5375 }
5476
77+ /**
78+ * Plays a note at a specified frequency in Hertz.
79+ * @param {number } value - The frequency in Hertz
80+ * @returns {Promise } Command execution promise
81+ */
5582 playHertz ( value ) {
5683 const args = JSInterface . validateArgs ( "playHertz" , [ value ] ) ;
5784 return this . runCommand ( "playHertz" , [ args [ 0 ] , this . turIndex ] ) ;
5885 }
5986
87+ /**
88+ * Sets an accidental (sharp, flat, etc.) for subsequent notes.
89+ * @param {string } accidental - The accidental to apply
90+ * @param {Function } flow - Flow function to execute after setting accidental
91+ * @returns {string } ENDFLOWCOMMAND
92+ */
6093 async setAccidental ( accidental , flow ) {
6194 const args = JSInterface . validateArgs ( "setAccidental" , [ accidental , flow ] ) ;
6295 await this . runCommand ( "setAccidental" , [ args [ 0 ] , this . turIndex , MusicBlocks . BLK ] ) ;
6396 await args [ 1 ] ( ) ;
6497 return this . ENDFLOWCOMMAND ;
6598 }
6699
100+ /**
101+ * Transposes subsequent notes by a scalar value.
102+ * @param {number } value - The number of scale degrees to transpose
103+ * @param {Function } flow - Flow function to execute after transposition
104+ * @returns {string } ENDFLOWCOMMAND
105+ */
67106 async setScalarTranspose ( value , flow ) {
68107 const args = JSInterface . validateArgs ( "setScalarTranspose" , [ value , flow ] ) ;
69108 await this . runCommand ( "setScalarTranspose" , [ args [ 0 ] , this . turIndex ] ) ;
70109 await args [ 1 ] ( ) ;
71110 return this . ENDFLOWCOMMAND ;
72111 }
73112
113+ /**
114+ * Transposes subsequent notes by a specified number of semitones.
115+ * @param {number } value - The number of semitones to transpose
116+ * @param {Function } flow - Flow function to execute after transposition
117+ * @returns {string } ENDFLOWCOMMAND
118+ */
74119 async setSemitoneTranspose ( value , flow ) {
75120 const args = JSInterface . validateArgs ( "setSemitoneTranspose" , [ value , flow ] ) ;
76121 await this . runCommand ( "setSemitoneTranspose" , [ args [ 0 ] , this . turIndex ] ) ;
77122 await args [ 1 ] ( ) ;
78123 return this . ENDFLOWCOMMAND ;
79124 }
80125
126+ /**
127+ * Sets the register (octave range) for subsequent notes.
128+ * @param {number } value - The register value to set
129+ * @returns {Promise } Command execution promise
130+ */
81131 setRegister ( value ) {
82132 const args = JSInterface . validateArgs ( "setRegister" , [ value ] ) ;
83133 return this . runCommand ( "setRegister" , [ args [ 0 ] , this . turIndex ] ) ;
84134 }
85135
136+ /**
137+ * Inverts the current pitch sequence based on specified parameters.
138+ * @param {string } name - The name of the inversion
139+ * @param {number } octave - The octave for the inversion
140+ * @param {string } mode - The mode for the inversion
141+ * @param {Function } flow - Flow function to execute after inversion
142+ * @returns {string } ENDFLOWCOMMAND
143+ */
86144 async invert ( name , octave , mode , flow ) {
87145 const args = JSInterface . validateArgs ( "invert" , [ name , octave , mode , flow ] ) ;
88146 await this . runCommand ( "invert" , [ args [ 0 ] , args [ 1 ] , args [ 2 ] , this . turIndex ] ) ;
89147 await args [ 3 ] ( ) ;
90148 return this . ENDFLOWCOMMAND ;
91149 }
92150
151+ /**
152+ * Sets the pitch number offset for subsequent notes.
153+ * @param {number } pitch - The pitch offset value
154+ * @param {number } octave - The octave offset value
155+ * @returns {Promise } Command execution promise
156+ */
93157 setPitchNumberOffset ( pitch , octave ) {
94158 const args = JSInterface . validateArgs ( "setPitchNumberOffset" , [ pitch , octave ] ) ;
95159 return this . runCommand ( "setPitchNumberOffset" , [ args [ 0 ] , args [ 1 ] , this . turIndex ] ) ;
96160 }
97161
162+ /**
163+ * Converts a number to its corresponding pitch name.
164+ * @param {number } number - The number to convert
165+ * @returns {string } The pitch name
166+ */
98167 numToPitch ( number ) {
99168 const args = JSInterface . validateArgs ( "numToPitch" , [ number ] ) ;
100169 return Singer . PitchActions . numToPitch ( args [ 0 ] , "pitch" , this . turIndex ) ;
101170 }
102171
172+ /**
173+ * Converts a number to its corresponding octave.
174+ * @param {number } number - The number to convert
175+ * @returns {number } The octave number
176+ */
103177 numToOctave ( number ) {
104178 const args = JSInterface . validateArgs ( "numToOctave" , [ number ] ) ;
105179 return Singer . PitchActions . numToPitch ( args [ 0 ] , "octave" , this . turIndex ) ;
0 commit comments