aboutsummaryrefslogtreecommitdiff
path: root/test/load wav.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/load wav.cpp')
-rw-r--r--test/load wav.cpp65
1 files changed, 0 insertions, 65 deletions
diff --git a/test/load wav.cpp b/test/load wav.cpp
deleted file mode 100644
index 4cd2756..0000000
--- a/test/load wav.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-#include "utils.h"
-#if UNITTEST
-
-#include <iostream>
-#include <stdio.h>
-#include <fstream>
-#include "../audio/sdl/source.h"
-#include "../audio/sdl/audio.h"
-
-using namespace jin::audio;
-using namespace std;
-
-struct WAV
-{
- int samples;
- int channel, samplerate;
- short* data;
- int pos;
-};
-
-WAV wav;
-static void callbackfunc(void *userdata, Uint8 *stream, int len)
-{
- if (wav.pos > wav.samples)
- wav.pos = 0;
- int16_t* buffer = (int16_t*)stream;
- int l = len / 2;
- for (int i = 0; i < l; ++i)
- {
- buffer[i] = wav.data[wav.pos + i];
- }
- wav.pos += l;
-}
-int length = 2226052;
-char buf[2226052];
-
-int main(int argc, char* argv[])
-{
- Audio* audio = SDLAudio::get();
- ifstream fs;
- fs.open("a.wav", ios::binary);
- fs.read(buf, length);
- SDLAudioSetting setting;
- SDL_AudioSpec spe;
- setting.callback = callbackfunc;
- wav_t wavconfig;
- if (wav_read(&wavconfig, buf, length) != 0)
- {
- cout << "load wav failed\n";
- }
- wav.channel = wavconfig.channels;
- wav.data = (short*)wavconfig.data;
- wav.pos = 0;
- wav.samplerate = wavconfig.samplerate;
- wav.samples = wavconfig.length;
- audio->init(&setting);
- while (true)
- {
- SDL_Delay(100);
- }
- audio->quit();
- return 0;
-}
-
-#endif \ No newline at end of file