GUIDOLib  1.7.7
Guido Engine Internal Documentation
MIDIMapper.h
1 #ifndef __MidiMapper__
2 #define __MidiMapper__
3 
4 /*
5  GUIDO Library
6  Copyright (C) 2011 Grame
7 
8 
9  This Source Code Form is subject to the terms of the Mozilla Public
10  License, v. 2.0. If a copy of the MPL was not distributed with this
11  file, You can obtain one at http://mozilla.org/MPL/2.0/.
12 
13  Grame Research Laboratory, 11, cours de Verdun Gensoul 69002 Lyon - France
14  research@grame.fr
15 
16 */
17 
18 #include <map>
19 
20 #include "TimeUnwrap.h"
21 #include "MidiShareLight.h"
22 
23 typedef struct TMidiSeq *MidiSeqPtr;
24 struct Guido2MidiParams;
25 
26 //------------------------------------------------------------------------------
27 class MidiMapper : public TimeUnwrap
28 {
29  private:
30  const Guido2MidiParams* fParams;
31  MidiLight* fMidi;
32  MidiSeqPtr fSeq;
33  MidiSeqPtr fTempoMap;
34  int fChan;
35  float fLastTempo;
36  TYPE_TIMEPOSITION fUPosition; // the current unrolled time position
37  int fFlags; // a bit field carrying accents, stacc, tenuto, etc...
38  int fCurrVelocity; // the current velocity, updated by \intens tags
39  std::map<char, MidiEvPtr> fTiedNotes; // tied notes mapped by Midi pitch
40  TYPE_DURATION fEmptyDur; // empty duration storage: used for chords
41  bool fChord; // a flag to indicate that we're in a chord
42 
43  enum { knoflag, hasStaccato=1, hasSlur=hasStaccato*2, hasTenuto=hasSlur*2, hasFermata = hasTenuto*2,
44  hasAccent=hasFermata*2, hasMarcato=hasAccent*2, hasTie=hasMarcato*2 };
45 
46  int Ticks (TYPE_DURATION duration);
47  int AdjustDuration (int duration, const Guido2MidiParams* p) const;
48  int AdjustVelocity (int vel, const Guido2MidiParams* p) const;
49  void MoveTime (TYPE_DURATION duration);
50  void TempoChge (const ARMusicalObject * ev);
51  void IntensChge (const ARMusicalObject * ev);
52  void TiedNote (MidiEvPtr note);
53 
54  protected:
55  virtual void Event (const ARMusicalObject * ev, EventType type);
56  virtual void Note (const ARMusicalObject * ev);
57  virtual void Rest (const ARMusicalObject * ev);
58 
59  public:
60  MidiMapper(ARMusicalVoice* voice, MidiLight* midi, const Guido2MidiParams* p, int chan, MidiSeqPtr outseq, MidiSeqPtr tmap);
61  virtual ~MidiMapper();
62 
63  virtual void AtPos (const ARMusicalObject * ev, EventType type);
64 
65  void End();
66  void Clear();
67 };
68 
69 
70 #endif
ARMusicalVoice
The class for GUIDO sequence, list of timepositions of events of a stream.
Definition: ARMusicalVoice.h:76
MidiMapper::Note
virtual void Note(const ARMusicalObject *ev)
duration
GuidoDate duration(CGRHandler inHandleGR)
Returns the music duration of a score.
Fraction
Numerator and denominator.
Definition: Fraction.h:23
TimeUnwrap::EventType
EventType
Definition: TimeUnwrap.h:51
MidiMapper::AtPos
virtual void AtPos(const ARMusicalObject *ev, EventType type)
MidiMapper::~MidiMapper
virtual ~MidiMapper()
MidiMapper::MidiMapper
MidiMapper(ARMusicalVoice *voice, MidiLight *midi, const Guido2MidiParams *p, int chan, MidiSeqPtr outseq, MidiSeqPtr tmap)
Guido2MidiParams
A data structure containing the settings for MIDI conversion.
Definition: GUIDO2Midi.h:33
MidiMapper::Event
virtual void Event(const ARMusicalObject *ev, EventType type)
MidiMapper
Definition: MIDIMapper.h:27
MidiMapper::End
void End()
MidiMapper::Clear
void Clear()
MidiMapper::Rest
virtual void Rest(const ARMusicalObject *ev)
ARMusicalObject
The base class for all AR objects. It contains all musical information : duration and time position.
Definition: ARMusicalObject.h:33
TimeUnwrap
Definition: TimeUnwrap.h:29

Guido Project Copyright © 2019 Grame-CNCM