simulated sports hooter

I want to use an arduino chip to simulate the sound of the hooter at the end of a game. ( football rugby or whatever )
I have been using a real electromechanical horn from a scooter, but as the contacts wear it seems to draw more and more current and causes problems.

I did an Arduino search and found a few references to sound generators, but none of the threads actually got anywhere - although the ant farm choir at http://adamfranchino.net/2010/04/26/arduino-ant-farm/ is fascinating !!

The tone itself that I need is pretty low frequency without high harmonics.
( I can use one pwm to vary the level for the fade in fade out.)

I am probably reinventing the wheel here, but

If the repitition of the basic waveforem is low enough, couldn't I just have a look up table and just run through the sampled voltages that make up the waveform - I don't need a very high sample rate or frequency response.

I am not into audio, so there is probably a chip out there to sample/hold/digitise it for me to make the master copy.

Or could I use a very short ( 100mS? ) wav file ( or whatever ) edited from a recording of the real thing, that would fit in the memory space, and constantly loop?
A hooter is pretty warbly anyway...
Can the arduino play a short wav file ??

I can look on a scope and see when the pattern repeats itself - note to self, record a horn off the TV sport this weekend !

I would only need the arduino with a simple filter, a 20?watt amplifier chip as used in car radios, and a speaker.

I want to use an arduino chip to simulate the sound of the hooter at the end of a game.

Must be a different meaning to the word hooter than these people understand:
http://www.hooters.com/home.aspx
Personally, I like there meaning better.

Gee Paul,

I had finally got into Arduino as a hobby and now you have steered me back to my old ways....................

OK, I found a sample hooter - sorry Paul - horn sound and have grabbed a short sample from the wav file where it looks like the waveform is repeating itself.

I then used BTc sound encoder3 to convert it to a 1bit stream, which doesn't sound too bad.

Its just a string of 1s and 0s whos average voltage sort of follows the waveform of the audio.

I chopped off the head and tail of each line ( because I havn't a clue what a BTc file format is)

which leaves me with 118 lines of binary bytes ( 118 bytes only )

like these:-

B01110100
B01000111
B01011000
B11110000 and so on

these are not 8 bit bytes that represent a voltage, they are like switching a switch on and off to vary the average voltage - all 1s would result after filtering of 5v and all 0s zero volts , 1010 would be 2.5v .

My basic plan is that whenever I want the horn to sound, I have a subroutine just repeating these bytes in a loop, OK there has to be a bit of a hiccup in the sound whenever it goes through the loop, but if I can try and shuffle the order of the bytes to make this when most of the pattern is zeros, ( or actually 50% 1s and 0s to bias it at the offset zero crossing ) it might not matter ?....

I am thinking of using the SPI data output ( pin 11) and ignore the MISO and CS, and just take the latch low at the start of the horn cycle , and return at the end.

I am using something like this on another project for video at the moment, so I will have to slow down everything for audio, and as the one bytes represent an average voltage, I will repeat each byte output "n" times to slow it down ( I cant "delay" between each or the average value will fall..)

Perhaps the time has come for me to learn arrays ?

I could do it in 118 lines of course , but I must start getting my code tidy..

so do I just put a "," between binary bytes, and use an array ? perhaps using hex values? and then step through them.

Each step would repeat "n" times as it goes through the loop.

I can think of some other ways of doing it, but I am not sure if they would work...

It works just as above. and it only takes up 1470 bytes so I can fit it in with the existing micro. ( and I found out what I was doing wrong with arrays at last ! )

The only SPI output I am using is the data, I have put a 2k2 resistor from pin 11 to the amplifier input, with a .22 mFD cap to ground from the the amp input.

this is the waveform from pin 11 red,, and after smoothing to the amp, green
Imgur

It gives a dirty brown note full of distortion and harmonics, like a horn.
Now I am going to try a siren, seeing as I have plenty of memory to play with....

int latchPin = 8;
int clockPin = 12;
int dataPin = 11;
long int timer;


void setup() {
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
digitalWrite(latchPin, LOW);


}

void loop() {

  int noise[] = {
    B10111001,
    B01010000,
    B10111110,
    B00011110,
    B00001100,
    B11011011,
    B01000111,
    B00101110,
    B00010111,
    B10000011,
    B10001000,
    B11110100,
    B11100110,
    B01000011,
    B11111000,
    B01110000,
    B01110011,
    B01011100,
    B00011101,
    B10011000,
    B11101010,
    B01000110,
    B00100111,
    B11000111,
    B10100001,
    B00011111,
    B11000001,   
    B11001100,       
    B01110110,          
    B00111000,  
    B11111010,   
    B00011000,  
    B00100111,   
    B10000100,   
    B01111011,     
    B00011111,   
    B00000111,    
    B00110011,     
    B11111001,     
    B10001100,    
    B01100110,     
    B11110000,    
    B01111100,        
    B10011110,        
    B00010011,    
    B10011100,        
    B01101100,        
    B00111100,        
    B11001111,        
    B00000111,    
    B11000110,       
    B00110010,        // theres some spare lines here for messing with the note
   
  };

  for (timer = 0; timer<800;timer ++) { // gives approx  4 second burst with just this loop playing and a 16MHz xtal.

    for (int j = 0; j < 25; j++) {   // vary the 25 to change the note

      shiftOut(dataPin, clockPin, MSBFIRST, noise[j]);   
     
    }
  }
       delay(1000);                       // a break between toots !
  digitalWrite(latchPin, HIGH); 
}