login

online now

We have 157 guests and no members online

search

 
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: Analog values

Analog values 1 year 4 months ago #855

Hi,

I'm creating a custom synthesizer using both synth and voice modes. Questions below:

Volume: I get errors when I try to use the setMasterAmplitude. I'm trying to use this to control the Voice amplitude, as there doesn't seem to be another way.

Values: There are many various manuals on the site, which can get confusing, as I'm constantly cross-referencing various items from different docs. I can't find anything on what the ranges are per function. Is there a handy guide for this? Some values seem to be related to Hertz, some are integers for frequencies, some are floats from .0 - 1.0f. and some more varied info. Anything here would help as I'm using Potentiometers to control these values. For example: voice->setFrequency( map(muxShield.analogReadMS(3,7), 0, 1023 , 5, 500)); This seems to work, but some other functions are way off.

setEnvelope: I would like to be able to modify the millisecond attack timing, decay and release. I'm confused as the values are listed as 'AT_2MS'. Is there a way to replace this with a float or integer?

Voice or Synth mode: Can I use both at the same time? For example can I put a v->begin(); and s->begin(); in void setup()? I get varied results, I'm wondering if it's just a bad idea to do so? I like the weird sounds I get sometime, but I don't want Ginsing to lock up on me.

Reset: What is the proper method to reset Ginsing? I've tried using the command GS.reset(); but I'mm not sure where to place it. I get varied results, none that seem to work. I've had a number of issues where the Ginsing will completely lockup with no sound output. The only way to fix has been to upload some other random code or to pull it off the Arduino UNO completely for a few seconds. There must be an easier method.

Thank you!!
Brian
The administrator has disabled public write access.
The following user(s) said Thank You: administrator

Analog values 1 year 4 months ago #856

Hi Brian, sorry for the confusion. I would recommend you take a look at the programming guide and reference - these are the definitive documents for inputs, ranges and so on. Please take a look and see if this helps, if not please feel free to reply back and we can work though the specifics. In short, there are two functional sets - ones that taking floating point values, and ones that take integer values. For example setMasterAmplitude() takes a floating point value between 0.0 and 1.0 (most amplitudes are normalized), and a faster "closer to the bone" function that works in the native chip format, such as setMasterAmplitudeVal() between 0 and 127. The floating point functions are slower because they do a type conversion, but are more generic and less related to the actual hardware.

As for the ADSR - it only has selectable values as is limited by hardware, so the enumerations restrict the settings to those values.

As for the modes, the lowest and most primitive mode is synth mode, where you can tweak the oscillators, ADSR, etc. Poly mode organizes the synth functions to allow for more musical applications, and Voice mode takes over the entire synth to model speech (using preprogrammed synth commands). So, no you cannot use the modes at the same time, but you can switch between them as you see fit.

Since GinSing really only sets registers in the chip, you can end up with settings that will keep the chip running producing sound until you tell it to stop. If you are mixing modes, you may be resetting only parts relevant to that mode. I would recommend make sure you select only one mode (and those commands), and see if the reset functions work for that mode. Then build up other modes the same way and it should work out.
Last Edit: 1 year 4 months ago by administrator.
The administrator has disabled public write access.

Analog values 1 year 4 months ago #857

Hi, thanks for the fast reply!

I'm still confused by the floating point or integer values for variables. I can't find in the docs what values take what. Can you let me know where that is?

10-4 on the ADSR and Voice/Synth modes.

Regarding reset, I understand that I need to use it, but still confused as to the structure in the code of where to call that function. Should I call it in the loop()? or if I'm switching between voice/synth modes, should I begin them, then call reset()? Or will that negate the begin()?

Thanks again,
Brian
The administrator has disabled public write access.

Analog values 1 year 4 months ago #858

Good, happy to make progress. Lets use the function you mentioned earlier SetMasterAmplitude. In the reference guid for this function you'll see:

syntax
void setMasterAmplitude ( float amplitude )

description

Sets the overall (global) amplitude of the shield. This amplitude is a software
equivalent to a volume control on the shield, and scales the output from the DCOs and
bank mixers by the given value.

