/*
 * Copyright 2011 Google Inc.
 * 
 * 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.
 */

package synthesizer_core_music;

option java_package = "com.google.synthesizer.core.music";

// An Event is one item in a score.  It has a start and end time, and information about what
// happens at that time, such as what note is played, and on what channel (instrument).
message Event {
  // The start time of the event in measures from the beginning of the score.
  optional double start = 1;

  // The end time of the event.
  optional double end = 2;

  // The start time before "snapping to" the nearest note in the editor.
  optional double unsnapped_start = 3;

  // The end time before "snapping to" the nearest note in the editor.
  optional double unsnapped_end = 4;

  // For a key event, the key/note being pressed.  For other events, this is just where it shows up
  // in the score.  For example, a loop event shows on a certain key just because that makes them
  // easier to edit.
  optional int32 key = 5;

  // The key before before "snapping to" the nearest whole key in the editor.
  // This can hold a fractional key, which can represent a valid frequency between two notes,
  // which might be valid for some synthesizers, but not for midi output.
  optional double unsnapped_key = 6;

  // Is this event selected in the UI?
  optional bool selected = 7;

  // An event where a key is pressed.
  optional KeyEvent key_event = 8;

  // An event where that defines a loop.
  optional LoopEvent loop_event = 9;
}

// An event where a key is pressed at the beginning and released at the end.
message KeyEvent {
  // The channel/instrument to play the note on.
  optional int32 channel = 1;
}

// An event where playback jumps from the end to the beginning a certain number of times. 
message LoopEvent {
  // The total number of times to loop.
  optional int32 count = 1;

  // The number of times left to loop in the current playback.
  optional int32 count_remaining = 2;
} 

// A score, representing a series of synthesizer events that can be played.
message Score {
  // The set of events, in no particular order.
  repeated Event event = 1;
}
