Author Topic: global tune, midi-offset for presets and more...  (Read 4651 times)

lokki

  • Sr. Member
  • ****
  • Posts: 383
    • View Profile
global tune, midi-offset for presets and more...
« on: August 13, 2017, 11:08:14 PM »
some suggestions:

-it would be great to have a global tuning setting, something like 435 to 448 in the global menu that tunes the preenfm to a reference a. nowadays more and more music is 442.
-a preset based midi offset would be great, in the range of -24 to +24 halftones (-+ 2 octaves). this is a feature found on many hardware synths, and would be very handy.

-i added cc3 to the matrix source, easy enough. but i thought it could be nice to have a user_cc value that you can set in the global menu and that will then be available in the modmatrix. that way everybody can define an individual cc for modulation, again very handy. i tried to implement this, but failed :-(

i would attempt the first two, but would need some ideas as to where the midi to frequency is happening in the code, global-tune would just be a constant fractional value added to the midi note.

for preset based midi offset the main question is where to put it in the menu...from there again it would only be an offset added to midinote...

lokki

  • Sr. Member
  • ****
  • Posts: 383
    • View Profile
Re: global tune, midi-offset for presets and more...
« Reply #1 on: August 14, 2017, 11:02:52 AM »
i see now, that there is a possibility to adjust tuning when you use a scala file.

still think that a global tune based on a=440 would be very useful.

lokki

  • Sr. Member
  • ****
  • Posts: 383
    • View Profile
Re: global tune, midi-offset for presets and more...
« Reply #2 on: August 14, 2017, 02:53:19 PM »
for preset based midi offset the main question is where to put it in the menu...from there again it would only be an offset added to midinote...

it should go after the filter type in the engine menu i think. so i have to search for it in the code... :-)

Xavier

  • Administrator
  • Hero Member
  • *
  • Posts: 2257
    • View Profile
Re: global tune, midi-offset for presets and more...
« Reply #3 on: August 14, 2017, 03:37:29 PM »
.... would need some ideas as to where the midi to frequency is happening in the code, global-tune would just be a constant fractional value added to the midi note.

Here is the newNote function where the frequency array is used.
https://github.com/Ixox/preenfm2/blob/master/src/synth/Osc.cpp#L180
(+ glideToNote function just bellow).

In the Osc.cpp init function, it should be easy to modify frequencies. Multiply all 128 values by 442/440 and you'll get a 442 hertz reference.

The array is one of the pre-generated array in :
https://github.com/Ixox/preenfm2/blob/master/waveforms/waves.c

Xavier

lokki

  • Sr. Member
  • ****
  • Posts: 383
    • View Profile
Re: global tune, midi-offset for presets and more...
« Reply #4 on: August 15, 2017, 12:54:16 AM »
thanks for the heads up. i think i did global tune! have to check tomorrow with the unit. while i was at it, i also tried the midi-offset thing i described. i added another parameterrowengine for the midi offset and it compiles fine. so the ui part should work. i'm not sure how to get a variable from my new entry though. where is for example oscillator->detune (used in Osc.cpp) defined? i don't see how the detune menu affects this variable (or where). 

sorry for the maybe silly questions.

Xavier

  • Administrator
  • Hero Member
  • *
  • Posts: 2257
    • View Profile
Re: global tune, midi-offset for presets and more...
« Reply #5 on: August 15, 2017, 03:21:43 PM »

Cool for the global tune !  :)

oscillator structure is definied here :
https://github.com/Ixox/preenfm2/blob/master/src/synth/Common.h#L324
This structure is used in the global Synth param structure :
https://github.com/Ixox/preenfm2/blob/master/src/synth/Common.h#L398
Then this global structure variable is defined at the instrument level here :
https://github.com/Ixox/preenfm2/blob/master/src/synth/Timbre.h#L159
(I need to get rid of the space/tab problem, indentation is not nice in github ;) )

Adding a new parameterrowengine is not easy, it will make your memory mapping incompatible with the current presets saved on your USB.
I have this problem for a very long time so that's why convertMemoryToParam and convertParamToMemory functions are for :)
https://github.com/Ixox/preenfm2/blob/master/src/filesystem/PreenFMFileType.cpp#L252

Xavier

lokki

  • Sr. Member
  • ****
  • Posts: 383
    • View Profile
Re: global tune, midi-offset for presets and more...
« Reply #6 on: August 15, 2017, 08:20:36 PM »
haha, this seems to be all way over my head... globaltune does not work on the preenfm when i test it now. if i set it to a constant offest value it works. i took a different approach and added a globalTune float variable in osc.cpp and changed the line (and all others that should be affected):

oscState->mainFrequency = frequencyToUse[note]  * oscillator->frequencyMul * (1.0f + oscillator->detune * .05f);

to

oscState->mainFrequency = frequencyToUse[note] *  globalTune * oscillator->frequencyMul * (1.0f + oscillator->detune * .05f);

if i set globalTune = 4.0f in the osc init function it works as expected, everything is tuned higher.

however i tried (naively i think) to access the global_tune menu entry (that i defined in menu.h and menu.cpp) like this:

this->synthState->fullState.midiConfigValue[MIDICONFIG_GLOBAL_TUNE]  and i did something like this:

globalTune = (4400.0f + (this->synthState->fullState.midiConfigValue[MIDICONFIG_GLOBAL_TUNE]  - 50)) / 4400.f  (globaltune is defined from 0 to 126 with 50 as 440hz. this should give me 0.1 resolution on the frequency from 435 to 447.6.

this does just not do anything.

even setting

globalTune = this->synthState->fullState.midiConfigValue[MIDICONFIG_GLOBAL_TUNE]

does not do anything, and that should yield extreme results.

so it seems that my variable access to globaltune is somehow wrong, or the value is not set at all.

menu.cpp entry looks like this:

 {
                "Glb Tune: ",
                "globaltune",
                127,
                0
        },



in other words, i have no idea what i am doing and i am sorry to waste so much of your time. :-(