A very very simple orgel.
orgel, a very very simple orgel program using PWM.
To generate sound you need to connect a sounder(speaker?) to
D2 (PTD4) and GND.
orgel (オルゴール) PWMを使用した、とてもとても単純なオルゴール。
音を出すのには D2(PTD4) と GND にサウンダー(スピーカー?) を接続してください。
You can change tune by editing tune.h.
There you need to specify tempo,
which defines how many 4th notes per minute.
Note: each tones in tune is a 16th.
曲を変えるのには tune.h を編集してください。
最初に tempo を設定してください。
tempo は4分音符が1分間に何回かを指定します。
ノート:tune.h で指定する音はそれぞれ16分音符となります。
float tempo = 100.0 ;
Above code is saying the tempo is 100 of 4th notes per minute.
上記のコードでは♩=100 という設定になります。
Then you need to specify notes to compose the tune by
writing following code.
次に下記のコードで、曲を構成する音を記述してください。
unsigned char note[] = { // enter notes here as decimal values } ;
Usable tone values are
0 for rest
1..49 for note from A3 to A7
These are index value in the note[] array.
Note: for values of each tone, please refer to tone.h and tune.h
使用可能な音の値は
0 休符
1..49 A3(ラ3) から A7(ラ7)
となっています。
これらは配列 note[] のインデックス値になります。
ノート:各音の具体的な値は tone.h と tune.h を御参照ください。
As you can imagine,
note value + 1 = #
note value - 1 = ♭
For example
G4 = 10
G♭4 = 9
G#4 = 11
想像つかれると思いますが、インデックス値に1を足すと#
インデックス値から1を引くと♭の音程になります。
tone.h@0:b1f4db5e5887, 2015-07-11 (annotated)
- Committer:
- Rhyme
- Date:
- Sat Jul 11 16:08:04 2015 +0000
- Revision:
- 0:b1f4db5e5887
- Child:
- 1:f0f27eb31eec
Sample tune, Greensleeves added
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Rhyme | 0:b1f4db5e5887 | 1 | #ifndef TONE_H |
Rhyme | 0:b1f4db5e5887 | 2 | #define TONE_H |
Rhyme | 0:b1f4db5e5887 | 3 | |
Rhyme | 0:b1f4db5e5887 | 4 | int tone_us[] = { |
Rhyme | 0:b1f4db5e5887 | 5 | 0, // for rest |
Rhyme | 0:b1f4db5e5887 | 6 | 4546, // A3 |
Rhyme | 0:b1f4db5e5887 | 7 | 4290, // A#3 |
Rhyme | 0:b1f4db5e5887 | 8 | 4050, // B3 |
Rhyme | 0:b1f4db5e5887 | 9 | 3822, // C4 |
Rhyme | 0:b1f4db5e5887 | 10 | 3606, // C#4 |
Rhyme | 0:b1f4db5e5887 | 11 | 3405, // D4 |
Rhyme | 0:b1f4db5e5887 | 12 | 3214, // D#4 |
Rhyme | 0:b1f4db5e5887 | 13 | 3034, // E4 |
Rhyme | 0:b1f4db5e5887 | 14 | 2864, // F4 |
Rhyme | 0:b1f4db5e5887 | 15 | 2703, // F#4 |
Rhyme | 0:b1f4db5e5887 | 16 | 2551, // G4 |
Rhyme | 0:b1f4db5e5887 | 17 | 2408, // G#4 |
Rhyme | 0:b1f4db5e5887 | 18 | 2273, // A4 |
Rhyme | 0:b1f4db5e5887 | 19 | 2145, // A#4 |
Rhyme | 0:b1f4db5e5887 | 20 | 2025, // B4 |
Rhyme | 0:b1f4db5e5887 | 21 | 1911, // C5 |
Rhyme | 0:b1f4db5e5887 | 22 | 1804, // C#5 |
Rhyme | 0:b1f4db5e5887 | 23 | 1703, // D5 |
Rhyme | 0:b1f4db5e5887 | 24 | 1607, // D#5 |
Rhyme | 0:b1f4db5e5887 | 25 | 1517, // E5 |
Rhyme | 0:b1f4db5e5887 | 26 | 1432, // F5 |
Rhyme | 0:b1f4db5e5887 | 27 | 1351, // F#5 |
Rhyme | 0:b1f4db5e5887 | 28 | 1276, // G5 |
Rhyme | 0:b1f4db5e5887 | 29 | 1204, // G#5 |
Rhyme | 0:b1f4db5e5887 | 30 | 1136, // A5 |
Rhyme | 0:b1f4db5e5887 | 31 | 1073, // A#5 |
Rhyme | 0:b1f4db5e5887 | 32 | 1012, // B5 |
Rhyme | 0:b1f4db5e5887 | 33 | 956, // C6 |
Rhyme | 0:b1f4db5e5887 | 34 | 902, // C#6 |
Rhyme | 0:b1f4db5e5887 | 35 | 851, // D6 |
Rhyme | 0:b1f4db5e5887 | 36 | 804, // D#6 |
Rhyme | 0:b1f4db5e5887 | 37 | 758, // E6 |
Rhyme | 0:b1f4db5e5887 | 38 | 716, // F6 |
Rhyme | 0:b1f4db5e5887 | 39 | 676, // F#6 |
Rhyme | 0:b1f4db5e5887 | 40 | 638, // G6 |
Rhyme | 0:b1f4db5e5887 | 41 | 602, // G#6 |
Rhyme | 0:b1f4db5e5887 | 42 | 568, // A6 |
Rhyme | 0:b1f4db5e5887 | 43 | 536, // A#6 |
Rhyme | 0:b1f4db5e5887 | 44 | 506, // B6 |
Rhyme | 0:b1f4db5e5887 | 45 | 478, // C7 |
Rhyme | 0:b1f4db5e5887 | 46 | 451, // C#7 |
Rhyme | 0:b1f4db5e5887 | 47 | 426, // D7 |
Rhyme | 0:b1f4db5e5887 | 48 | 402, // D#7 |
Rhyme | 0:b1f4db5e5887 | 49 | 379, // E7 |
Rhyme | 0:b1f4db5e5887 | 50 | 358, // F7 |
Rhyme | 0:b1f4db5e5887 | 51 | 338, // F#7 |
Rhyme | 0:b1f4db5e5887 | 52 | 319, // G7 |
Rhyme | 0:b1f4db5e5887 | 53 | 301, // G#7 |
Rhyme | 0:b1f4db5e5887 | 54 | 284, // A7 |
Rhyme | 0:b1f4db5e5887 | 55 | } ; |
Rhyme | 0:b1f4db5e5887 | 56 | |
Rhyme | 0:b1f4db5e5887 | 57 | int num_tones = 50 ; |
Rhyme | 0:b1f4db5e5887 | 58 | |
Rhyme | 0:b1f4db5e5887 | 59 | #endif /* TONE_H */ |