
#include "MidiEvent.h"

MidiEvent::MidiEvent(){
  event_type = 0;
  channel = 0;
  note = 0;
  velocity = 0;
}

MidiEvent::MidiEvent(int event_type, int channel, int note, int velocity){

  this->event_type = event_type;
  this->channel = channel;
  this->note = note;
  this->velocity = velocity;
}

void MidiEvent::setData(int event_type, int channel, int note, int velocity){
  
  this->event_type = event_type;
  this->channel = channel;
  this->note = note;
  this->velocity = velocity;
}

void MidiEvent::copyEvent(MidiEvent event){

  setData(event.getEventType(), event.getChannel(), event.getNote(), event.getVelocity());

  setTimeStamp(event.getHour(), event.getMinute(), event.getSecond(), 
	       event.getHighMilliseconds(), event.getLowMilliseconds());
  
}

void MidiEvent::setTimeStamp(int hour, int minutes, int seconds,
			     int high_milliseconds, int low_milliseconds){
  
  h= hour;
  mn = minutes;
  sec = seconds;
  ms_high = high_milliseconds;
  ms_low = low_milliseconds;
  
}

unsigned long MidiEvent::getBulkTime(){
  // this method assembles all the time constraints 
  // into a bulk milisecond total

  unsigned long time = ms_low + 
    ms_high * 100 + 
    sec * 1000 + 
    mn * 60000 + 
    h * 3600000;

  return  time;
}

void MidiEvent::printData(){
  
  cout << "event= " << event_type << 
    " channel= " << channel << 
    " note= " << note << 
    " velocity= " << velocity <<
    " h= " << h << " mn= " << mn << " sec= " << sec << 
    " ms= " << getMilliseconds() << endl;
}

