~ubuntu-branches/ubuntu/quantal/muse/quantal

« back to all changes in this revision

Viewing changes to awl/utils.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessio Treglia
  • Date: 2011-08-12 11:16:41 UTC
  • mto: (1.1.9) (10.1.6 sid)
  • mto: This revision was merged to the branch mainline in revision 26.
  • Revision ID: james.westby@ubuntu.com-20110812111641-72iatqb9jomjejko
ImportĀ upstreamĀ versionĀ 2.0~beta2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//=============================================================================
 
2
//  Awl
 
3
//  Audio Widget Library
 
4
//  $Id:$
 
5
//
 
6
//  Copyright (C) 2002-2006 by Werner Schweer and others
 
7
//
 
8
//  This program is free software; you can redistribute it and/or modify
 
9
//  it under the terms of the GNU General Public License version 2.
 
10
//
 
11
//  This program is distributed in the hope that it will be useful,
 
12
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
//  GNU General Public License for more details.
 
15
//
 
16
//  You should have received a copy of the GNU General Public License
 
17
//  along with this program; if not, write to the Free Software
 
18
//  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
19
//=============================================================================
 
20
 
 
21
#include <QString>
 
22
 
 
23
#include "utils.h"
 
24
 
 
25
static const char* vall[] = {
 
26
      "c","c#","d","d#","e","f","f#","g","g#","a","a#","h"
 
27
      };
 
28
static const char* valu[] = {
 
29
      "C","C#","D","D#","E","F","F#","G","G#","A","A#","H"
 
30
      };
 
31
 
 
32
namespace Awl {
 
33
 
 
34
//---------------------------------------------------------
 
35
//   pitch2string
 
36
//---------------------------------------------------------
 
37
 
 
38
QString pitch2string(int v)
 
39
      {
 
40
      if (v < 0 || v > 127)
 
41
            return QString("----");
 
42
      int octave = (v / 12) - 2;
 
43
      QString o;
 
44
      o.sprintf("%d", octave);
 
45
      int i = v % 12;
 
46
      QString s(octave < 0 ? valu[i] : vall[i]);
 
47
      return s + o;
 
48
      }
 
49
}
 
50