2009-08-26 23:09:30 -04:00
|
|
|
/* This file is part of Evoral.
|
|
|
|
* Copyright (C) 2008 Dave Robillard <http://drobilla.net>
|
|
|
|
* Copyright (C) 2009 Paul Davis
|
2009-10-14 12:10:01 -04:00
|
|
|
*
|
2009-08-26 23:09:30 -04:00
|
|
|
* Evoral is free software; you can redistribute it and/or modify it under the
|
|
|
|
* terms of the GNU General Public License as published by the Free Software
|
|
|
|
* Foundation; either version 2 of the License, or (at your option) any later
|
|
|
|
* version.
|
2009-10-14 12:10:01 -04:00
|
|
|
*
|
2009-08-26 23:09:30 -04:00
|
|
|
* Evoral is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
|
2009-10-14 12:10:01 -04:00
|
|
|
*
|
2009-08-26 23:09:30 -04:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "evoral/midi_util.h"
|
|
|
|
#include <cstdio>
|
|
|
|
|
|
|
|
namespace Evoral {
|
|
|
|
|
|
|
|
std::string
|
|
|
|
midi_note_name (uint8_t val)
|
|
|
|
{
|
|
|
|
if (val > 127) {
|
|
|
|
return "???";
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char* notes[] = {
|
|
|
|
"c",
|
|
|
|
"c#",
|
|
|
|
"d",
|
|
|
|
"d#",
|
|
|
|
"e",
|
|
|
|
"f",
|
|
|
|
"f#",
|
|
|
|
"g",
|
2010-02-08 14:36:25 -05:00
|
|
|
"g#",
|
2009-08-26 23:09:30 -04:00
|
|
|
"a",
|
|
|
|
"a#",
|
2010-02-08 14:36:25 -05:00
|
|
|
"b"
|
2009-08-26 23:09:30 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
int octave = val/12;
|
|
|
|
static char buf[8];
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-08-26 23:09:30 -04:00
|
|
|
val -= octave*12;
|
|
|
|
|
|
|
|
snprintf (buf, sizeof (buf), "%s%d", notes[val], octave);
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|