Skip to content

sustainablelab/game-gui-3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Install basic build tools:

sudo apt install make gcc pkg-config exuberant-ctags

Install SDL2 dependencies:

sudo apt install libsld2-dev libsdl2-ttf-dev

Build:

make

Run:

./build/main

Play:

Key                                      | Action
---                                      | ------
j                                        | Play a single note
R                                        | Play looping notes forever (until j or r is pressed)
r                                        | Drone forever (until j or R is pressed)
Space                                    | Increase harmonics
Shift + Space                            | Decrease harmonics
Mouse move in X away/towards from center | Increase/decrease ratio of tone to noise
Mouse move in Y up/down                  | Continuous pitch change up/down
1 | A
2 | A#
3 | B
4 | C
5 | C#
6 | D
7 | D#
8 | E
9 | F
0 | F#
- | G
= | G#
Backspace | A (octave)

Pitch:

Mouse Y position Fundamental frequency [Hz] Keypress
Top 220 -
Center 110 Backspace
Quarter 55 1
Bottom 0 -

The maximum possible fundamental frequency is achieved by moving the mouse to the very top of the screen. This is 220Hz. Of course the tone is harmonic rich (especially if you hit the Spacebar a lot), so there are higher frequencies present. At mid-screen (half-way down from the top), the frequency is 110Hz, and at the bottom of the screen it is 0Hz. In otherwords, screen position linearly scales frequency.

You can jump the mouse to the 12 equal-tempered frequencies and the octave, making a total of 13 notes playable with the keyboard. These notes range from a quarter of the screen, 55 Hz, up to the middle of the screen, 110 Hz (the octave).

    constexpr float _0 = 1.0;
    constexpr float _1 = 1.0594630943592953;
    constexpr float _2 = 1.122462048309373;
    constexpr float _3 = 1.189207115002721;
    constexpr float _4 = 1.2599210498948732;
    constexpr float _5 = 1.3348398541700344;
    constexpr float _6 = 1.4142135623730951;
    constexpr float _7 = 1.4983070768766815;
    constexpr float _8 = 1.5874010519681994;
    constexpr float _9 = 1.681792830507429;
    constexpr float _10 = 1.7817974362806785;
    constexpr float _11 = 1.8877486253633868;
    constexpr float _12 = 2.0;
    constexpr float _12th_root_of_2[] = {_0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11,_12};

About

Audio synthesis using SDL sound driver callbacks

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published