2 * Copyright (C) 2008-2013 Team XBMC
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, see
17 * <http://www.gnu.org/licenses/>.
30 #include "src/vgmstream.h"
32 long __declspec(dllexport) DLL_Init()
37 long __declspec(dllexport) DLL_LoadVGM(const char* szFileName, int* sampleRate, int* sampleSize, int* channels)
41 if ((result = init_vgmstream(szFileName)) == NULL)
44 *sampleRate = result->sample_rate;
46 *channels = result->channels;
50 void __declspec(dllexport) DLL_FreeVGM(long vgm)
52 close_vgmstream((VGMSTREAM*)vgm);
55 int __declspec(dllexport) DLL_FillBuffer(long vgm, char* szBuffer, int iSize)
57 VGMSTREAM* song = (VGMSTREAM*)vgm;
58 render_vgmstream((sample*)szBuffer,iSize/(2*song->channels),(VGMSTREAM*)vgm);
63 unsigned long __declspec(dllexport) DLL_Seek(long vgm, unsigned long timepos)
65 VGMSTREAM* song = (VGMSTREAM*)vgm;
66 int16_t* buffer = new int16_t[576*song->channels];
67 long samples_to_do = (long)timepos * song->sample_rate / 1000L;
68 if (samples_to_do < song->current_sample )
69 reset_vgmstream(song);
71 samples_to_do -= song->current_sample;
73 while (samples_to_do > 0)
75 long l = samples_to_do>576?576:samples_to_do;
76 render_vgmstream(buffer,l,song);
84 unsigned long __declspec(dllexport) DLL_GetLength(long vgm)
86 VGMSTREAM* song = (VGMSTREAM*)vgm;
88 return song->num_samples/song->sample_rate*1000;