wave shield

For other supported Arduino products from Adafruit: Shields, accessories, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
cricket
 
Posts: 9
Joined: Wed Mar 20, 2013 2:49 pm

wave shield

Post by cricket »

Hi, I am trying to use adafruit's waveshield to run sample code from the WaveHC examples for now and have encountered a strange problem. I can get the card to read so I suppose this is formatted correctly and that my shield is also. HOWEVER, when I try to run any other example from the WaveHC library, they do not compile.I receive many errors/ the most consistent being: SampleRateHC.pde:-1: error: 'WaveHC' does not name a type. The console prints this out for almost everything in the sketch. I have a pot hooked up to analog 0 on arduino and I am using an unmodified example code from the WaveHC library. Any help would be greatly appreciated as I am very confused as to why I cannot get sample code to run.... :oops:
Here is the example code I am using that does not compile:

Code: Select all

/*
 * Adafruit SampleRateMod.pde example modified to use WaveHC.
 *
 * Play files with sample rate controlled by voltage on analog pin zero.
 */
# include <WaveHC.h>
# include <WaveUtil.h>

SdReader card;    // This object holds the information for the card
FatVolume vol;    // This holds the information for the partition on the card
FatReader root;   // This holds the information for the volumes root directory
FatReader file;   // This object represent the WAV file
WaveHC wave;      // This is the only wave (audio) object, since we will only play one at a time

/*
 * Define macro to put error messages in flash memory
 */
#define error(msg) error_P(PSTR(msg))

//////////////////////////////////// SETUP
void setup() {
  Serial.begin(9600);
  Serial.println("Wave test!");

  // try card.init(true) if errors occur on V1.0 Wave Shield
  if (!card.init()) {
    error("Card init. failed!");
  }
  // enable optimize read - some cards may timeout
  card.partialBlockRead(true);
  
  if (!vol.init(card)) {
    error("No partition!");
  }
  if (!root.openRoot(vol)) {
    error("Couldn't open root");
  }
  putstring_nl("Files found:");
  root.ls();
}

// forward declarition
void playcomplete(FatReader &file);



//////////////////////////////////// LOOP
void loop() { 
  uint8_t i, r;
  char c, name[15];
  dir_t dir;

  root.rewind();
  // scroll through the files in the directory
  while (root.readDir(dir) > 0) { 
    // only play .WAV files
    if (!strncmp_P((char *)&dir.name[8]. PSTR("WAV"))) continue;
    
    if (!file.open(vol, dir)){
      putstring("Can't open ");
      printEntryName(dir);
      Serial.println();
      continue;
    }
    putstring("\n\rPlaying "); 
    printEntryName(dir);
    Serial.println();
    playcomplete(file);
    file.close();    
  }
}
/////////////////////////////////// HELPERS
/*
 * print error message and halt
 */
void error_P(const char *str) {
  PgmPrint("Error: ");
  SerialPrint_P(str);
  sdErrorCheck();
  while(1);
}
/*
 * print error message and halt if SD I/O error, great for debugging!
 */
void sdErrorCheck(void) {
  if (!card.errorCode()) return;
  PgmPrint("\r\nSD I/O error: ");
  Serial.print(card.errorCode(), HEX);
  PgmPrint(", ");
  Serial.println(card.errorData(), HEX);
  while(1);
}
int16_t lastpotval = 0;
#define HYSTERESIS 3
/*
 * play file with sample rate changes
 */
void playcomplete(FatReader &file) {
  int16_t potval;
  uint32_t newsamplerate;
  
   if (!wave.create(file)) {
     putstring_nl(" Not a valid WAV"); return;
   }
   // ok time to play!
   wave.play();
   
  while (wave.isplaying) {
     potval = analogRead(0);
     if ( ((potval - lastpotval) > HYSTERESIS) || ((lastpotval - potval) > HYSTERESIS)) {
         putstring("pot = ");
         Serial.println(potval, DEC); 
         putstring("tickspersam = ");
         Serial.print(wave.dwSamplesPerSec, DEC);
         putstring(" -> ");
         newsamplerate = wave.dwSamplesPerSec;
         newsamplerate *= potval;
         newsamplerate /= 512;   // we want to 'split' between sped up and slowed down.
        if (newsamplerate > 24000) {
          newsamplerate = 24000;  
        }
        if (newsamplerate < 1000) {
          newsamplerate = 1000;  
        }        
        wave.setSampleRate(newsamplerate);
        
        Serial.println(newsamplerate, DEC);
        lastpotval = potval;
     }
     delay(100);
   }
   sdErrorCheck();
}
Last edited by adafruit_support_bill on Thu Mar 21, 2013 6:09 am, edited 1 time in total.
Reason: Please use the 'code' button when submitting code

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: wave shield

Post by adafruit_support_mike »

First of all, let's make sure your WaveHC library is in the right place: in a folder named 'libraries' inside your Arduino 'sketchbook' folder.

