Subversion Repositories DIN Is Noise

Rev

Rev 2099 | Rev 2101 | 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;
2099 jag 44
  float lastsnapfreq;
45
 
1528 jag 46
  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
47
 
48
  // range is microtonal space between two notes
49
  int num_ranges;
50
  int last_range;
51
 
52
  scale_listener* scl;
53
 
54
  scale_info () {
2099 jag 55
    lo_tonic = tonic = hi_tonic = lastsnapfreq = 0.0f;
1528 jag 56
    num_notes = last_note = second_last_note = 0;
57
    num_ranges = 0;
58
    last_range = -1;
59
    western = 0;
60
    scl = 0;
61
  }
62
 
63
  int set_tonic (float f);
64
 
65
  int load_scale (const std::string& n);
66
  int save_scale ();
67
 
68
  void update (checkbutton* cb_notes);
69
  void update_settings ();
70
 
71
};
72
 
1719 jag 73
extern scale_info all_notes;
74
 
1528 jag 75
#endif