Subversion Repositories DIN Is Noise

Rev

Rev 2009 | Rev 2099 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1528 jag 1
/*
2
* scale_info.h
2097 jag 3
* DIN Is Noise is copyright (c) 2006-2024 Jagannathan Sampath
1528 jag 4
* For more information, please visit http://dinisnoise.org/
5
*/
6
 
7
 
8
#ifndef __SCALE_INFO
9
#define __SCALE_INFO
10
 
11
#include <string>
12
#include <vector>
13
#include <map>
14
 
15
struct checkbutton;
16
struct scale_info;
17
 
18
struct scale_listener {
19
  virtual void scale_loaded () = 0;
20
  virtual void scale_changed () = 0;
21
  virtual void tonic_changed () = 0;
22
};
23
 
24
struct scale_info {
25
 
26
  std::string name; // name of scale
27
 
28
  float lo_tonic, tonic, hi_tonic;
29
 
30
  std::map <std::string, float> intervals; // custom intervals for this scale
31
 
32
  std::vector<std::string> notes; // notes of the scale
33
  int num_notes;
34
  int last_note;
35
  int second_last_note;
36
  void set_num_notes (int nn);
37
 
38
  struct nearest_note_t {
39
    std::string name;
40
    float freq;
41
    float distance;
42
    nearest_note_t () : freq (0), distance (0) {}
43
  } nearest_note;
44
 
45
  int western; // C = 0, C# = 1, D = 2, D# = 3, E = 4, F = 5, F# = 6, G = 7, G# = 8, A = 9, A# = 10, B = 11
46
 
47
  // range is microtonal space between two notes
48
  int num_ranges;
49
  int last_range;
50
 
51
  scale_listener* scl;
52
 
53
  scale_info () {
54
    lo_tonic = tonic = hi_tonic = 0.0f;
55
    num_notes = last_note = second_last_note = 0;
56
    num_ranges = 0;
57
    last_range = -1;
58
    western = 0;
59
    scl = 0;
60
  }
61
 
62
  int set_tonic (float f);
63
 
64
  int load_scale (const std::string& n);
65
  int save_scale ();
66
 
67
  void update (checkbutton* cb_notes);
68
  void update_settings ();
69
 
70
};
71
 
1719 jag 72
extern scale_info all_notes;
73
 
1528 jag 74
#endif