From 5205bdb94eb970adb629f0e1b1b7d3fd994837a4 Mon Sep 17 00:00:00 2001 From: James Harlow Date: Thu, 1 Aug 2013 18:50:36 +0100 Subject: [PATCH] Have arary elements sit on the pentatonic scale --- src/SortSound.cpp | 19 ++++++++++++++++++- src/WMain.cpp | 8 ++++---- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/SortSound.cpp b/src/SortSound.cpp index 672abb783..60e3ef106 100644 --- a/src/SortSound.cpp +++ b/src/SortSound.cpp @@ -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) diff --git a/src/WMain.cpp b/src/WMain.cpp index 961c182b3..d86ea705c 100644 --- a/src/WMain.cpp +++ b/src/WMain.cpp @@ -37,7 +37,7 @@ WMain::WMain(wxWindow* parent) infoTextctrl->Hide(); // program icon - { + { #include "sos.xpm" SetIcon( wxIcon(sos) ); } @@ -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) @@ -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;