home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 November / CMCD1104.ISO / Software / Complet / ZynAddFX / Setup_ZynAddSubFX-2.1.1.exe / MIDIEvents.C < prev    next >
Encoding:
C/C++ Source or Header  |  2004-07-30  |  2.1 KB  |  86 lines

  1. /*
  2.   ZynAddSubFX - a software synthesizer
  3.  
  4.   MIDIEvents.C - It stores the midi events from midi file or sequencer
  5.   Copyright (C) 2003-2004 Nasca Octavian Paul
  6.   Author: Nasca Octavian Paul
  7.  
  8.   This program is free software; you can redistribute it and/or modify
  9.   it under the terms of version 2 of the GNU General Public License 
  10.   as published by the Free Software Foundation.
  11.  
  12.   This program is distributed in the hope that it will be useful,
  13.   but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.   GNU General Public License (version 2) for more details.
  16.  
  17.   You should have received a copy of the GNU General Public License (version 2)
  18.   along with this program; if not, write to the Free Software Foundation,
  19.   Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  20.  
  21. */
  22.  
  23. #include "MIDIEvents.h"
  24. #include <stdlib.h>
  25. #include <stdio.h>
  26.  
  27. MIDIEvents::MIDIEvents(){
  28. };
  29.  
  30. MIDIEvents::~MIDIEvents(){
  31. };
  32.  
  33.  
  34. /************** Track stuff ***************/
  35. void MIDIEvents::writeevent(list *l,event *ev){
  36.     listpos *tmp=new listpos;
  37.     tmp->next=NULL;
  38.     tmp->ev=*ev;
  39.     if (l->current!=NULL) l->current->next=tmp;
  40.     else l->first=tmp;
  41.     l->current=tmp;
  42.     printf("Wx%x ",(int) l->current);
  43.     printf("-> %d  \n",l->current->ev.deltatime);
  44.     l->size++;
  45. };
  46.  
  47. void MIDIEvents::readevent(list *l,event *ev){
  48.     if (l->current==NULL) {
  49.     ev->type=-1;
  50.     return;
  51.     };
  52.     *ev=l->current->ev;
  53.     l->current=l->current->next;
  54.  
  55.     //test
  56.     if (l->current!=NULL) {
  57. //    ev->deltatime=10000;
  58. //    printf("Rx%d\n",l->current->ev.deltatime);
  59.     printf("Rx%x  ",(int) l->current);
  60.     printf("-> %d  (next=%x) \n",(int)l->current->ev.deltatime,(int)l->current->next);
  61.     };
  62.  
  63. };
  64.  
  65.  
  66. void MIDIEvents::rewindlist(list *l){
  67.     l->current=l->first;
  68. };
  69.  
  70. void MIDIEvents::deletelist(list *l){
  71.     l->current=l->first;
  72.     if (l->current==NULL) return;
  73.     while (l->current->next!=NULL){
  74.     listpos *tmp=l->current;
  75.     l->current=l->current->next;
  76.     delete(tmp);
  77.     };
  78.     deletelistreference(l);
  79. };
  80.  
  81. void MIDIEvents::deletelistreference(list *l){
  82.     l->current=l->first=NULL;
  83.     l->size=0;
  84.     l->length=0.0;
  85. };
  86.