Create a new NoteSequence with sustain pedal control changes applied.
Extends each note within a sustain to either the beginning of the next note of the same pitch or the end of the sustain period, whichever happens first. This is done on a per instrument basis, so notes are only affected by sustain events for the same instrument. Drum notes will not be modified.
The NoteSequence for which to apply sustain. This object will not be modified.
The MIDI control number for sustain pedal. Control events with this number and value 0-63 will be treated as sustain pedal OFF events, and control events with this number and value 64-127 will be treated as sustain pedal ON events.
A copy of note_sequence
but with note end times extended to
account for sustain.
Confirms that the given NoteSequence has been quantized by absolute time.
Confirms that the given NoteSequence has been quantized.
Confirms that the given NoteSequence has been quantized relative to tempo.
Create an empty quantized NoteSequence with steps per quarter note and tempo.
The number of steps per quarter note to use.
The tempo to use.
A new quantized NoteSequence.
Returns whether the given NoteSequence has been quantized by absolute time.
Returns whether or not a NoteSequence proto has been quantized.
Returns whether the given NoteSequence has been quantized relative to tempo.
Any consecutive notes of the same pitch are merged into a sustained note. Does not merge notes that connect on a measure boundary. This process also rearranges the order of the notes - notes are grouped by instrument, then ordered by timestamp.
A quantized NoteSequence
to be merged.
a new NoteSequence
with sustained notes merged.
Assign instruments to the notes, pitch bends, and control changes of a
NoteSequence
based on program numbers and drum status. All drums will be
assigned the last instrument (and program 0). All non-drum events with the
same program number will be assigned to a single instrument.
The NoteSequence
for which to merge instruments. Will not be
modified.
A copy of ns
with merged instruments.
Quantize a NoteSequence proto relative to tempo.
The input NoteSequence is copied and quantization-related fields are
populated. Sets the steps_per_quarter
field in the quantization_info
message in the NoteSequence.
Note start and end times, and chord times are snapped to a nearby quantized
step, and the resulting times are stored in a separate field (e.g.,
QuantizedStartStep). See the comments above QUANTIZE_CUTOFF
for details
on how the quantizing algorithm works.
The NoteSequence
to quantize.
Each quarter note of music will be divided into this many quantized time steps.
A copy of the original NoteSequence, with quantized times added.
Quantizes seconds to the nearest step, given steps_per_second.
See the comments above QUANTIZE_CUTOFF
for details on how the
quantizing algorithm works.
Seconds to quantize.
Quantizing resolution.
Value to use for quantizing cutoff.
the quantized step.
Replaces all the notes in an input sequence that match the instruments in
a second sequence. For example, if replaceSequence
has notes that all have
either instrument=0
or instrument=1
, then any notes in originalSequence
with instruments 0 or 1 will be removed and replaced with the notes in
replaceSequence
. If there are instruments in replaceSequence
that are
not in originalSequence
, they will not be added.
The NoteSequence
to be changed.
The NoteSequence
that will replace the notes in
sequence
with the same instrument.
a new NoteSequence
with the instruments replaced.
Splits a quantized NoteSequence
into smaller NoteSequences
of
equal chunks. If a note splits across a chunk boundary, then it will be
split between the two chunks.
Silent padding may be added to the final chunk to make it chunkSize
.
The number of steps per chunk. For example, if you want to split the sequence into 2 bar chunks, then if the sequence has 4 steps/quarter, that will be 32 steps for each 2 bars (so a chunkSize of 32).
An array of NoteSequences
each of which are at most chunkSize
steps.
Calculates steps per second given stepsPerQuarter and a QPM.
Trim notes from a NoteSequence to lie within a specified time range.
Notes starting before start
are not included. Notes ending after
end
are not included, unless truncateEndNotes
is true.
The NoteSequence for which to trim notes.
The time after which all notes should begin. This should be either seconds (if ns is unquantized), or a quantized step (if ns is quantized).
The time before which all notes should end. This should be either seconds (if ns is unquantized), or a quantized step (if ns is quantized).
Optional. If true, then notes starting before the end time but ending after it will be included and truncated.
A new NoteSequence with all notes trimmed to lie between start
and end
, and time-shifted to begin at 0.
Create an unquantized version of a quantized NoteSequence
.
Any existing times will be replaced in the output NoteSequence
and
quantization info and steps will be removed.
The tempo to use. If not provided, the tempo in ns
is used,
or the default of 120 if it is not specified in the sequence either.
a new non-quantized NoteSequence
with time in seconds.
Generated using TypeDoc
A library for common manipulations of
NoteSequence
s.Copyright 2018 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.