mirror of
https://github.com/Tonejs/Tone.js
synced 2024-11-16 08:38:00 +00:00
checks if part is array
This commit is contained in:
parent
a01dbb8518
commit
2016778123
1 changed files with 14 additions and 10 deletions
|
@ -132,17 +132,21 @@ define(["Tone/core/Tone", "Tone/core/Transport"], function(Tone){
|
|||
var notes = [];
|
||||
for (var inst in score){
|
||||
var part = score[inst];
|
||||
for (var i = 0; i < part.length; i++){
|
||||
var noteDescription = part[i];
|
||||
var note;
|
||||
if (Array.isArray(noteDescription)){
|
||||
var time = noteDescription[0];
|
||||
var value = noteDescription.slice(1);
|
||||
note = new Tone.Note(inst, time, value);
|
||||
} else {
|
||||
note = new Tone.Note(inst, noteDescription);
|
||||
if (Array.isArray(part)){
|
||||
for (var i = 0; i < part.length; i++){
|
||||
var noteDescription = part[i];
|
||||
var note;
|
||||
if (Array.isArray(noteDescription)){
|
||||
var time = noteDescription[0];
|
||||
var value = noteDescription.slice(1);
|
||||
note = new Tone.Note(inst, time, value);
|
||||
} else {
|
||||
note = new Tone.Note(inst, noteDescription);
|
||||
}
|
||||
notes.push(note);
|
||||
}
|
||||
notes.push(note);
|
||||
} else {
|
||||
throw new TypeError("score parts must be Arrays");
|
||||
}
|
||||
}
|
||||
return notes;
|
||||
|
|
Loading…
Reference in a new issue