Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "coconet/coconet_utils"

Utility functions for the [Coconet]{@link} model.

license

Copyright 2019 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.

Index

Variables

Const IS_IOS

IS_IOS: boolean = /iPad|iPhone|iPod/.test(navigator.userAgent)

Const MIN_PITCH

MIN_PITCH: 36 = 36

Const NUM_PITCHES

NUM_PITCHES: 46 = 46

Const NUM_VOICES

NUM_VOICES: 4 = 4

Functions

pianorollToSequence

  • pianorollToSequence(pianoroll: tf.Tensor4D, numberOfSteps: number): NoteSequence
  • Converts a pianoroll representation to a NoteSequence. Note that since the pianoroll representation can't distinguish between multiple eighth notes and held notes, the resulting NoteSequence won't either.

    Parameters

    • pianoroll: tf.Tensor4D

      Tensor of shape [steps][NUM_PITCHES][NUM_VOICES], where each entry represents an instrument being played at a particular step and for a particular pitch. For example, pianoroll[0][64] =[0, 0, 1, 0] means that the third instrument plays pitch 64 at time 0.

    • numberOfSteps: number

      The number of quantized steps in the sequence.

    Returns NoteSequence

    A NoteSequence.

sequenceToPianoroll

  • sequenceToPianoroll(ns: INoteSequence, numberOfSteps: number): tf.Tensor4D
  • Converts a NoteSequence to a pianoroll representation. This sequence needs to contain notes with a valid set of instruments, representing the voices in a Bach harmony: 0 is Soprano, 1 is Alto, 2 Tenor and 3 Bass. Any notes with instruments outside of this range are ignored. Note that this pianoroll representation can't distinguish between multiple eighth notes and held notes, so that information will be lost.

    Parameters

    • ns: INoteSequence

      A quantized NoteSequence with at least one note.

    • numberOfSteps: number

      The number of quantized steps in the sequence.

    Returns tf.Tensor4D

    A Tensor of shape [numberOfSteps][NUM_PITCHES][NUM_VOICES] where each entry represents an instrument being played at a particular step and for a particular pitch. For example, pianoroll[0][64] = [0, 0, 1, 0] means that the third instrument plays pitch 64 at time 0.

Generated using TypeDoc