login

online now

We have 158 guests and no members online

search

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

TOPIC: Problem with Punch Through

Problem with Punch Through 3 years 9 months ago #478

Sorry, very basic question here but hopefully that means it won't be much of a hassle to answer. I'm having a problem punching through to synth mode from other modes. Simple example: take this snippet of code from the preset mode example sketch -
preset->load    ( 0 , (GSPreset) presetIdx );      // load the selected preset on bank 0
    preset->trigger ( 0 );                             // trigger the preset on bank 0
    delay ( 1000 );                                    // listen to it for one second
Then add a call to set the frequency:
preset->load    ( 0 , (GSPreset) presetIdx );      // load the selected preset on bank 0
    preset->trigger ( 0 );                             // trigger the preset on bank 0
    synth.setFrequency ( OSC_1 , 100.0f );
    delay ( 1000 );                                    // listen to it for one second
Problem is that this generates a 'synth was not declared in this scope' error. I'm obviously doing something wrong, so all advice would be much appreciated.
Last Edit: 3 years 9 months ago by administrator.
The administrator has disabled public write access.

Re: Problem with Punch Through 3 years 9 months ago #479

That error is a compiler error, correct? I would suspect the variable "synth" is not declared within the function that you are showing in the second example, which is why its not in scope there. You could check where the variable is defined and make sure it is outside any function thereby making it global.

If you want to post the entire code I can probably give you an easy fix. You might get some insight also by looking at the sample programs. For example, if you look at the _5_synthmode example you can see how the variable GinSingSynth *s is declared globally and set up in an initialization function, making it valid and available to all the other functions.
The administrator has disabled public write access.
The following user(s) said Thank You: Charlie McF

Re: Problem with Punch Through 3 years 9 months ago #480

Ah, got it now thanks. The code I posted was actually from one of the sample programs, _2_presetmode. Here's the whole thing which works fine now, thanks for your help:
// ---------------------------------------------------------------------------------------------------------------------------------------------

#include <GinSing.h>                                   // interface header file
GinSing  GS;                                           //  create the class library from which all methods and data are accessed


#define rcvPin  4                                      // this is the pin used for receiving    ( can be either 4 or 12 )
#define sndPin  3                                      // this is the pin used for transmitting ( can be either 3 or 11 ) 
#define ovfPin  2                                      // this is the pin used for overflow control ( can be either 2 or 10 )

// ---------------------------------------------------------------------------------------------------------------------------------------------

void setup ()                                          // we are doing everything here, but you can also do this in the update loop
{
  
  GS.begin ( rcvPin , sndPin , ovfPin );               // start the device (required) and enter preset mode
  GinSingPreset * preset = GS.getPreset();             // get the preset mode interface
  GinSingSynth * synth = GS.getSynth();			// get the synth interface
  GinSingMaster * master = GS.getMaster();		// get the master interface
  preset->begin ();                                    // enter presetmode
  

  // cycle through the effects and load them into the first bank
  
  for ( int presetIdx = (int) SpaceWarp; presetIdx < (int) AmpMod; presetIdx++ )
  {
    
    preset->load    ( 0 , (GSPreset) presetIdx );      // load the selected preset on bank 0
    preset->trigger ( 0 );                             // trigger the preset on bank 0
    synth->selectBank (BANK_A);
    synth->setFrequency(OSC_ALL, 50.0f);
    master->setMasterAmplitude (0.1f);
    
    delay ( 1000 );                                    // listen to it for one second
    
    preset->release ( 0 );                             // release the preset
    
  }
  
  GS.end();                                            // end the device

}

void loop (){}
The administrator has disabled public write access.

Re: Problem with Punch Through 3 years 9 months ago #486

Another apology: I replied to this a while back but it seems not to have made it to the forum, sorry. Anyway, good news is that thanks to this advice I got it to work. I just had to add these lines at the start of the sketch:
GinSingPreset * preset = GS.getPreset(); // get the Ginsing sound synth preset mode interface
GinSingSynth * synth = GS.getSynth(); // get the Ginsing synth mode interface
GinSingMaster * master = GS.getMaster(); // get the Ginsing sound synth master interface

Then call as required from the functions, eg
void pingpresetfreq(){
  pingFreq = (float) map (pingCm, 1, maxDistance, 5000, 20);
  synth->setFrequency(OSC_1, pingFreq);
}

and it all works, thanks! And as it happens I was using the Presets sample program in my original post...
The administrator has disabled public write access.

Re: Problem with Punch Through 3 years 9 months ago #487

Great News! Don't forget to keep using the forum if you come across any other problems.
The administrator has disabled public write access.
  • Page:
  • 1
Time to create page: 0.168 seconds