A library which allows the playing of Wav files using the TLV320

Dependents:   RSALB_hbridge_helloworld RSALB_lobster WavPlayer_test AudioCODEC_HelloWorld

Files at this revision

API Documentation at this revision

Comitter:
p07gbar
Date:
Wed Sep 19 10:58:16 2012 +0000
Child:
1:3eb96771bbee
Commit message:
Working stably

Changed in this revision

I2S.lib Show annotated file Show diff for this revision Revisions of this file
RingBuffer/RingBuffer.cpp Show annotated file Show diff for this revision Revisions of this file
RingBuffer/RingBuffer.h Show annotated file Show diff for this revision Revisions of this file
TLV320.lib Show annotated file Show diff for this revision Revisions of this file
WavPlayer.cpp Show annotated file Show diff for this revision Revisions of this file
WavPlayer.h Show annotated file Show diff for this revision Revisions of this file
WavPlayerConfig.cpp Show annotated file Show diff for this revision Revisions of this file
WavPlayerConfig.h Show annotated file Show diff for this revision Revisions of this file
sinelookup.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/I2S.lib	Wed Sep 19 10:58:16 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/p07gbar/code/I2S_library/#455d5826751b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RingBuffer/RingBuffer.cpp	Wed Sep 19 10:58:16 2012 +0000
@@ -0,0 +1,146 @@
+
+
+#include "RingBuffer.h"
+//Serial debug(USBTX,USBRX);
+
+RingBuffer::RingBuffer()
+{
+    Start = 0;
+    Finish = 0;
+    for(int i = 0; i < RBLENGTH; i++)
+    {
+        for(int j = 0; j<RBWIDTH; j++)
+        {
+            Buffer[i][j] = 0;
+        }
+    }
+    //debug.baud(115200);
+}
+
+int RingBuffer::addToBuffer(int* input)
+{
+    if(Finish == Start && Samples != 0)
+    {
+        return -1;     
+    }
+    else
+    {
+        for(int i = 0; i < RBWIDTH; i++)
+        {
+            Buffer[Finish][i] = input[i];
+        }
+        sortFinishNS();
+        return 0;
+    }
+    
+}
+
+
+int RingBuffer::addToBufferS(int input, int across)
+{
+    Buffer[Finish][across] = input;
+    return 0;
+}
+
+
+
+int RingBuffer::nextBuffer()
+{
+    sortFinishNS();
+    return 0;
+}
+
+
+
+void RingBuffer::readFirst(int* output)
+{
+    for(int i = 0; i < RBWIDTH; i++)
+        {
+            output[i] = Buffer[Start][i];
+        }
+}
+
+int RingBuffer::readFirstS(int across)
+{
+    return Buffer[Start][across];
+}
+
+
+
+void RingBuffer::readAt(int* output, int at)
+{
+    for(int i = 0; i < RBWIDTH; i++)
+        {
+            output[i] = Buffer[at][i];
+        }
+}
+
+int RingBuffer::readAtS(int at, int across)
+{
+    return Buffer[at][across];
+}
+
+
+
+void RingBuffer::readLast(int*output)
+{
+     for(int i = 0; i < RBWIDTH; i++)
+        {
+            output[i] = Buffer[Finish-1][i];
+        }
+}
+
+
+int RingBuffer::readLastS(int across)
+{
+    return Buffer[Finish-1][across];
+}
+
+void RingBuffer::usedFirst()
+{
+    sortStartUS();
+}
+
+void RingBuffer::usedLast()
+{
+    Finish--;
+    Samples--;
+}
+
+int RingBuffer::numberStored()
+{
+    if(Samples > RBLENGTH)
+    {
+        if(Finish < Start)
+        {
+            Samples = Finish + (RBLENGTH - Start);
+        }
+        else
+        {
+            Samples = Start - Finish;
+        }
+    }
+    return Samples;
+}
+
+void RingBuffer::sortFinishNS()
+{
+    Finish++;
+    Samples++;
+    if(Finish == RBLENGTH)
+    {
+        Finish = 0;
+        //debug.printf("\n\rBOO! %3i %3i\n\r",Start, Finish);
+    }
+    
+}
+
+void RingBuffer::sortStartUS()
+{
+    Start++;
+    Samples--;
+    if(Start == RBLENGTH)
+    {
+        Start = 0;
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RingBuffer/RingBuffer.h	Wed Sep 19 10:58:16 2012 +0000
@@ -0,0 +1,44 @@
+#ifndef RINGBUFFER_H
+#define RINGBUFFER_H
+
+#include "mbed.h"
+
+#define RBLENGTH 1000
+#define RBWIDTH 2
+
+class RingBuffer {
+
+public:
+
+RingBuffer();
+
+int addToBuffer(int* input);
+int addToBufferS(int input, int across);
+int nextBuffer();
+
+void readFirst(int* output);
+int readFirstS(int across);
+
+void readAt(int* output, int at);
+int readAtS(int at, int across);
+
+void readLast(int*output);
+int readLastS(int across);
+
+void usedFirst();
+void usedLast();
+
+int numberStored();
+
+protected:
+
+int16_t Buffer[RBLENGTH][RBWIDTH];
+
+int Start;
+int Finish;
+int Samples;
+
+void sortFinishNS();
+void sortStartUS();
+};
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TLV320.lib	Wed Sep 19 10:58:16 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/p07gbar/code/TLV320_library/#a68f7c573e8c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WavPlayer.cpp	Wed Sep 19 10:58:16 2012 +0000
@@ -0,0 +1,506 @@
+// TODO: Add licence and stop start remembering and fill buffer functions
+
+
+
+#include "WavPlayer.h"
+
+#define DEBUG 1
+#define debug_printf(args ...) if (DEBUG) printf(args)
+
+#define WAVPLAYER_PLAYER_BUF 1000
+
+#define WAVPLAYER_OUTPUT_RATE 48000
+
+#define WAVPLAYER_READ_MARGIN 0.9
+
+#define WAVLPAYER_SLOW_MARGIN 5
+
+#define WAVPLAYER_GEN_TEST 0
+
+#define WAVPLAYER_GEN_FREQ 440
+
+#if WAVPLAYER_GEN_TEST == 1
+#include "sinelookup.h"
+#else
+#define SINE16LENGTH 2
+#define SINE32LENGTH 2
+const int16_t sine16lookup[] = {0,10000};
+#endif
+
+WavPlayer* WavPlayer::instance;
+//void WavPlayer::i2sisr();
+
+WavPlayer::WavPlayer() :
+        flag_play(true), i2s(I2S_TRANSMIT, p5, p6, p7), codec(p9, p10)//, ext_flag(p22), //run_flag(p23)
+{
+    instance = this;
+    codec.power(true);                  //power up TLV apart from analogue input
+    codec.stop();
+    codec.frequency(WAVPLAYER_OUTPUT_RATE);            //set sample frequency
+    codec.wordsize(16);  //set transfer protocol
+    codec.master(false);
+    codec.headphone_volume(0.6);
+    //interrupt come from the I2STXFIFO only
+
+    i2s.masterslave(I2S_MASTER);
+    i2s.attach(&WavPlayer::i2sisr);
+
+    i2s.wordsize(16);
+    i2s.stereomono(I2S_MONO);
+
+    i2s.frequency(WAVPLAYER_OUTPUT_RATE);
+
+    //ext_flag = false;
+
+    flag_vol = false;
+    volume = 1;
+}
+
+WavPlayer::WavPlayer(FILE **fpp):flag_play(true), i2s(I2S_TRANSMIT, p5, p6, p7), codec(p9, p10)//, ext_flag(p22), //run_flag(p23)
+{
+    instance = this;
+    codec.power(true);                  //power up TLV apart from analogue input
+    codec.stop();
+    codec.frequency(WAVPLAYER_OUTPUT_RATE);            //set sample frequency
+    codec.wordsize(16);  //set transfer protocol
+    codec.master(false);
+    codec.headphone_volume(0.6);
+    //interrupt come from the I2STXFIFO only
+
+    i2s.masterslave(I2S_MASTER);
+    i2s.attach(&WavPlayer::i2sisr);
+
+    i2s.wordsize(16);
+    i2s.stereomono(I2S_MONO);
+
+    i2s.frequency(WAVPLAYER_OUTPUT_RATE);
+
+    //ext_flag = false;
+
+    flag_vol = false;
+    volume = 1;
+    open(fpp);
+}
+
+void WavPlayer::i2sisr()
+{
+    instance->i2sisr_();
+}
+
+void WavPlayer::i2sisr_()
+{
+    int to_write = i2s.max_fifo_points() - i2s.fifo_points();
+    int temp[32];
+    /*for(int i = 0; i < 32; i++)
+     {
+     temp[i] = 0;
+     }*/
+    int destore[2];
+    if (rbuf.numberStored() > to_write + 8 && flag_play)
+    {
+        for (int i = 0; i < to_write; i += 2)
+        {
+            rbuf.readFirst(destore);
+            rbuf.usedFirst();
+            temp[i]   = destore[0];
+            temp[i+1] = destore[1];
+        }
+
+        i2s.write(temp, to_write);
+    }
+    else
+    {
+        for (int i = 0; i < to_write; i++)
+        {
+            temp[i] = 0;
+        }
+        i2s.write(temp, to_write);
+        isr_underrun++;
+        
+    }
+
+}
+
+void WavPlayer::open(FILE **fpp)
+{
+    filepp = fpp;
+    if (*filepp == NULL)
+        printf(
+                "Please open a file before passing the file pointer pointer...\n\r");
+    char temp[4];
+    fgets_m(temp, 4, *filepp);
+    debug_printf("%s\n\r", temp);
+    if (strcmp(temp, "RIFF") != 0)
+        printf("This is not a RIFF file\n\r");
+    fseekread(*filepp, temp, 8, 4);
+    if (strcmp(temp, "WAVE") != 0)
+        printf("This is not a WAVE file\n\r");
+
+    getConfig();
+}
+
+int WavPlayer::getConfig()
+{
+    char temp[4];
+    clear(temp, 4);
+    fseekread(*filepp, temp, 4, 4);
+    config.file_size = getu32(temp, 4);
+    debug_printf("FileSize = %i\n\r", config.file_size);
+
+    int chunkstart = findChunk(*filepp, "fmt ", 4, config.file_size, 12);
+
+    if (chunkstart != -1)
+    {
+
+        config.format_tag = fsru16(*filepp, chunkstart + 8);
+        debug_printf("Format_tag:            %i\n\r", config.format_tag);
+
+        config.channels = fsru16(*filepp, chunkstart + 10);
+        debug_printf("nChannels:            %i\n\r", config.channels);
+
+        config.samples_per_sec = fsru32(*filepp, chunkstart + 12);
+        debug_printf("nSamplesPerSec:        %i\n\r", config.samples_per_sec);
+
+        config.avg_bytes_per_sec = fsru32(*filepp, chunkstart + 16);
+        debug_printf("avg_bytes_per_sec:    %i\n\r", config.avg_bytes_per_sec);
+
+        config.block_align = fsru16(*filepp, chunkstart + 20);
+        debug_printf("block_align:            %i\n\r", config.block_align);
+
+        config.bits_per_sample = fsru16(*filepp, chunkstart + 22);
+        debug_printf(
+                "bits per sample:            %i\n\r", config.bits_per_sample);
+
+    }
+
+    chunkstart = findChunk(*filepp, "data", 4, config.file_size, 12);
+
+    if (chunkstart != -1)
+    {
+        config.data_length = fsru32(*filepp, chunkstart + 4);
+        debug_printf("Data Length:            %i\n\r", config.data_length);
+    }
+    return 0;
+
+}
+
+float WavPlayer::play()
+{
+    return play(float(config.data_length) / float(config.samples_per_sec));
+
+}
+
+float WavPlayer::play(float time)
+{
+    return play(current_time, time);
+}
+
+float WavPlayer::play(float start, float timefor)
+{
+
+    #if WAVPLAYER_GEN_TEST == 1
+    config.channels = 1;    
+    config.samples_per_sec = 48000;
+    #endif
+    
+    float timeElapsed = 0;
+    int endPoint = int((start + timefor) * float(config.samples_per_sec));
+    if (endPoint * config.block_align >= config.data_length)
+        endPoint = config.data_length / config.block_align;
+    //printf("Will end after: %i samples \n\r", endPoint);
+    int point = int(start * float(config.samples_per_sec));
+    bool valid = true;
+    flag_play = false;
+    int dataOffset = findChunk(*filepp, "data", 4, config.file_size, 12) + 8 + (point * config.block_align);
+
+    double timeComp = 0;
+
+    double out_rate_t_p = 1 / double(WAVPLAYER_OUTPUT_RATE);
+    //printf("out_rate_t_p = %f\n\r", out_rate_t_p);
+    double out_rate_t_n = -1 / double(WAVPLAYER_OUTPUT_RATE);
+    double in_rate = 1 / double(config.samples_per_sec); //0.0000125
+    //printf("in_rate = %f\n\r", in_rate);
+    
+    float phase = 0;
+
+    if (dataOffset != -1)
+    {
+        fseek(*filepp, dataOffset, SEEK_SET);
+
+        int16_t buffer[WAVPLAYER_PLAYER_BUF];
+
+        codec.start();
+        //debug_printf("Expecting isr\n\r");
+
+        i2s.frequency(WAVPLAYER_OUTPUT_RATE);
+
+
+        if (config.channels == 1)
+        {
+            stereo = false;
+            i2s.stereomono(I2S_MONO);
+        }
+        else
+        {
+            stereo =true;
+            i2s.stereomono(I2S_STEREO);
+        }
+
+        i2s.attach(&WavPlayer::i2sisr);
+        i2s.start();
+        flag_play = true;
+
+        while (valid && point < endPoint)
+        {
+            if (rbuf.numberStored() < RBLENGTH - 10)
+            {
+
+                //timer.reset();
+                //timer.start();
+                int numToread = WAVPLAYER_PLAYER_BUF;
+                if (numToread > (RBLENGTH - 10) - rbuf.numberStored())
+                {
+                    numToread = (RBLENGTH - 10) - rbuf.numberStored();
+                }
+                if (numToread + (point * (config.block_align/config.channels)) > config.data_length)
+                {
+                    numToread = config.data_length - point * config.block_align;
+                    valid = false;
+                    debug_printf("EOF detected\n\r");
+                }
+                if(numToread % 2 == 1) numToread--;
+                //printf("Generating\n\r");
+                //run_flag = true;
+                //phase = sine_gen(buffer,numToread,float(config.samples_per_sec)/120,phase);
+                timer.reset();
+                timer.start();
+                //fread(buffer, config.block_align/config.channels, numToread, *filepp);
+                 #if WAVPLAYER_GEN_TEST == 1
+                    phase = sine_gen(buffer,numToread,float(config.samples_per_sec)/WAVPLAYER_GEN_FREQ,phase);  
+                #else
+                    fread(buffer, config.block_align/config.channels, numToread, *filepp);
+                #endif
+                timer.stop();
+                //printf("numToread:%f\n\r",float(numToread));
+                if(numToread>=10)
+                {
+                    read_time += (timer.read()/float(numToread));
+                    read_time_div += 1;
+                }
+                
+                
+                if(read_time/float(read_time_div) >= WAVPLAYER_READ_MARGIN / float(config.samples_per_sec*config.channels))
+                {
+                    slow_count++;
+                    if(slow_count > WAVLPAYER_SLOW_MARGIN)
+                    {
+                        printf("Data rates not high enough to sustain read...%f seconds per read\n\r", read_time/float(read_time_div));
+                        valid = false;
+                        break;
+                    }
+
+                }
+                
+                //run_flag = false;
+                int storer[2];
+                for (int i = 0; i < numToread; i += 2)
+                {
+
+                    //run_flag = true;
+
+                    if (timeComp < out_rate_t_p && timeComp > out_rate_t_n)
+                    {
+                        storer[0] = (int) buffer[i];
+                        storer[1] = (int) buffer[i + 1];
+
+                        //storer[0] = blip;
+                        //storer[1] = blip;
+                        timeComp += in_rate;
+                        while (rbuf.numberStored() > RBLENGTH - 10)
+                        {
+                            //run_flag = true;
+                            //run_flag = false;
+                        }
+                        rbuf.addToBuffer(storer);
+                        timeComp -= out_rate_t_p;
+                        //printf(",",timeComp);
+                        point++;
+                        //printf("straight %f\n\r",timeComp);
+                    }
+                    else if (timeComp >= out_rate_t_p)
+                    {
+
+                        storer[0] = (int) buffer[i];
+                        storer[1] = (int) buffer[i + 1];
+
+                        //storer[0] = blip;
+                        //storer[1] = blip;
+
+                        timeComp += in_rate;
+                        /*const float ct = 5;
+                         float c = 0;
+                         float bufi = float(buffer[i]);
+                         float bufip = float((i+1 >= numToread) ? buffer[i+1] : bufi);*/
+
+                        while (timeComp >= out_rate_t_p)
+                        {
+                            //storer[0] = int((((ct-c)/ct)*bufi)+((c/ct)*bufip));
+                            while (rbuf.numberStored() > RBLENGTH - 10)
+                            {
+                                //run_flag = true;
+                                //run_flag = false;
+                            }
+                            rbuf.addToBuffer(storer);
+                            timeComp -= out_rate_t_p;
+                            //printf(";");
+                            //if(c < ct) c++;
+                        }
+                        point++;
+
+                    }
+                    else if (timeComp <= out_rate_t_n)
+                    {
+                        timeComp += in_rate;
+                        //printf("-");
+                    }
+
+                    //storer[1] = 0;
+                    //if(i%1 == 0) printf("%i\n",int(storer[0]),int(storer[1]));
+                    //run_flag = false;
+
+                }
+                flag_play = true;
+                //timer.stop();
+                //printf("point: %i\n\r",isr_underrun);
+                //read_time += timer;
+                //read_time_div =numToread;
+
+            }
+        }
+    }
+    flag_play = false;
+    current_time = float(point)/float(config.samples_per_sec);
+    return current_time;
+}
+
+int WavPlayer::fseekread(FILE *fp, char* str, int offset, int len)
+{
+    fseek(fp, offset, SEEK_SET);
+    fgets_m(str, len, fp);
+    return len;
+}
+
+uint32_t WavPlayer::getu32(char str[], int len)
+{
+    uint32_t temp = 0;
+    for (int i = 0; i < len; i++)
+    {
+        temp += str[i] << (i * 8);
+
+    }
+    return temp;
+}
+
+uint16_t WavPlayer::getu16(char str[], int len)
+{
+    uint16_t temp = 0;
+    for (int i = 0; i < len; i++)
+    {
+        temp += str[i] << (i * 8);
+    }
+    return temp;
+}
+
+int32_t WavPlayer::get32(char str[], int len)
+{
+    uint32_t temp = 0;
+    for (int i = 0; i < len; i++)
+    {
+        temp += str[i] << (i * 8);
+
+    }
+    return temp;
+}
+
+int16_t WavPlayer::get16(char str[], int len)
+{
+    uint16_t temp = 0;
+    for (int i = 0; i < len; i++)
+    {
+        temp += str[i] << (i * 8);
+    }
+    return temp;
+}
+
+uint32_t WavPlayer::fsru32(FILE *fp, int offset, int len)
+{
+    char temp[4];
+    fseekread(fp, temp, offset, len);
+    return getu32(temp, len);
+}
+
+uint16_t WavPlayer::fsru16(FILE *fp, int offset, int len)
+{
+    char temp[2];
+    fseekread(fp, temp, offset, len);
+    return getu16(temp, len);
+}
+
+void WavPlayer::clear(char* str, int len)
+{
+    for (int i = 0; i < len; i++)
+    {
+        str[i] = 0;
+    }
+}
+
+int WavPlayer::findChunk(FILE *fp, char* match, int len, int fileSize,
+        int startOffset)
+{
+    char temp[5];
+    int count = startOffset;
+    while ((count + 8) < fileSize)
+    {
+        clear(temp, 5);
+        fseekread(fp, temp, count, 4);
+        int chunksize = fsru32(fp, count + 4) + 8;
+        //debug_printf("@ %i Chunk Name: %s Size: %i\n\r", count, temp, chunksize);
+
+        if (strcmp(temp, match) == 0)
+        {
+            return count;
+        }
+        count += chunksize;
+    }
+    return -1;
+}
+
+int WavPlayer::findChunk(FILE *fp, char* match, int len, int startOffset)
+{
+    return findChunk(fp, match, len, config.file_size, startOffset);
+}
+
+void WavPlayer::fgets_m(char* str, int num, FILE* fp)
+{
+    for (int i = 0; i < num; i++)
+    {
+        str[i] = fgetc(fp);
+        //printf("%c",str[i]);
+    }
+}
+
+float WavPlayer::sine_gen(int16_t* buf, int len, float div, float phase)
+{
+    #if WAVPLAYER_GEN_TEST == 1
+    float t = SINE16LENGTH / div;
+    for (int i = 0; i < len; i++)
+    {
+        buf[i] = sine16lookup[int(phase)];
+        //printf("%i\n\r",buf[i]);
+        phase += t;
+        while (phase >= SINE16LENGTH)
+            phase -= SINE16LENGTH;
+    }
+    #endif
+    return phase;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WavPlayer.h	Wed Sep 19 10:58:16 2012 +0000
@@ -0,0 +1,159 @@
+/**
+* @author Giles Barton-Owen
+*
+* @section LICENSE
+*
+* Copyright (c) 2012 mbed
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+* THE SOFTWARE.
+*
+* @section DESCRIPTION
+*    A WAV player library for the TLV320 and the LPC1768's built in I2S peripheral
+*
+*/ 
+
+#ifndef WAVPLAYER_H
+#define WAVPLAYER_H
+
+#include "mbed.h"
+#include "WavPlayerConfig.h"
+#include "RingBuffer.h"
+#include "TLV320.h"
+#include "I2S.h"
+
+/** A class to play WAV files from a file system, tested with USB
+ *
+ * Example (note, this has requires the USB MSC library to be imported):
+ * @code
+ *
+ * #include "mbed.h"
+ * #include "WavPlayer.h"
+ * #include "MSCFileSystem.h"
+ * 
+ * MSCFileSystem msc("msc"); // Mount flash drive under the name "msc"
+ * WavPlayer player;
+ * 
+ * int main() {
+ *    FILE *fp = fopen("/msc/test.wav", "r");  // Open "out.txt" on the local file system for writing
+ *     player.open(&fp);
+ *     player.play();
+ *     fclose(fp);
+ * }
+ * @endcode
+ */
+
+
+class WavPlayer
+{
+public:
+      /** Create a WavPlayer instance
+     * 
+     */
+    WavPlayer();
+    
+    /** Create a WavPlayer instance
+     * 
+     * @param fpp A pointer to a file pointer to read out of
+     */
+    WavPlayer(FILE **fpp);
+    
+    /** Set the file to read out of
+     * 
+     * @param fpp A pointer to a file pointer to read out of
+     */
+    void open(FILE **fpp);
+    
+    /** Extract the header infomation, automatically called by open
+     */
+    int getConfig();
+    
+    /** Play the entire file. Blocking
+     */
+    float play();
+    
+    /** Play the file for a certain number of seconds. Blocking
+     *
+     * @param time The number of seconds to play the file for.
+     */
+    float play(float time);
+    
+    /** Play the file for a certain number of seconds, from a certain start point. Blocking
+     *
+     * @param start        The start time
+     * @param timefor     The number of seconds to play the file for.
+     */
+    float play(float start, float timefor);
+
+
+
+private:
+    WavPlayerConfig config;
+    FILE ** filepp;
+    RingBuffer rbuf;
+
+    I2S i2s;
+    TLV320 codec;
+    static void i2sisr();
+    void i2sisr_();
+    static WavPlayer* instance;
+
+    int fseekread(FILE *fp, char* str, int offset, int len);
+    uint32_t getu32(char str[], int len);
+    uint16_t getu16(char str[], int len);
+    int32_t get32(char str[], int len);
+    int16_t get16(char str[], int len);
+    uint32_t fsru32(FILE *fp, int offset, int len = 4);
+    uint16_t fsru16(FILE *fp, int offset, int len = 2);
+    void clear(char* str, int len);
+
+    int findChunk(FILE *fp, char* match, int len, int fileSize, int startOffset = 12);
+    int findChunk(FILE *fp, char* match, int len, int startOffset = 12);
+    void fgets_m(char* str, int num, FILE* fp);
+
+    float sine_gen(int16_t* buf, int len, float div, float phase);
+
+    bool flag_vol;
+    double volume;
+
+    bool stereo;
+
+    bool flag_play;
+
+    Timer timer;
+    
+    int isr_underrun;
+
+    float read_time;
+    int read_time_div;
+
+    float isr_time;
+    int isr_time_div;
+    
+    float current_time;
+    
+    int slow_count;
+
+    //Timer isrtimer;
+
+    //DigitalOut ext_flag;
+    //DigitalOut run_flag;
+
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WavPlayerConfig.cpp	Wed Sep 19 10:58:16 2012 +0000
@@ -0,0 +1,14 @@
+#include "WavPlayerConfig.h"
+
+WavPlayerConfig::WavPlayerConfig()
+{
+
+    format_tag = 0;
+    channels = 0;
+    samples_per_sec = 0;
+    avg_bytes_per_sec = 0;
+    block_align = 0;
+    bits_per_sample = 0;
+    data_length = 0;
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WavPlayerConfig.h	Wed Sep 19 10:58:16 2012 +0000
@@ -0,0 +1,63 @@
+/**
+* @author Giles Barton-Owen
+*
+* @section LICENSE
+*
+* Copyright (c) 2012 mbed
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy
+* of this software and associated documentation files (the "Software"), to deal
+* in the Software without restriction, including without limitation the rights
+* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+* copies of the Software, and to permit persons to whom the Software is
+* furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in
+* all copies or substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+* THE SOFTWARE.
+*
+* @section DESCRIPTION
+*    A WAV player configuration class for WavPlayer
+*
+*/ 
+
+
+#ifndef WAVPLAYERCONFIG_H
+#define WAVPLAYERCONFIG_H
+
+#include "mbed.h"
+
+class WavPlayerConfig
+{
+public:
+    /*format_tag(uint16_t ft);
+     channels(uint16_t n);
+     samples_per_second(uint32_t sps);
+     avg_bytes_per_second(uint32_t abps);
+     block_align(uint16_t ba);
+     bits_per_sample(uint16_t bps);
+     data_length(uint32_t len);*/
+
+    WavPlayerConfig();
+
+    uint16_t format_tag;
+    uint16_t channels;
+    uint32_t samples_per_sec;
+    uint32_t avg_bytes_per_sec;
+    uint16_t block_align;
+    uint16_t bits_per_sample;
+    uint32_t data_length;
+    uint32_t file_size;
+
+private:
+
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sinelookup.h	Wed Sep 19 10:58:16 2012 +0000
@@ -0,0 +1,213 @@
+#define SINE16LENGTH 1024
+#define SINE32LENGTH 1024
+
+const int16_t sine16lookup[] = {    0, 201, 402, 603, 804, 1005, 1206, 1407, 1607, 1808, 2009, 
+                                    2210, 2410, 2611, 2811, 3011, 3211, 3411, 3611, 3811, 4011, 
+                                    4210, 4409, 4609, 4808, 5006, 5205, 5403, 5602, 5800, 5997, 
+                                    6195, 6392, 6589, 6786, 6983, 7179, 7375, 7571, 7766, 7961, 
+                                    8156, 8351, 8545, 8739, 8933, 9126, 9319, 9512, 9704, 9896, 
+                                    10087, 10278, 10469, 10659, 10849, 11039, 11228, 11416, 11605, 11793, 
+                                    11980, 12167, 12353, 12539, 12725, 12910, 13094, 13278, 13462, 13645, 
+                                    13828, 14010, 14191, 14372, 14552, 14732, 14912, 15090, 15269, 15446, 
+                                    15623, 15800, 15976, 16151, 16325, 16499, 16673, 16846, 17018, 17189, 
+                                    17360, 17530, 17700, 17869, 18037, 18204, 18371, 18537, 18703, 18868, 
+                                    19032, 19195, 19358, 19519, 19681, 19841, 20001, 20159, 20318, 20475, 
+                                    20631, 20787, 20942, 21097, 21250, 21403, 21555, 21706, 21856, 22005, 
+                                    22154, 22301, 22448, 22594, 22740, 22884, 23027, 23170, 23312, 23453, 
+                                    23593, 23732, 23870, 24007, 24144, 24279, 24414, 24547, 24680, 24812, 
+                                    24943, 25073, 25201, 25330, 25457, 25583, 25708, 25832, 25955, 26077, 
+                                    26199, 26319, 26438, 26557, 26674, 26790, 26905, 27020, 27133, 27245, 
+                                    27356, 27466, 27576, 27684, 27791, 27897, 28002, 28106, 28208, 28310, 
+                                    28411, 28511, 28609, 28707, 28803, 28898, 28993, 29086, 29178, 29269, 
+                                    29359, 29447, 29535, 29621, 29707, 29791, 29874, 29956, 30037, 30117, 
+                                    30196, 30273, 30350, 30425, 30499, 30572, 30644, 30714, 30784, 30852, 
+                                    30919, 30985, 31050, 31114, 31176, 31237, 31298, 31357, 31414, 31471, 
+                                    31526, 31581, 31634, 31685, 31736, 31785, 31834, 31881, 31927, 31971, 
+                                    32015, 32057, 32098, 32138, 32176, 32214, 32250, 32285, 32319, 32351, 
+                                    32383, 32413, 32442, 32469, 32496, 32521, 32545, 32568, 32589, 32610, 
+                                    32629, 32647, 32663, 32679, 32693, 32706, 32718, 32728, 32737, 32745, 
+                                    32752, 32758, 32762, 32765, 32767, 32767, 32767, 32765, 32762, 32758, 
+                                    32752, 32745, 32737, 32728, 32718, 32706, 32693, 32679, 32663, 32647, 
+                                    32629, 32610, 32589, 32568, 32545, 32521, 32496, 32469, 32442, 32413, 
+                                    32383, 32351, 32319, 32285, 32250, 32214, 32176, 32138, 32098, 32057, 
+                                    32015, 31971, 31927, 31881, 31834, 31785, 31736, 31685, 31634, 31581, 
+                                    31526, 31471, 31414, 31357, 31298, 31237, 31176, 31114, 31050, 30985, 
+                                    30919, 30852, 30784, 30714, 30644, 30572, 30499, 30425, 30350, 30273, 
+                                    30196, 30117, 30037, 29956, 29874, 29791, 29707, 29621, 29535, 29447, 
+                                    29359, 29269, 29178, 29086, 28993, 28898, 28803, 28707, 28609, 28511, 
+                                    28411, 28310, 28208, 28106, 28002, 27897, 27791, 27684, 27576, 27466, 
+                                    27356, 27245, 27133, 27020, 26905, 26790, 26674, 26557, 26438, 26319, 
+                                    26199, 26077, 25955, 25832, 25708, 25583, 25457, 25330, 25201, 25073, 
+                                    24943, 24812, 24680, 24547, 24414, 24279, 24144, 24007, 23870, 23732, 
+                                    23593, 23453, 23312, 23170, 23027, 22884, 22740, 22594, 22448, 22301, 
+                                    22154, 22005, 21856, 21706, 21555, 21403, 21250, 21097, 20942, 20787, 
+                                    20631, 20475, 20318, 20159, 20001, 19841, 19681, 19519, 19358, 19195, 
+                                    19032, 18868, 18703, 18537, 18371, 18204, 18037, 17869, 17700, 17530, 
+                                    17360, 17189, 17018, 16846, 16673, 16499, 16325, 16151, 15976, 15800, 
+                                    15623, 15446, 15269, 15090, 14912, 14732, 14552, 14372, 14191, 14010, 
+                                    13828, 13645, 13462, 13278, 13094, 12910, 12725, 12539, 12353, 12167, 
+                                    11980, 11793, 11605, 11416, 11228, 11039, 10849, 10659, 10469, 10278, 
+                                    10087, 9896, 9704, 9512, 9319, 9126, 8933, 8739, 8545, 8351, 
+                                    8156, 7961, 7766, 7571, 7375, 7179, 6983, 6786, 6589, 6392, 
+                                    6195, 5997, 5800, 5602, 5403, 5205, 5006, 4808, 4609, 4409, 
+                                    4210, 4011, 3811, 3611, 3411, 3211, 3011, 2811, 2611, 2410, 
+                                    2210, 2009, 1808, 1607, 1407, 1206, 1005, 804, 603, 402, 
+                                    201, 0, -201, -402, -603, -804, -1005, -1206, -1407, -1607, 
+                                    -1808, -2009, -2210, -2410, -2611, -2811, -3011, -3211, -3411, -3611, 
+                                    -3811, -4011, -4210, -4409, -4609, -4808, -5006, -5205, -5403, -5602, 
+                                    -5800, -5997, -6195, -6392, -6589, -6786, -6983, -7179, -7375, -7571, 
+                                    -7766, -7961, -8156, -8351, -8545, -8739, -8933, -9126, -9319, -9512, 
+                                    -9704, -9896, -10087, -10278, -10469, -10659, -10849, -11039, -11228, -11416, 
+                                    -11605, -11793, -11980, -12167, -12353, -12539, -12725, -12910, -13094, -13278, 
+                                    -13462, -13645, -13828, -14010, -14191, -14372, -14552, -14732, -14912, -15090, 
+                                    -15269, -15446, -15623, -15800, -15976, -16151, -16325, -16499, -16673, -16846, 
+                                    -17018, -17189, -17360, -17530, -17700, -17869, -18037, -18204, -18371, -18537, 
+                                    -18703, -18868, -19032, -19195, -19358, -19519, -19681, -19841, -20001, -20159, 
+                                    -20318, -20475, -20631, -20787, -20942, -21097, -21250, -21403, -21555, -21706, 
+                                    -21856, -22005, -22154, -22301, -22448, -22594, -22740, -22884, -23027, -23170, 
+                                    -23312, -23453, -23593, -23732, -23870, -24007, -24144, -24279, -24414, -24547, 
+                                    -24680, -24812, -24943, -25073, -25201, -25330, -25457, -25583, -25708, -25832, 
+                                    -25955, -26077, -26199, -26319, -26438, -26557, -26674, -26790, -26905, -27020, 
+                                    -27133, -27245, -27356, -27466, -27576, -27684, -27791, -27897, -28002, -28106, 
+                                    -28208, -28310, -28411, -28511, -28609, -28707, -28803, -28898, -28993, -29086, 
+                                    -29178, -29269, -29359, -29447, -29535, -29621, -29707, -29791, -29874, -29956, 
+                                    -30037, -30117, -30196, -30273, -30350, -30425, -30499, -30572, -30644, -30714, 
+                                    -30784, -30852, -30919, -30985, -31050, -31114, -31176, -31237, -31298, -31357, 
+                                    -31414, -31471, -31526, -31581, -31634, -31685, -31736, -31785, -31834, -31881, 
+                                    -31927, -31971, -32015, -32057, -32098, -32138, -32176, -32214, -32250, -32285, 
+                                    -32319, -32351, -32383, -32413, -32442, -32469, -32496, -32521, -32545, -32568, 
+                                    -32589, -32610, -32629, -32647, -32663, -32679, -32693, -32706, -32718, -32728, 
+                                    -32737, -32745, -32752, -32758, -32762, -32765, -32767, -32768, -32767, -32765, 
+                                    -32762, -32758, -32752, -32745, -32737, -32728, -32718, -32706, -32693, -32679, 
+                                    -32663, -32647, -32629, -32610, -32589, -32568, -32545, -32521, -32496, -32469, 
+                                    -32442, -32413, -32383, -32351, -32319, -32285, -32250, -32214, -32176, -32138, 
+                                    -32098, -32057, -32015, -31971, -31927, -31881, -31834, -31785, -31736, -31685, 
+                                    -31634, -31581, -31526, -31471, -31414, -31357, -31298, -31237, -31176, -31114, 
+                                    -31050, -30985, -30919, -30852, -30784, -30714, -30644, -30572, -30499, -30425, 
+                                    -30350, -30273, -30196, -30117, -30037, -29956, -29874, -29791, -29707, -29621, 
+                                    -29535, -29447, -29359, -29269, -29178, -29086, -28993, -28898, -28803, -28707, 
+                                    -28609, -28511, -28411, -28310, -28208, -28106, -28002, -27897, -27791, -27684, 
+                                    -27576, -27466, -27356, -27245, -27133, -27020, -26905, -26790, -26674, -26557, 
+                                    -26438, -26319, -26199, -26077, -25955, -25832, -25708, -25583, -25457, -25330, 
+                                    -25201, -25073, -24943, -24812, -24680, -24547, -24414, -24279, -24144, -24007, 
+                                    -23870, -23732, -23593, -23453, -23312, -23170, -23027, -22884, -22740, -22594, 
+                                    -22448, -22301, -22154, -22005, -21856, -21706, -21555, -21403, -21250, -21097, 
+                                    -20942, -20787, -20631, -20475, -20318, -20159, -20001, -19841, -19681, -19519, 
+                                    -19358, -19195, -19032, -18868, -18703, -18537, -18371, -18204, -18037, -17869, 
+                                    -17700, -17530, -17360, -17189, -17018, -16846, -16673, -16499, -16325, -16151, 
+                                    -15976, -15800, -15623, -15446, -15269, -15090, -14912, -14732, -14552, -14372, 
+                                    -14191, -14010, -13828, -13645, -13462, -13278, -13094, -12910, -12725, -12539, 
+                                    -12353, -12167, -11980, -11793, -11605, -11416, -11228, -11039, -10849, -10659, 
+                                    -10469, -10278, -10087, -9896, -9704, -9512, -9319, -9126, -8933, -8739, 
+                                    -8545, -8351, -8156, -7961, -7766, -7571, -7375, -7179, -6983, -6786, 
+                                    -6589, -6392, -6195, -5997, -5800, -5602, -5403, -5205, -5006, -4808, 
+                                    -4609, -4409, -4210, -4011, -3811, -3611, -3411, -3211, -3011, -2811, 
+                                    -2611, -2410, -2210, -2009, -1808, -1607, -1407, -1206, -1005, -804, 
+                                    -603, -402, -201};
+ 
+  const int32_t sine32lookup[] = {    0, 13176711, 26352927, 39528151, 52701886, 65873638, 79042909, 92209204, 105372028, 118530884, 131685278, 
+                                    144834714, 157978697, 171116732, 184248325, 197372981, 210490206, 223599506, 236700387, 249792357, 262874923, 
+                                    275947591, 289009870, 302061268, 315101294, 328129456, 341145265, 354148229, 367137860, 380113668, 393075166, 
+                                    406021864, 418953276, 431868914, 444768293, 457650927, 470516330, 483364019, 496193509, 509004318, 521795963, 
+                                    534567962, 547319836, 560051103, 572761285, 585449902, 598116478, 610760535, 623381597, 635979189, 648552837, 
+                                    661102068, 673626408, 686125386, 698598532, 711045377, 723465451, 735858287, 748223418, 760560379, 772868705, 
+                                    785147934, 797397602, 809617248, 821806413, 833964637, 846091463, 858186434, 870249095, 882278991, 894275670, 
+                                    906238680, 918167571, 930061894, 941921200, 953745043, 965532978, 977284561, 988999351, 1000676905, 1012316784, 
+                                    1023918549, 1035481765, 1047005996, 1058490807, 1069935767, 1081340445, 1092704410, 1104027236, 1115308496, 1126547765, 
+                                    1137744620, 1148898640, 1160009404, 1171076495, 1182099495, 1193077990, 1204011566, 1214899812, 1225742318, 1236538675, 
+                                    1247288477, 1257991319, 1268646799, 1279254515, 1289814068, 1300325060, 1310787095, 1321199780, 1331562723, 1341875533, 
+                                    1352137822, 1362349204, 1372509294, 1382617710, 1392674071, 1402677999, 1412629117, 1422527050, 1432371426, 1442161874, 
+                                    1451898025, 1461579513, 1471205974, 1480777044, 1490292364, 1499751575, 1509154322, 1518500249, 1527789007, 1537020243, 
+                                    1546193612, 1555308767, 1564365366, 1573363068, 1582301533, 1591180425, 1599999411, 1608758157, 1617456334, 1626093615, 
+                                    1634669675, 1643184190, 1651636841, 1660027308, 1668355276, 1676620431, 1684822463, 1692961062, 1701035922, 1709046739, 
+                                    1716993211, 1724875039, 1732691927, 1740443580, 1748129706, 1755750017, 1763304224, 1770792044, 1778213194, 1785567396, 
+                                    1792854372, 1800073848, 1807225552, 1814309216, 1821324572, 1828271355, 1835149306, 1841958164, 1848697673, 1855367580, 
+                                    1861967634, 1868497585, 1874957189, 1881346201, 1887664382, 1893911494, 1900087300, 1906191570, 1912224072, 1918184580, 
+                                    1924072870, 1929888719, 1935631910, 1941302224, 1946899450, 1952423376, 1957873795, 1963250501, 1968553291, 1973781967, 
+                                    1978936330, 1984016188, 1989021349, 1993951624, 1998806829, 2003586779, 2008291295, 2012920200, 2017473320, 2021950483, 
+                                    2026351521, 2030676268, 2034924561, 2039096241, 2043191149, 2047209133, 2051150040, 2055013723, 2058800035, 2062508835, 
+                                    2066139983, 2069693341, 2073168777, 2076566159, 2079885360, 2083126254, 2086288719, 2089372637, 2092377892, 2095304369, 
+                                    2098151959, 2100920556, 2103610053, 2106220351, 2108751351, 2111202958, 2113575079, 2115867625, 2118080510, 2120213651, 
+                                    2122266966, 2124240380, 2126133817, 2127947206, 2129680479, 2131333571, 2132906419, 2134398965, 2135811152, 2137142927, 
+                                    2138394239, 2139565042, 2140655292, 2141664948, 2142593970, 2143442326, 2144209982, 2144896909, 2145503083, 2146028479, 
+                                    2146473079, 2146836866, 2147119825, 2147321946, 2147443222, 2147483647, 2147443222, 2147321946, 2147119825, 2146836866, 
+                                    2146473079, 2146028479, 2145503083, 2144896909, 2144209982, 2143442326, 2142593970, 2141664948, 2140655292, 2139565042, 
+                                    2138394239, 2137142927, 2135811152, 2134398965, 2132906419, 2131333571, 2129680479, 2127947206, 2126133817, 2124240380, 
+                                    2122266966, 2120213651, 2118080510, 2115867625, 2113575079, 2111202958, 2108751351, 2106220351, 2103610053, 2100920556, 
+                                    2098151959, 2095304369, 2092377892, 2089372637, 2086288719, 2083126254, 2079885360, 2076566159, 2073168777, 2069693341, 
+                                    2066139983, 2062508835, 2058800035, 2055013723, 2051150040, 2047209133, 2043191149, 2039096241, 2034924561, 2030676268, 
+                                    2026351521, 2021950483, 2017473320, 2012920200, 2008291295, 2003586779, 1998806829, 1993951624, 1989021349, 1984016188, 
+                                    1978936330, 1973781967, 1968553291, 1963250501, 1957873795, 1952423376, 1946899450, 1941302224, 1935631910, 1929888719, 
+                                    1924072870, 1918184580, 1912224072, 1906191570, 1900087300, 1893911494, 1887664382, 1881346201, 1874957189, 1868497585, 
+                                    1861967634, 1855367580, 1848697673, 1841958164, 1835149306, 1828271355, 1821324572, 1814309216, 1807225552, 1800073848, 
+                                    1792854372, 1785567396, 1778213194, 1770792044, 1763304224, 1755750017, 1748129706, 1740443580, 1732691927, 1724875039, 
+                                    1716993211, 1709046739, 1701035922, 1692961062, 1684822463, 1676620431, 1668355276, 1660027308, 1651636841, 1643184190, 
+                                    1634669675, 1626093615, 1617456334, 1608758157, 1599999411, 1591180425, 1582301533, 1573363068, 1564365366, 1555308767, 
+                                    1546193612, 1537020243, 1527789007, 1518500249, 1509154322, 1499751575, 1490292364, 1480777044, 1471205974, 1461579513, 
+                                    1451898025, 1442161874, 1432371426, 1422527050, 1412629117, 1402677999, 1392674071, 1382617710, 1372509294, 1362349204, 
+                                    1352137822, 1341875533, 1331562723, 1321199780, 1310787095, 1300325060, 1289814068, 1279254515, 1268646799, 1257991319, 
+                                    1247288477, 1236538675, 1225742318, 1214899812, 1204011566, 1193077990, 1182099495, 1171076495, 1160009404, 1148898640, 
+                                    1137744620, 1126547765, 1115308496, 1104027236, 1092704410, 1081340445, 1069935767, 1058490807, 1047005996, 1035481765, 
+                                    1023918549, 1012316784, 1000676905, 988999351, 977284561, 965532978, 953745043, 941921200, 930061894, 918167571, 
+                                    906238680, 894275670, 882278991, 870249095, 858186434, 846091463, 833964637, 821806413, 809617248, 797397602, 
+                                    785147934, 772868705, 760560379, 748223418, 735858287, 723465451, 711045377, 698598532, 686125386, 673626408, 
+                                    661102068, 648552837, 635979189, 623381597, 610760535, 598116478, 585449902, 572761285, 560051103, 547319836, 
+                                    534567962, 521795963, 509004318, 496193509, 483364019, 470516330, 457650927, 444768293, 431868914, 418953276, 
+                                    406021864, 393075166, 380113668, 367137860, 354148229, 341145265, 328129456, 315101294, 302061268, 289009870, 
+                                    275947591, 262874923, 249792357, 236700387, 223599506, 210490206, 197372981, 184248325, 171116732, 157978697, 
+                                    144834714, 131685278, 118530884, 105372028, 92209204, 79042909, 65873638, 52701886, 39528151, 26352927, 
+                                    13176711, 0, -13176711, -26352927, -39528151, -52701886, -65873638, -79042909, -92209204, -105372028, 
+                                    -118530884, -131685278, -144834714, -157978697, -171116732, -184248325, -197372981, -210490206, -223599506, -236700387, 
+                                    -249792357, -262874923, -275947591, -289009870, -302061268, -315101294, -328129456, -341145265, -354148229, -367137860, 
+                                    -380113668, -393075166, -406021864, -418953276, -431868914, -444768293, -457650927, -470516330, -483364019, -496193509, 
+                                    -509004318, -521795963, -534567962, -547319836, -560051103, -572761285, -585449902, -598116478, -610760535, -623381597, 
+                                    -635979189, -648552837, -661102068, -673626408, -686125386, -698598532, -711045377, -723465451, -735858287, -748223418, 
+                                    -760560379, -772868705, -785147934, -797397602, -809617248, -821806413, -833964637, -846091463, -858186434, -870249095, 
+                                    -882278991, -894275670, -906238680, -918167571, -930061894, -941921200, -953745043, -965532978, -977284561, -988999351, 
+                                    -1000676905, -1012316784, -1023918549, -1035481765, -1047005996, -1058490807, -1069935767, -1081340445, -1092704410, -1104027236, 
+                                    -1115308496, -1126547765, -1137744620, -1148898640, -1160009404, -1171076495, -1182099495, -1193077990, -1204011566, -1214899812, 
+                                    -1225742318, -1236538675, -1247288477, -1257991319, -1268646799, -1279254515, -1289814068, -1300325060, -1310787095, -1321199780, 
+                                    -1331562723, -1341875533, -1352137822, -1362349204, -1372509294, -1382617710, -1392674071, -1402677999, -1412629117, -1422527050, 
+                                    -1432371426, -1442161874, -1451898025, -1461579513, -1471205974, -1480777044, -1490292364, -1499751575, -1509154322, -1518500249, 
+                                    -1527789007, -1537020243, -1546193612, -1555308767, -1564365366, -1573363068, -1582301533, -1591180425, -1599999411, -1608758157, 
+                                    -1617456334, -1626093615, -1634669675, -1643184190, -1651636841, -1660027308, -1668355276, -1676620431, -1684822463, -1692961062, 
+                                    -1701035922, -1709046739, -1716993211, -1724875039, -1732691927, -1740443580, -1748129706, -1755750017, -1763304224, -1770792044, 
+                                    -1778213194, -1785567396, -1792854372, -1800073848, -1807225552, -1814309216, -1821324572, -1828271355, -1835149306, -1841958164, 
+                                    -1848697673, -1855367580, -1861967634, -1868497585, -1874957189, -1881346201, -1887664382, -1893911494, -1900087300, -1906191570, 
+                                    -1912224072, -1918184580, -1924072870, -1929888719, -1935631910, -1941302224, -1946899450, -1952423376, -1957873795, -1963250501, 
+                                    -1968553291, -1973781967, -1978936330, -1984016188, -1989021349, -1993951624, -1998806829, -2003586779, -2008291295, -2012920200, 
+                                    -2017473320, -2021950483, -2026351521, -2030676268, -2034924561, -2039096241, -2043191149, -2047209133, -2051150040, -2055013723, 
+                                    -2058800035, -2062508835, -2066139983, -2069693341, -2073168777, -2076566159, -2079885360, -2083126254, -2086288719, -2089372637, 
+                                    -2092377892, -2095304369, -2098151959, -2100920556, -2103610053, -2106220351, -2108751351, -2111202958, -2113575079, -2115867625, 
+                                    -2118080510, -2120213651, -2122266966, -2124240380, -2126133817, -2127947206, -2129680479, -2131333571, -2132906419, -2134398965, 
+                                    -2135811152, -2137142927, -2138394239, -2139565042, -2140655292, -2141664948, -2142593970, -2143442326, -2144209982, -2144896909, 
+                                    -2145503083, -2146028479, -2146473079, -2146836866, -2147119825, -2147321946, -2147443222, -2147483648, -2147443222, -2147321946, 
+                                    -2147119825, -2146836866, -2146473079, -2146028479, -2145503083, -2144896909, -2144209982, -2143442326, -2142593970, -2141664948, 
+                                    -2140655292, -2139565042, -2138394239, -2137142927, -2135811152, -2134398965, -2132906419, -2131333571, -2129680479, -2127947206, 
+                                    -2126133817, -2124240380, -2122266966, -2120213651, -2118080510, -2115867625, -2113575079, -2111202958, -2108751351, -2106220351, 
+                                    -2103610053, -2100920556, -2098151959, -2095304369, -2092377892, -2089372637, -2086288719, -2083126254, -2079885360, -2076566159, 
+                                    -2073168777, -2069693341, -2066139983, -2062508835, -2058800035, -2055013723, -2051150040, -2047209133, -2043191149, -2039096241, 
+                                    -2034924561, -2030676268, -2026351521, -2021950483, -2017473320, -2012920200, -2008291295, -2003586779, -1998806829, -1993951624, 
+                                    -1989021349, -1984016188, -1978936330, -1973781967, -1968553291, -1963250501, -1957873795, -1952423376, -1946899450, -1941302224, 
+                                    -1935631910, -1929888719, -1924072870, -1918184580, -1912224072, -1906191570, -1900087300, -1893911494, -1887664382, -1881346201, 
+                                    -1874957189, -1868497585, -1861967634, -1855367580, -1848697673, -1841958164, -1835149306, -1828271355, -1821324572, -1814309216, 
+                                    -1807225552, -1800073848, -1792854372, -1785567396, -1778213194, -1770792044, -1763304224, -1755750017, -1748129706, -1740443580, 
+                                    -1732691927, -1724875039, -1716993211, -1709046739, -1701035922, -1692961062, -1684822463, -1676620431, -1668355276, -1660027308, 
+                                    -1651636841, -1643184190, -1634669675, -1626093615, -1617456334, -1608758157, -1599999411, -1591180425, -1582301533, -1573363068, 
+                                    -1564365366, -1555308767, -1546193612, -1537020243, -1527789007, -1518500249, -1509154322, -1499751575, -1490292364, -1480777044, 
+                                    -1471205974, -1461579513, -1451898025, -1442161874, -1432371426, -1422527050, -1412629117, -1402677999, -1392674071, -1382617710, 
+                                    -1372509294, -1362349204, -1352137822, -1341875533, -1331562723, -1321199780, -1310787095, -1300325060, -1289814068, -1279254515, 
+                                    -1268646799, -1257991319, -1247288477, -1236538675, -1225742318, -1214899812, -1204011566, -1193077990, -1182099495, -1171076495, 
+                                    -1160009404, -1148898640, -1137744620, -1126547765, -1115308496, -1104027236, -1092704410, -1081340445, -1069935767, -1058490807, 
+                                    -1047005996, -1035481765, -1023918549, -1012316784, -1000676905, -988999351, -977284561, -965532978, -953745043, -941921200, 
+                                    -930061894, -918167571, -906238680, -894275670, -882278991, -870249095, -858186434, -846091463, -833964637, -821806413, 
+                                    -809617248, -797397602, -785147934, -772868705, -760560379, -748223418, -735858287, -723465451, -711045377, -698598532, 
+                                    -686125386, -673626408, -661102068, -648552837, -635979189, -623381597, -610760535, -598116478, -585449902, -572761285, 
+                                    -560051103, -547319836, -534567962, -521795963, -509004318, -496193509, -483364019, -470516330, -457650927, -444768293, 
+                                    -431868914, -418953276, -406021864, -393075166, -380113668, -367137860, -354148229, -341145265, -328129456, -315101294, 
+                                    -302061268, -289009870, -275947591, -262874923, -249792357, -236700387, -223599506, -210490206, -197372981, -184248325, 
+                                    -171116732, -157978697, -144834714, -131685278, -118530884, -105372028, -92209204, -79042909, -65873638, -52701886, 
+                                    -39528151, -26352927, -13176711};
+                                                                        
+                                     
+                                     
\ No newline at end of file