This commit is contained in:
2017-02-06 12:14:05 +01:00
parent 209c869eeb
commit 19a2260644
9 changed files with 60 additions and 43 deletions

View File

@@ -10,7 +10,7 @@ static const float lengths[10] = { 0.0f, 0.00390625f, 0.0078125f, 0.015625f, 0.0
static const Uint16 tempos[10] = { 13230, 8820, 6615, 5292, 4410, 3780, 3308, 2940, 2646, 2406 };
static const float periods[108] = { 1348.49207, 1272.80688, 1201.37, 1133.94214, 1070.29871, 1010.22772, 953.527893, 900.010376, 849.496887, 801.818176, 756.815613, 714.338745, 674.246033, 636.403564, 600.684875, 566.971069, 535.149475, 505.11377, 476.763947, 450.005249, 424.748352, 400.909088, 378.407806, 357.169373, 337.123016, 318.201782, 300.342438, 283.485535, 267.574738, 252.556885, 238.381973, 225.002625, 212.374176, 200.454544, 189.203888, 178.584702, 168.561508, 159.100876, 150.171234, 141.742767, 133.787354, 126.278458, 119.190987, 112.501305, 106.187096, 100.227272, 94.6019516, 89.2923508, 84.2807541, 79.5504379, 75.0856171, 70.8713837, 66.8936768, 63.139225, 59.5954933, 56.2506561, 53.0935478, 50.113636, 47.3009758, 44.6461754, 42.140377, 39.775219, 37.5428085, 35.4356918, 33.4468384, 31.5696125, 29.7977467, 28.1253281, 26.5467739, 25.056818, 23.650486, 22.3230877, 21.0701885, 19.8876095, 18.7714043, 17.7178459, 16.7234192, 15.7848072, 14.8988733, 14.0626631, 13.273387, 12.528409, 11.8252439, 11.1615429, 10.5350943, 9.94380569, 9.38570118, 8.85892296, 8.36171055, 7.89240265, 7.44943666, 7.03133202, 6.636693, 6.2642045, 5.91262197, 5.58077145, 5.26754713, 4.97190285, 4.69285059, 4.42946148, 4.18085527, 3.94620132, 3.72471833, 3.51566601, 3.3183465, 3.13210225, 2.95631051, 2.7903862 };
static class c_channel {
class c_channel {
private:
Uint8 volume{ 64 };
Uint8 octave{ 4 };
@@ -110,7 +110,7 @@ public:
return last_noise;
}
void set_song(const char* melody) {
int len = SDL_strlen(melody);
size_t len = SDL_strlen(melody);
SDL_memcpy(song, melody, len);
song[len] = 0;
pos = 0; volume = 64; octave = 4; tempo = 44100; default_length = 0.25f;
@@ -128,9 +128,6 @@ public:
static c_channel channels[4];
static int sign(int number) { return number > 0 ? 1 : -1; }
static bool samesign(int a, int b) { return (a > 0 && b > 0) || (a < 0 && b < 0); }
static void audio_callback(void* userdata, Uint8* stream, int len) {
Uint8 datum = 0;
for (int i = 0; i < len; i++) {