Author Topic: midi offset and EDIT: globaltune...  (Read 13014 times)

Xavier

  • Administrator
  • Hero Member
  • *
  • Posts: 2259
    • View Profile
Re: midi offset
« Reply #15 on: December 29, 2017, 09:37:34 AM »

also on a related note: is there any reason why the frequency array in waves2.c is not declared as a const? if a scala file is used that array is not manipulated i think. would that not be more efficient? (my tuneFactor should also be const :-))

On microcontroller, const are not moved to RAM, they stay on the flash memory, so they're slower. That's fine for your tuneFactor, but not for value used in the real time audio engine.

lokki

  • Sr. Member
  • ****
  • Posts: 383
    • View Profile
Re: midi offset
« Reply #16 on: December 29, 2017, 10:33:43 AM »
On microcontroller, const are not moved to RAM, they stay on the flash memory, so they're slower. That's fine for your tuneFactor, but not for value used in the real time audio engine.

i see. i often use const on arduino, because i though it would speed up things :-) but arduino may be different...will do some benchmarks :-)
« Last Edit: December 29, 2017, 11:04:56 AM by lokki »

Xavier

  • Administrator
  • Hero Member
  • *
  • Posts: 2259
    • View Profile
Re: midi offset
« Reply #17 on: December 29, 2017, 03:13:52 PM »

Because of the page change, you may have missed the latest message of page 1.

lokki

  • Sr. Member
  • ****
  • Posts: 383
    • View Profile
Re: midi offset
« Reply #18 on: December 29, 2017, 03:55:55 PM »
thanks, i saw it. i'm abroad playing for a few days, will report back when i get a chance to try it out. cheers

lokki

  • Sr. Member
  • ****
  • Posts: 383
    • View Profile
Re: midi offset
« Reply #19 on: January 02, 2018, 08:34:57 PM »
hi xavier,

i tried moving the usb initialization up before the osc init but it makes no difference. but also no freezes :-)

i then tried with your static void suggestion in osc.cpp and it works! (well partially)

with:

Code: [Select]
void Osc::tune( int tuneconfig) {
float  tuneFactor[] = {435.0,435.5,436.0,436.5,437.0,437.5,438.0,438.5,439.0,439.5,440.0,440.5,441.0,441.5,442.0,442.5,443.0,443.5,444.0} ;
float frecAdjust = tuneFactor[tuneconfig] / 440.0f;

 for (int k=0; k<127; k++) {
midiNoteTunedFrequency[k]= frequency[k] * frecAdjust;
 }
   // Set frequencyToUse  to frequency (no Scala scale defined)
        frequencyToUse = midiNoteTunedFrequency;
}

and the corresponding declaration in the public section in osc.h i have globaltune working after reboot! yehaa! i put a call to Osc::tune in preenFM.cpp at line 145 as you suggested.

i also tried to intercept when a new value is changed in synthstate.cpp like this:

Code: [Select]
   if (fullState.midiConfigValue[fullState.menuSelect] == MIDICONFIG_GLOBAL_TUNE) {
Osc::tune(this->fullState.midiConfigValue[MIDICONFIG_GLOBAL_TUNE]);
}

but i get no realtime change. maybe i am using the variable addressing wrongly? (this is the part where i am still confused,hehe) or line 1029 is not the right place?

EDIT: it is the right place, because tuning is actually changing once i am in the menu and adjust globaltune. the only problem is it is a fixed value it changes to, i'm guessing the array nr. that represents MIDICONFIG_GLOBAL_TUNE and not the actual value i am changing...

anyhow, this is already a huge step forward, so thanks heaps for your help!!
« Last Edit: January 02, 2018, 08:49:59 PM by lokki »

lokki

  • Sr. Member
  • ****
  • Posts: 383
    • View Profile
Re: midi offset and EDIT: globaltune...
« Reply #20 on: January 06, 2018, 09:49:09 AM »
xavier,

how do i check if i have global tune selected in the menu?

so that i don't call the Osc::tune function all the time when i am in the menu.

in other words i'm trying to do something like this:

Code: [Select]
if (selectedMenu == MIDICONFIG_GLOBAL_TUNE) {
Osc::tune(fullState.midiConfigValue[fullState.menuSelect]);

i don't fully understand because the place you gave me in code (line 1029 in SynthState.cpp) is for encoder 3 (the one i am turning to adjust the value) how do i check the position of the first encoder? (since i assume this corresponds to MIDIONFIG_GLOBAL_TUNE) hmm...

EDIT: to clarify, a version without the if-statement works perfectly well, but i thought it is bad practice to call the function even when other settings are changed...
« Last Edit: January 06, 2018, 12:49:52 PM by lokki »