Pages: [1]   Go Down
Author Topic: wave shield + 12 bit  (Read 1881 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
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

Online Online
Faraday Member
Karma: 27
Posts: 2568
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; 

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

ok, I'm sorry
the shield is the adafruits wave shield
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
  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:");

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

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

void playcomplete(char *name){

  while (wave.isplaying);

void playfile(char *name) {
  // stop any file already playing
  if (wave.isplaying) {

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

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

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.

Pages: [1]   Go Up
Jump to: