Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Have array elements sit on the pentatonic scale #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/SortSound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,24 @@ void SoundAccess(size_t i)
/// function mapping array index (normalized to [0,1]) to frequency
static double arrayindex_to_frequency(double aindex)
{
return 120 + 1200 * (aindex*aindex);
double low_c = 65.406;
double low_d = 73.416;
double low_e = 82.407;
double low_g = 97.999;
double low_a = 110;

int index = aindex * 40;
float tone;
switch (index % 5) {
case 0: tone = low_c; break;
case 1: tone = low_d; break;
case 2: tone = low_e; break;
case 3: tone = low_g; break;
case 4: tone = low_a; break;
}
return tone * ((index / 5) + 1);

// return 120 + 1200 * (aindex*aindex);
}

/// reset internal sound data (called from main thread)
Expand Down
8 changes: 4 additions & 4 deletions src/WMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ WMain::WMain(wxWindow* parent)
infoTextctrl->Hide();

// program icon
{
{
#include "sos.xpm"
SetIcon( wxIcon(sos) );
}
Expand All @@ -57,8 +57,8 @@ WMain::WMain(wxWindow* parent)
sortview->FillInputlist(inputTypeChoice);
sortview->FillData(0, 100);
inputTypeChoice->SetSelection(0);
arraySizeSlider->SetValue(100);
SetArraySize(100);
arraySizeSlider->SetValue(40);
SetArraySize(40);

// insert quicksort pivot rules into wxChoice
for (const wxChar** pt = g_quicksort_pivot_text; *pt; ++pt)
Expand All @@ -79,7 +79,7 @@ WMain::WMain(wxWindow* parent)
// Set the audio format
sdlaudiospec.freq = 44100;
sdlaudiospec.format = AUDIO_S16SYS;
sdlaudiospec.channels = 1; /* 1 = mono, 2 = stereo */
sdlaudiospec.channels = 2; /* 1 = mono, 2 = stereo */
sdlaudiospec.samples = 4096; /* Good low-latency value for callback */
sdlaudiospec.callback = SoundCallback;
sdlaudiospec.userdata = sortview;
Expand Down