example

GinSingMaster *m = GS.getMaster(); // get master interface
m->setMasterAmplitude ( 0.5f ); // set global output to 50%

arguments

amplitude

A floating point value that represents the global amplitude output. The amplitude value can range
from 0.0 ( muted ) to 1.0 ( full volume. Note that DCO output is also scaled by its own amplitude and
the bank amplitude as well.


The equivalent integer fiction setMasterAmplitudeVal page looks like this:

syntax

void setMasterAmplitudeVal ( ubyte ampVal )

description

Sets the overall (global) amplitude of the shield as an unsigned byte. The Babblebot IC
internally uses a unsigned byte to represent volume, so using this function will avoid
the floating point conversion performed in setMasterAmplitude().

example

GinSingMaster *m = GS.getMaster(); // get master interface
m->setMasterAmplitudeVal ( 64 ); // set global output to 50%

arguments

ampVal

An unsigned byte that represents the global output amplitude. The value can range from 0 ( muted )
to 127 ( full volume ).



As for the reset, you only need to call it generally at the beginning of a mode, but if you are switching modes and want to shut everything off, I would try calling reset before switching, and then reset after switching - but you should not need it in a loop.
The administrator has disabled public write access.

Analog values 1 year 4 months ago #859

Again, thanks. I get that now, I was really questioning the other functions. Sorry if i hadn't explained that properly. Perhaps my code snippets below may help. I'm not asking you to program this for me, but if you wouldn't mind letting me know if I'm doing something greatly wrong, that would be a good kickstart for me anyway. Thanks again.


Here's what I have in my declarations.

//Buttons/Sliders
int presetIdx; //declare preset id

//Read Inputs Declarations
int modeA1;
int modeA1_mix_select;

int modeA2;
int modeA2_select;
int modeA2mix_mod;

int modeA3;
int modeA3_select;
int modeA3mix_mod;

// wave type;(DIGITAL)
int sineValue;
int rampValue;
int squareValue;
int sawValue;

// trig/release;(DIGITAL)
int atValue;
int arValue;
int ftValue;
int frValue;
int trigValue;
int releaseValue;

//Trigger button
boolean current_trigger_State = HIGH;
boolean last_trigger_State = LOW;
int trigger_State;
int trigger_Time = 0; // the last time the output pin was toggled

//Release button
boolean current_release_State = HIGH;
boolean last_release_State = LOW;
int release_State;
int release_Time = 0; // the last time the output pin was toggled

// preset selection up/down (DIGITAL)
int upValue;
int downValue;

// sliders; (ANALOG)
int ampValue;
int freqValue;
int attackValue;
int decayValue;
int resValue;
int amprampValue;
int amprateValue;
int freqrampValue;
int freqrateValue;

// joystick;
int joypitchValue;
int joyspeedValue;

//Bools and comparisons
//Joystick button
boolean current_joybutton_State = LOW; // LOW is synth, HIGH is voice
boolean joybuttonPrevious = HIGH; // the previous reading from the input pin
int joybutton_State; //current state of joystick button
long joybuttonTime = 0; // the last time the output pin was toggled


For the actual settings, here's what I'm doing for Voice. is there a better method? My code is pretty complex currently and I actually just ran out of space on the UNO, mostly based on the floats it seems. Notice how I'm mapping the INT values from the slider to floats. This works, but may be overly complex, as Map only uses Integers it seems.

v->setNote ( A_1 ); //not sure if this is needed
v->setFrequency( map(muxShield.analogReadMS(3,7), 0, 1023 , 5, 500)); //keeping it low for deeper sounds
v->setDelay (map(muxShield.analogReadMS(3,3), 0, 1023 , 100, 1500)); // set delay could be 100 - 1500, or .01 - 1.5??? Don't know if this is best method.
v->setBlendSpeed ((float)(map(muxShield.analogReadMS(3,4), 0, 1023 , 0, 1000) / 1000.0f)); // set blend speed



And here's what I'm doing for Synth. I get some cool results, but the amplitude/frequency ramp sliders seem way off. Thoughts?

s->setFrequency ( OSC_1 , map(muxShield.analogReadMS(3,1), 0, 1023 , 50 , 127));
s->setFrequency ( OSC_2 , map(muxShield.analogReadMS(3,1), 0, 1023 , 51 , 126));
s->setFrequency ( OSC_3 , map(muxShield.analogReadMS(3,1), 0, 1023 , 1 , 125));

s->setDutyCycle (OSC_2, (float)(map(muxShield.analogReadMS(3,4), 0, 1023 , -1000 , 1000) * .001f)); //Set AM Oscillator, I think it only uses PULSE mode

//Frequency Ramp stuff
int tgtFrq = map(muxShield.analogReadMS(3,7), 0, 1023 , 25, 2500); //Freq Ramp slider
float tgtRate = ((float)(map(muxShield.analogReadMS(3,8), 0, 1023 , 0, 10000) / 20000.0f)) ; //Freq Rate slider (.0000 - .5000)
Serial.println(tgtRate);

s->setFreqRamp (OSC_3 , tgtFrq) ;
s->setFreqTarget ( OSC_3 , tgtFrq , tgtRate );
// delay(30);

//Amplitude Ramp stuff
float tgtAmp = ((float)(map(muxShield.analogReadMS(3,5), 0, 1023 , 20, 10000) / 15000.0f)); //Amp Ramp slider
float ampRate = ((float)(map(muxShield.analogReadMS(3,6), 0, 1023 , 0, 10000) / 10000.0f)) ; //Amp Rate slider
s->setAmpTarget ( OSC_2 , tgtAmp , ampRate);
s->setAmpRamp ( OSC_2 , tgtAmp) ;
s->setEnvelope ( OSC_1 , // set envelope for this oscillator. The values below still seem off.
/* ATTACK */ AT_2MS , ((float)(map(muxShield.analogReadMS(3,2), 0, 1023 , 0, 10000) / 1000.0f)) , // set the attack stage to reach 100% volume in 2 milliseconds
/* DECAY */ DR_575MS , ((float)(map(muxShield.analogReadMS(3,3), 0, 1023 , 0, 10000) / 1000.0f)) , // after that, drop the amplitude down to 80% in about 1/2 second
/* SUSTAIN */ // no paramters needed - just sustain the decay value until released
/* RELEASE */ DR_1500MS , ((float)(map(muxShield.analogReadMS(3,5), 0, 1023 , 0, 10000) / 1000.0f)) ); // when release() is called, fade out to 0% volume in 1.5 seconds

s->setAmplitude( OSC_ALL , ((float)(map(muxShield.analogReadMS(3,0), 0, 1023 , 0, 1000) / 1000.0f ))); //this works, but doesn't work when using Amplitude Ramp. Will need masterAmplitude for this eventually.
The administrator has disabled public write access.

Analog values 1 year 4 months ago #860

Due to the number of things that could go wrong that I can't check from here, I would suggest we start with the basics.

I would recommend you first remove all the input variables and replace them with constants that match your expectation (comment out the calls but replace with fixed values). If what you hear is not what you expect, it might be easier to spot the issue. This is particularly true if you can isolate the code for each mode; so for example just try the voice mode code using known values and see if that works; since I don't see all of the voice code its hard for me to see if a setup is missing or something.

I suspect in doing this it might highlight something missing, or at least that the value you are passing is out of operating range.
How does that sound?
The administrator has disabled public write access.

Analog values 1 year 4 months ago #865

Thank you, I will try that to pin down the issues!!
-Brian
The administrator has disabled public write access.

Analog values 1 year 4 months ago #866

BTW, another thing that you might find helpful in figuring out how the synth mode functions is to download the Tweaker / Babbletron programs - they allow for interactive changes to all the parameters and displays the function calls at the same time.
The administrator has disabled public write access.
The following user(s) said Thank You: m1llipede
  • Page:
  • 1
Time to create page: 0.263 seconds