Pages: [1]   Go Down
Author Topic: wave shield + 12 bit  (Read 1883 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hi  smiley
I'm new in the arduino world
and I'm tried to build a simple project:
a voice activated from a sensor, when people are near the sensor the voice speak them..

I use a PIR sensor, an arduino 2009 and a wave shield (!!!)
is quiet simple and all system work good
the only problem is with the wave shield that want only 12 bit wav file
if you don't use a human voice with the shield this is not a big problem..because the sound is played.. but distort!  smiley-mad

and it seems impossible to convert file in this format,  smiley-cry
no one software make this conversion
I tried with many of this, from free to professional

Any one else have this problem?
help me
thank you
fraz
Logged

Montreal
Offline Offline
Faraday Member
**
Karma: 27
Posts: 2573
Per aspera ad astra.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What is the shield, link to product doc  would be helpful, and post your scetch.
  In short, conversion from int_16 to int_12 is  right shift operation, for example ,  sample_12 = sample_16 >>4; 
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ok, I'm sorry
the shield is the adafruits wave shield  http://www.adafruit.com/products/94
and this is my sketch


#include <AF_Wave.h>
#include <avr/pgmspace.h>
#include "util.h"
#include "wave.h"

int pirPin= 0;  // Reading from digital pin 11 PIR sensor!
int val = 0;

AF_Wave card;
File f;
Wavefile wave;

void setup() {
  // set up serial port
  Serial.begin(9600);
  pinMode(pirPin, INPUT);

  // set up waveshield pins
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(0, INPUT);
 
  // open memory card...........This part is necessary to set up and read SDcard!
 if (!card.init_card()) {
    putstring_nl("Card init. failed!"); return;
  }
  if (!card.open_partition()) {
    putstring_nl("No partition!"); return;
  }
  if (!card.open_filesys()) {
    putstring_nl("Couldn't open filesys"); return;
  }
  if (!card.open_rootdir()) {
    putstring_nl("Couldn't open dir"); return;
  }
 
  putstring_nl("Files fuond:");
  ls();
}

void ls() {
  char name[13];
  int ret;
 
  card.reset_dir();
  putstring_nl("Files found:");
  while (1) {
    ret = card.get_next_name_in_dir(name);
    if (!ret) {
       card.reset_dir();
       return;
    }
    Serial.println(name);
  }
}

void loop(){
val = analogRead(pirPin);
  Serial.println(val);
    if (val < 10) {
      Serial.println("e vai!");
       playcomplete("PEN3.WAV");
    }
    if (val > 11) {
      Serial.println ("zitto");
    }
    delay (500);
 // while (LOW==analogRead(pirPin)) {;}
        //  delay(5000);
}

 
void playcomplete(char *name){

  playfile(name);
  while (wave.isplaying);
  card.close_file(f);
}

void playfile(char *name) {
  // stop any file already playing
  if (wave.isplaying) {
    wave.stop();
    card.close_file(f);
  }

  f = card.open_file(name);
  if (f && wave.create(f)) {
    wave.play();
  }
}
 


but what mean this? : sample_12 = sample_16 >>4; 
thank you smiley
f
Logged

Yorkshire England
Offline Offline
Sr. Member
****
Karma: 2
Posts: 267
Arduino good init
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't know if the documentation is out of date or it's some other reason but 16 bit wavs are fine. They have to be mono. 44.1 or 22 khz will work but you only get to use the volume control on 22s. I've got one and it works fine.
Logged

Pages: [1]   Go Up
Jump to: