Access variable that inside a class member function in a CPP file

I'm trying to access a variable that is declared and defined within a member function of a class, contained within a CPP file. I need to be able to see what the value of "eType" is every time parseEvent() is called. I've tried a number of things such as:

  • Moving eType to the MIDIFile.h header file
  • Declaring eType as extern and declare/defining it within the Arduino IDE
  • Creating a function within the MFTrack class that returns the value of eType and calling said function in Arduino IDE

All of these attempt produced errors. After spending several hours on this, I figure I need to seek out some help. I've included excerpts of the most important parts of the code.

Library: Google Code Archive - Long-term storage for Google Code Project Hosting.

MIDIFile.cpp Contains "eType" and getNextEvent(MIDIFile *mf, uint32_t elapsedTime);

void MFTrack::parseEvent(MIDIFile *mf)
// process the event from the physical file
{
	uint8_t	 eType;
	uint32_t eLen, mLen;
	sysex_event	sev;		// used for sysex callback function

	// now we have to process this event
	eType = mf->_fd.read();

	switch (eType)
	{
// ---------------------------- MIDI

	  // midi_event = any MIDI channel message, including running status
	  // Midi events (status bytes 0x8n - 0xEn) The standard Channel MIDI messages, where 'n' is the MIDI channel (0 - 15).
	  // This status byte will be followed by 1 or 2 data bytes, as is usual for the particular MIDI message. 
	  // Any valid Channel MIDI message can be included in a MIDI file.
	case 0x80 ... 0xBf:	// MIDI message with 2 parameters
	case 0xe0 ... 0xef:
		_mev.size = 3;
		_mev.data[0] = eType;
		_mev.channel = _mev.data[0] & 0xf;	// mask off the channel
		_mev.data[0] = _mev.data[0] & 0xf0;	// just the command byte
		_mev.data[1] = mf->_fd.read();
		_mev.data[2] = mf->_fd.read();
		DUMPS("[MID2] Ch: ");
		DUMP(_mev.channel);
		DUMPS(" Data: ");
		DUMPX(_mev.data[0]);
		DUMP(' ');
		DUMPX(_mev.data[1]);
		DUMP(' ');
		DUMPX(_mev.data[2]);
#if !DUMP_DATA
		if (mf->_midiHandler != NULL)
			(mf->_midiHandler)(&_mev);
#endif // !DUMP_DATA
	break;


bool MFTrack::getNextEvent(MIDIFile *mf, uint32_t elapsedTime)
// track_event = <time:v> + [<midi_event> | <meta_event> | <sysex_event>]
{
	uint32_t deltaT, elapsedTicks;

	// is there anything to process?
	if (_endOfTrack)
	  return(false);

	// move the file pointer to where we left off
	mf->_fd.seekSet(_startOffset+_currOffset);

	// work out new total elapsed time
	_elapsedTimeTotal += elapsedTime;
	elapsedTicks = _elapsedTimeTotal / mf->getMicrosecondDelta();

	// Get the DeltaT from the file in order to see if enough ticks have
	// passed for the event to be active. If not, just return without
	// saving the file pointer and we will go back to the same spot next time.
	deltaT = readVarLen(&mf->_fd);
	if (elapsedTicks < deltaT)
		return(false);

	// Adjust the total elapsed time. Note use of actual DeltaT to avoid 
	// accumulation of errors as we only check for elaspedTime being >= ticks,
	// giving positive biased errors every time.
	_elapsedTimeTotal -= (deltaT * mf->getMicrosecondDelta());

	DUMPS("\ndT: ");
	DUMP(deltaT);
	DUMP("\tET: ");
	DUMP(elapsedTicks);
	DUMP('\t');

	parseEvent(mf);

	// remember the offset for next time
	_currOffset = mf->_fd.curPosition() - _startOffset;

	return(true);
}

MIDIFile.cpp Contains the getNextEvent() function
```
**boolean MIDIFile::getNextEvent(void)
{
uint32_t elapsedTime;
uint8_t n;

// if we are paused we are paused!
if (_paused) return false;

// sync start all the tracks if we need to
if (!_syncAtStart)
{
	synchTracks();
	_syncAtStart = true;
}

// check if enough time has passed for a MIDI tick
elapsedTime = micros() - _lastEventCheckTime;
if (elapsedTime < _microsecondDelta)
	return false;	
_lastEventCheckTime = micros();			// save for next round of checks

if (_format != 0) DUMPS("\n-- TRK "); 

#if TRACK_PRIORITY
// process all events from each track first - TRACK PRIORITY
for (uint8_t i = 0; i < _trackCount; i++)
{
if (_format != 0) DUMPX(i);
// Limit n to be a sensible number of events in the loop counter
// When there are no more events, just break out
// Other than the first event, the other have an elapsed time of 0 (ie occur simultaneously)
for (n=0; n < 100; n++)
{
if (!_track[i].getNextEvent(this, (n==0 ? elapsedTime : 0)))
break;
}

	if ((n > 0) && (_format != 0))
		DUMPS("\n-- TRK "); 
}

#else // EVENT_PRIORITY**
**__ <strong>__**Arduino Code:**__</strong> __**
**void loop(void)
{
    int  err;

for (uint8_t i=0; i<ARRAY_SIZE(tuneList); i++)
{
  // reset LEDs
  digitalWrite(READY_LED, LOW);
  digitalWrite(SD_ERROR_LED, LOW);

  // use the next file name and play it
  SMF.setFilename(tuneList[i]);
  err = SMF.load();
  if (err != -1)
  {
	DEBUG("\nSMF load Error ");
	DEBUG(err);
	digitalWrite(SMF_ERROR_LED, HIGH);
	delay(WAIT_DELAY);
  }
  else
  {
	// play the file
	while (!SMF.isEOF())
	{
		if (SMF.getNextEvent())
		tickMetronome();
	}

	// done with this one
	SMF.close();
	midiSilence();

	// signal finsh LED with a dignified pause
	digitalWrite(READY_LED, HIGH);
	delay(WAIT_DELAY);
  }
}

}
__
```**__