So... it plays a sound on a key press with a pitch determined by the key?
I think it would be a good idea (if not just somewhat polite) if you were to put that really long list in that post above inside spoiler tags:
[spoiler=Like this!]*hidden content here*[/spoiler] :)
Hey all, Update Here(done with the cryptocoins btw):
I recently found some time, in 3.5 years since first publishing my app on the Mac Appstore, to fix the sound files for ToneBoards. For those interested, you can now download the new tones on github (https://github.com/kipbits/ToneBoards/releases/tag/1.0.2). Install by dragging and dropping the contents of the TONESv15 into your toneboards app package TONESv10 folder (sorry, I'm on limited time, and can't make it fancy).
...I still plan to port to linux(recently been playing with MX Linux (https://mxlinux.org)) although stuff just keeps getting in the way. Anyway, I thought I'd share these before I forgot about them. These new sounds are designed to play better on small laptop speakers, especially the base notes! Maybe I'll provide an explanation of how I made them later.
...It's a shame that during the apple dev publishing process, I lost some commented-out code, which could perhaps help me in porting to linux. Perhaps it was my fault, although I just haven't brought myself to research and rewrite it yet(Also, I'm still looking for a solution to my problem finger).
...And sorry no demo for the moment(I can't spare my browser tabs right now, and quicktime + toneboards seam to kick it over the edge. Just wanted to post this before I forget.
I really would like to port this to Linux, though I'm kind of sad that there are no linux distros that support Miller Columns, and Firefox's bookmark system is all screwed up... Also, definitely still sucks that the doctors refuse to fix my finger(healthcare is too expensive anyway, it's probably better it just stays broken).
...I guess I can at least post some wikipedia links to the basics concepts underpinning my sound-files tweaking:
Ramp function (https://en.wikipedia.org/wiki/Ramp_function)
Harmonic series (https://en.wikipedia.org/wiki/Harmonic_series_(mathematics))
Basel problem (https://en.wikipedia.org/wiki/Basel_problem)
Sigmoid function (https://en.wikipedia.org/wiki/Sigmoid_function)/Logistic function (https://en.wikipedia.org/wiki/Logistic_function)
...also I found some notes; they could perhaps be useful to someone:
https://en.wikipedia.org/wiki/Overtone
overtones harmonics
fundamental 1st
1st 2nd +1 octave
2nd 3rd
3rd 4th +2 octaves
4th 5th
5th 6th
6th 7th
7th 8th +3 octaves
8th 9th
9th 10th
10th 11th
11th 12th
12th 13th
13th 14th
14th 15th
15th 16th +4 octaves
...
31st 32nd +5
63 64 +6
127 128 +7
https://www.historicaltuning.com/Harmonics.html
n∑_i=1(i) = 1+2+3+...+n = n(n+1)/2
1 1
2 3
3 6
4 10
5 15
6 21
7 28
8 36
9 45
10 55
11 66
12 78
13 91
14 105
15 120
16 136
17 153
18 171
19 190
20 210
(numharmonics+1-h)/(numharmonics*(numharmonics+1)/2)
fundamental*(i)/256 + harmonics*(256-i)/256
https://en.wikipedia.org/wiki/Lipps–Meyer_law
https://en.wikipedia.org/wiki/Harmonic_series_(mathematics)
https://en.wikipedia.org/wiki/Euler–Mascheroni_constant
https://en.wikipedia.org/wiki/Harmonic_number
https://en.wikipedia.org/wiki/Recurrence_relation
https://en.wikipedia.org/wiki/Harmonic_series_(mathematics)#p-series
y=ln(x+0.5)+0.5772156649... or y=ln(x)+0.5772156649...+1/(2x)+1/(12x^2)
//lowest note is 5.75 octaves below middle A
hz keyboard mytone#
440 middle A 138
220 -1 114
110 -2 90
55 -3 66
27.5 -4 42 _20hz lower limit_
13.75 -5 18
6.875 -6 -6
https://en.wikipedia.org/wiki/Riemann_zeta_function
https://en.wikipedia.org/wiki/Basel_problem
S x^-2 = -x^-1
y=-1/(x+0.6)+1.65
440 138 middle A
880 162 +1
1760 186 +2
3520 210 +3
7040 234 +4
14080 258 +5
y=-1/(x+0.6)+1.65
0=-255/(255+0.6)+c
i:0-255
y=255/(x+1)-1
https://en.wikipedia.org/wiki/Sigmoid_function
y=L/(1+e^(-k(x-xº)))
y=255/(1+e^(-8/128(x-128)))
I had a little time, and made a quick demos: See Attachment Below
...I still want to port to Linux(though not sure when it will happen).
...maybe I should just ploop down my code for the update here for all to use(won't do any good hidden away):
#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>
#include "ResourcePath.hpp"
#include <cmath>
#include <iostream>
#include <string>
//const unsigned SAMPLES = 22050;//44100;//
const unsigned SAMPLE_RATE = 44100;//44112
const unsigned AMPLITUDE = 30000;
const double TWO_PI = 6.28318530717958647692;
const double increment = 440./44100;//middle A
const int numharmonics = 128;//1;//2;//4;//8;//16;//32;//64;//128;
const float EulerMasch = 0.6;//0.5772;//0.5772156649...//audible hum numharmonics=2
const float hoffset = 0.6;//0.5;//still audible hum numharmonics=2
const float bapprox = 1.65;
const double lgrow = -8.0/102.0;//-16.0/102.0;//-16.0/128.0;//-8.0/128.0;
const short lmid = 102;//128;
const double lopt = 1.0;//lopt>0
//y = sin(2π*M*x) => ƒ = M <=> λ = 1/M
//M = (440/44100)*2^(i/24)
int main(int, char const**){
//double jmult = 1./2; // 1
//double jmult = 1./4; // 2
//double jmult = 1./8; // 3
//double jmult = 1./16; // 4 div 5
double jmult = 1./40; //this!//this!//this!//this!//this!//this!
short wfund = 0;
std::cout << "jmult: " << jmult << "\n\n";
for (int i=0; i<256; i++) {
int duration = (int) (jmult*SAMPLE_RATE/exp2((double) (i-138)/24));//jmult/m;//relative to middle A
double dur = (jmult*SAMPLE_RATE/exp2((double) (i-138)/24));//relative to middle A
//if (duration < 22051) {
//if (duration < 44101) {
if (duration < 88201) {
jmult *= 2;
duration = (int) (jmult*SAMPLE_RATE/exp2((double) (i-138)/24));//jmult/m;
dur = (jmult*SAMPLE_RATE/exp2((double) (i-138)/24));
}
double cycles = 440.*exp2((double) (i-138)/24)*dur/44100.;//relative to middle A
//std::cout << "tone_" << i << "\'s lambda is " << ((int) 1/m) << " samples long\n";
std::cout << "tone_" << i << " lambda " << dur << " : " << duration << " : " << " cycles: " << cycles << " # " << i - 138 << "\n";
float mlogistic = 1.0+exp(lgrow*(i-lmid));
unsigned durationSAMPS = duration;
sf::Int16 *myrawsamples = new sf::Int16[durationSAMPS];
double x = 0;
for (unsigned j = 0; j < durationSAMPS; j++) {//build//raw//build//raw//build//raw//build//raw//build//raw
//myrawsamples[j] = AMPLITUDE * sin(x*TWO_PI);
//myrawsamples[j] = AMPLITUDE * sin(x*TWO_PI)*i/255; //fundamental*(i)/256 + harmonics*(256-i)/256
//myrawsamples[j] = AMPLITUDE * sin(x*TWO_PI)*wfund/138; //fundamental*(i)/256 + harmonics*(256-i)/256
//myrawsamples[j] = AMPLITUDE * sin(x*TWO_PI)*i/255;
//myrawsamples[j] = AMPLITUDE * sin(x*TWO_PI)*(255-255/(i+1))/255;
myrawsamples[j] = AMPLITUDE * sin(x*TWO_PI)/pow(mlogistic, lopt);//pow (double base, double exponent)
//y=255/(1+e^(-8/128(x-128)))
for(int h=1; h<numharmonics+1; h++){
//myrawsamples[j] += AMPLITUDE * sin(h*x*TWO_PI)/numharmonics;
//myrawsamples[j] += AMPLITUDE * sin(h*x*TWO_PI)*(numharmonics+1-h)/(numharmonics*(numharmonics+1)/2);
//harmonics += AMPLITUDE * sin(h*x*TWO_PI)*(numharmonics+1-h)/(numharmonics*(numharmonics+1)/2);
//myrawsamples[j] += AMPLITUDE * sin(h*x*TWO_PI)*(numharmonics+1-h)/(numharmonics*(numharmonics+1)/2)*(256-i)/256; //fundamental*(i)/256 + harmonics*(256-i)/256
//myrawsamples[j] += AMPLITUDE * sin(h*x*TWO_PI)/h/(log(h + hoffset)+EulerMasch)*(255-i)/255; //fundamental*(i)/256 + harmonics*(256-i)/256
//if (wfund < 138) {
//myrawsamples[j] += AMPLITUDE * sin(h*x*TWO_PI)/h/(log(h + hoffset)+EulerMasch)*(138-wfund)/138;//hseriesbest!
//myrawsamples[j] += AMPLITUDE * sin(h*x*TWO_PI)/numharmonics*(138-wfund)/138;
//myrawsamples[j] +=
// AMPLITUDE * sin(h*x*TWO_PI)*(numharmonics+1-h)/(numharmonics*(numharmonics+1)/2)*(138-wfund)/138;
//myrawsamples[j] += AMPLITUDE * sin(h*x*TWO_PI)/h/h/(-1/(h+hoffset)+1.65)*(138-wfund)/138;//y=-1/(x+0.6)+1.65
//}
//myrawsamples[j] += AMPLITUDE * sin(h*x*TWO_PI)/h/h/(-1/(h+hoffset)+1.65)*(255-i)/255;
//myrawsamples[j] += AMPLITUDE * sin(h*x*TWO_PI)/h/h/(-1/(h+hoffset)+bapprox)*(255/(i+1))/255;
myrawsamples[j] += AMPLITUDE * sin(h*x*TWO_PI)/h/h/(-1/(h+hoffset)+bapprox)*(1-1/pow(mlogistic, lopt));
//y=255/(1+e^(-8/128(x-128)))
}
x += increment*exp2((double) (i-138)/24);//mNOTESarray/12);//relative to middle A
//lowest note is 5.75 octaves below middle A
}
sf::SoundBuffer *Buffer = new sf::SoundBuffer();
if (!Buffer->loadFromSamples(myrawsamples, durationSAMPS, 1, SAMPLE_RATE)) {
std::cerr << "INITIALIZATION failed!" << std::endl;
return 1;
}
std::string outfilename = "tone_" + std::to_string(i) + "_.ogg";//outfiles/
std::cout << outfilename << " at " << resourcePath() << "\n\n";
Buffer->saveToFile(resourcePath() + outfilename);//___
if (wfund < 138) {
wfund++;
}
}
return EXIT_SUCCESS;
}