If it isn't there, the program can't find the files it needs to compile the code.

cricket
 
Posts: 9
Joined: Wed Mar 20, 2013 2:49 pm

Re: wave shield

Post by cricket »

Thanks for responding so quickly!!!!
Yes, the WaveHC library is in a folder called library in arduino. It shows up in tbe dropdown under "import library".

User avatar
adafruit_support_bill
 
Posts: 88136
Joined: Sat Feb 07, 2009 10:11 am

Re: wave shield

Post by adafruit_support_bill »

Can you post the exact error messages you are seeing? Be sure to scroll to the very top of the list, since the first few are usually the most relevant.

cricket
 
Posts: 9
Joined: Wed Mar 20, 2013 2:49 pm

Re: wave shield

Post by cricket »

For some reason, I am receiving less errors today than I was yesterday. I am only receiving- which I guess means it is a path issue? Or is something missing from the library?

SampleRateHC.pde:-1: error: no matching function for call to 'WaveHC::WaveHC()'
/Users/cosmigitana/Documents/Arduino/libraries/WaveHC/WaveHC.h:113: note: candidates are: WaveHC::WaveHC(HardwareSerial&)
/Users/cosmigitana/Documents/Arduino/libraries/WaveHC/WaveHC.h:78: note: WaveHC::WaveHC(const WaveHC&)

User avatar
adafruit_support_bill
 
Posts: 88136
Joined: Sat Feb 07, 2009 10:11 am

Re: wave shield

Post by adafruit_support_bill »

Do you have a link to where you got that sketch? The one on the Wave Shield example page is written for the (obsolete) AF_Wave library.
http://www.ladyada.net/media/wavshield/ ... ateMod.pde

cricket
 
Posts: 9
Joined: Wed Mar 20, 2013 2:49 pm

Re: wave shield

Post by cricket »

I actually downloaded the WaveHC library from here first: http://code.google.com/p/wavehc/ and when I couldnt compile any example sketches, I found this on gitHub:https://github.com/catchdave/arduino-gb


I tried running the sketch you provided and received the following errors:

sketch_mar21a.cpp:4:18: error: wave.h: No such file or directory
sketch_mar21a:5: error: 'AF_Wave' does not name a type
sketch_mar21a:6: error: 'File' does not name a type
sketch_mar21a:7: error: 'Wavefile' does not name a type
sketch_mar21a.cpp: In function 'void setup()':
sketch_mar21a:23: error: 'card' was not declared in this scope
sketch_mar21a:24: error: 'putstring_nl' was not declared in this scope
sketch_mar21a:26: error: 'card' was not declared in this scope
sketch_mar21a:27: error: 'putstring_nl' was not declared in this scope
sketch_mar21a:29: error: 'card' was not declared in this scope
sketch_mar21a:30: error: 'putstring_nl' was not declared in this scope
sketch_mar21a:33: error: 'card' was not declared in this scope
sketch_mar21a:34: error: 'putstring_nl' was not declared in this scope
sketch_mar21a:37: error: 'putstring_nl' was not declared in this scope
sketch_mar21a.cpp: In function 'void ls()':
sketch_mar21a:45: error: 'card' was not declared in this scope
sketch_mar21a:46: error: 'putstring_nl' was not declared in this scope
sketch_mar21a.cpp: In function 'void loop()':
sketch_mar21a:64: error: 'card' was not declared in this scope
sketch_mar21a:74: error: 'putstring' was not declared in this scope
sketch_mar21a.cpp: In function 'void playcomplete(char*)':
sketch_mar21a:89: error: 'wave' was not declared in this scope
sketch_mar21a:92: error: 'putstring' was not declared in this scope
sketch_mar21a:107: error: 'card' was not declared in this scope
sketch_mar21a:107: error: 'f' was not declared in this scope
sketch_mar21a.cpp: In function 'void playfile(char*)':
sketch_mar21a:111: error: 'f' was not declared in this scope
sketch_mar21a:111: error: 'card' was not declared in this scope
sketch_mar21a:113: error: 'putstring_nl' was not declared in this scope
sketch_mar21a:115: error: 'wave' was not declared in this scope
sketch_mar21a:116: error: 'putstring_nl' was not declared in this scope
sketch_mar21a:119: error: 'wave' was not declared in this scope

User avatar
adafruit_support_bill
 
Posts: 88136
Joined: Sat Feb 07, 2009 10:11 am

Re: wave shield

Post by adafruit_support_bill »

This is the official repository for WaveHC. https://code.google.com/p/wavehc/
I just tested it and all of the examples do compile.
I tried running the sketch you provided and received the following errors:
Yes. As I said, it was written for a different library.

cricket
 
Posts: 9
Joined: Wed Mar 20, 2013 2:49 pm

Re: wave shield

Post by cricket »

I downloaded the library from your link and everything compiles and runs. Thank you!!!!!!!!!

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Arduino products from Adafruit”