mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-12 01:30:49 +01:00
initial foobar2000 stuff
git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@199 51a99a44-fe44-0410-b1ba-c3e57ba2b86b
This commit is contained in:
parent
882eaf0814
commit
caa264ddca
202
fb2k/foo_input_vgmstream.vcproj
Normal file
202
fb2k/foo_input_vgmstream.vcproj
Normal file
@ -0,0 +1,202 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8.00"
|
||||
Name="foo_input_vgmstream"
|
||||
ProjectGUID="{F3739CF2-F422-4A3D-BB0A-53C5D4C5ABA0}"
|
||||
Keyword="Win32Proj"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="Debug"
|
||||
IntermediateDirectory="Debug"
|
||||
ConfigurationType="2"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""C:\projects\SDK-2007-02-04\foobar2000\SDK";"C:\projects\SDK-2007-02-04\foobar2000\shared";"C:\projects\SDK-2007-02-04\foobar2000\helpers""
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;IN_VGMSTREAM_EXPORTS;"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="1"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="shared.lib foobar2000_SDKd.lib foobar2000_component_clientd.lib pfcd.lib"
|
||||
LinkIncremental="2"
|
||||
AdditionalLibraryDirectories="C:\projects\SDK-2007-02-04\foobar2000\lib"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="2"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="Release"
|
||||
IntermediateDirectory="Release"
|
||||
ConfigurationType="2"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories=""C:\projects\SDK-2007-02-04\foobar2000\SDK";"C:\projects\SDK-2007-02-04\foobar2000\shared";"C:\projects\SDK-2007-02-04\foobar2000\helpers""
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;IN_VGMSTREAM_EXPORTS;"
|
||||
RuntimeLibrary="2"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="shared.lib foobar2000_SDK.lib foobar2000_component_client.lib pfc.lib"
|
||||
LinkIncremental="2"
|
||||
AdditionalLibraryDirectories="C:\projects\SDK-2007-02-04\foobar2000\lib"
|
||||
SubSystem="2"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\foo_vgmstream.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
|
||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||
>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\foostream.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\in_vgmstream.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
25
fb2k/foo_vgmstream.h
Normal file
25
fb2k/foo_vgmstream.h
Normal file
@ -0,0 +1,25 @@
|
||||
#ifndef _FOO_VGMSTREAM_
|
||||
#define _FOO_VGMSTREAM_
|
||||
|
||||
typedef struct _FOO_STREAMFILE {
|
||||
struct _STREAMFILE sf;
|
||||
abort_callback * p_abort;
|
||||
service_ptr_t<file> m_file;
|
||||
char name[260];
|
||||
off_t offset;
|
||||
size_t validsize;
|
||||
uint8_t * buffer;
|
||||
size_t buffersize;
|
||||
} FOO_STREAMFILE;
|
||||
|
||||
|
||||
static STREAMFILE * open_foo_streamfile_buffer_by_file(service_ptr_t<file> m_file,const char * const filename, size_t buffersize, abort_callback * p_abort);
|
||||
STREAMFILE * open_foo_streamfile_buffer(const char * const filename, size_t buffersize, abort_callback * p_abort);
|
||||
STREAMFILE * open_foo_streamfile(const char * const filename, abort_callback * p_abort);
|
||||
|
||||
#define DECLARE_MULTIPLE_FILE_TYPE(NAME,EXTENSION) \
|
||||
namespace { static input_file_type_impl g_filetype_instance_##EXTENSION(NAME,"*." #EXTENSION ,true); \
|
||||
static service_factory_single_ref_t<input_file_type_impl> g_filetype_service##EXTENSION(g_filetype_instance_##EXTENSION); }
|
||||
|
||||
|
||||
#endif
|
197
fb2k/foostream.cpp
Normal file
197
fb2k/foostream.cpp
Normal file
@ -0,0 +1,197 @@
|
||||
#ifdef _MSC_VER
|
||||
#define _CRT_SECURE_NO_DEPRECATE
|
||||
#endif
|
||||
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#include <commctrl.h>
|
||||
#include <stdio.h>
|
||||
#include <io.h>
|
||||
|
||||
#include <foobar2000.h>
|
||||
#include <helpers.h>
|
||||
#include <shared.h>
|
||||
|
||||
extern "C" {
|
||||
#include "../src/vgmstream.h"
|
||||
#include "../src/util.h"
|
||||
}
|
||||
#include "foo_vgmstream.h"
|
||||
|
||||
|
||||
static size_t read_the_rest_foo(uint8_t * dest, off_t offset, size_t length, FOO_STREAMFILE * streamfile) {
|
||||
size_t length_read_total=0;
|
||||
|
||||
/* is the beginning at least there? */
|
||||
if (offset >= streamfile->offset && offset < streamfile->offset+streamfile->validsize) {
|
||||
size_t length_read;
|
||||
off_t offset_into_buffer = offset-streamfile->offset;
|
||||
length_read = streamfile->validsize-offset_into_buffer;
|
||||
memcpy(dest,streamfile->buffer+offset_into_buffer,length_read);
|
||||
length_read_total += length_read;
|
||||
length -= length_read;
|
||||
offset += length_read;
|
||||
dest += length_read;
|
||||
}
|
||||
|
||||
/* TODO: What would make more sense here is to read the whole request
|
||||
* at once into the dest buffer, as it must be large enough, and then
|
||||
* copy some part of that into our own buffer.
|
||||
* The destination buffer is supposed to be much smaller than the
|
||||
* STREAMFILE buffer, though. Maybe we should only ever return up
|
||||
* to the buffer size to avoid having to deal with things like this
|
||||
* which are outside of my intended use.
|
||||
*/
|
||||
/* read as much of the beginning of the request as possible, proceed */
|
||||
while (length>0) {
|
||||
size_t length_to_read;
|
||||
size_t length_read=0;
|
||||
streamfile->validsize=0;
|
||||
|
||||
streamfile->m_file->seek(offset,*streamfile->p_abort);
|
||||
if (streamfile->m_file->is_eof(*streamfile->p_abort)) return length_read;
|
||||
|
||||
streamfile->offset=offset;
|
||||
|
||||
/* decide how much must be read this time */
|
||||
if (length>streamfile->buffersize) length_to_read=streamfile->buffersize;
|
||||
else length_to_read=length;
|
||||
|
||||
/* always try to fill the buffer */
|
||||
length_read = streamfile->m_file->read(streamfile->buffer,streamfile->buffersize,*streamfile->p_abort);
|
||||
streamfile->validsize=length_read;
|
||||
|
||||
#ifdef PROFILE_STREAMFILE
|
||||
streamfile->bytes_read += length_read;
|
||||
#endif
|
||||
|
||||
/* if we can't get enough to satisfy the request we give up */
|
||||
if (length_read < length_to_read) {
|
||||
memcpy(dest,streamfile->buffer,length_read);
|
||||
length_read_total+=length_read;
|
||||
return length_read_total;
|
||||
}
|
||||
|
||||
/* use the new buffer */
|
||||
memcpy(dest,streamfile->buffer,length_to_read);
|
||||
length_read_total+=length_to_read;
|
||||
length-=length_to_read;
|
||||
dest+=length_to_read;
|
||||
offset+=length_to_read;
|
||||
}
|
||||
|
||||
return length_read_total;
|
||||
}
|
||||
|
||||
static size_t read_foo(FOO_STREAMFILE *streamfile, uint8_t * dest, off_t offset, size_t length) {
|
||||
|
||||
if (!streamfile || !dest || length<=0) return 0;
|
||||
|
||||
/* if entire request is within the buffer */
|
||||
if (offset >= streamfile->offset && offset+length <= streamfile->offset+streamfile->validsize) {
|
||||
memcpy(dest,streamfile->buffer+(offset-streamfile->offset),length);
|
||||
return length;
|
||||
}
|
||||
|
||||
return read_the_rest_foo(dest,offset,length,streamfile);
|
||||
}
|
||||
|
||||
STREAMFILE * open_foo_streamfile(const char * const filename, abort_callback * p_abort) {
|
||||
return open_foo_streamfile_buffer(filename,STREAMFILE_DEFAULT_BUFFER_SIZE, p_abort);
|
||||
}
|
||||
|
||||
static STREAMFILE *open_foo(FOO_STREAMFILE *streamFile,const char * const filename,size_t buffersize) {
|
||||
service_ptr_t<file> m_file;
|
||||
|
||||
STREAMFILE *newstreamFile;
|
||||
|
||||
if (!filename)
|
||||
return NULL;
|
||||
|
||||
// if same name, duplicate the file pointer we already have open
|
||||
if (!strcmp(streamFile->name,filename)) {
|
||||
m_file = streamFile->m_file;
|
||||
if (1) {
|
||||
newstreamFile = open_foo_streamfile_buffer_by_file(m_file,filename,buffersize,streamFile->p_abort);
|
||||
if (newstreamFile) {
|
||||
return newstreamFile;
|
||||
}
|
||||
// failure, close it and try the default path (which will probably fail a second time)
|
||||
}
|
||||
}
|
||||
// a normal open, open a new file
|
||||
|
||||
return open_foo_streamfile_buffer(filename,buffersize,streamFile->p_abort);
|
||||
}
|
||||
|
||||
static size_t get_size_foo(FOO_STREAMFILE * streamfile) {
|
||||
//fseeko(streamfile->infile,0,SEEK_END);
|
||||
return streamfile->m_file->get_size(*streamfile->p_abort);//ftello(streamfile->infile);
|
||||
}
|
||||
|
||||
static off_t get_offset_foo(FOO_STREAMFILE *streamFile) {
|
||||
return streamFile->offset;
|
||||
}
|
||||
|
||||
static void close_foo(FOO_STREAMFILE * streamfile) {
|
||||
//fclose(streamfile->infile);
|
||||
free(streamfile->buffer);
|
||||
free(streamfile);
|
||||
}
|
||||
|
||||
static void get_name_foo(FOO_STREAMFILE *streamfile,char *buffer,size_t length) {
|
||||
strcpy(buffer,streamfile->name);
|
||||
}
|
||||
|
||||
static STREAMFILE * open_foo_streamfile_buffer_by_file(service_ptr_t<file> m_file,const char * const filename, size_t buffersize, abort_callback * p_abort) {
|
||||
uint8_t * buffer;
|
||||
FOO_STREAMFILE * streamfile;
|
||||
|
||||
buffer = (uint8_t *) calloc(buffersize,1);
|
||||
if (!buffer) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
streamfile = (FOO_STREAMFILE *) calloc(1,sizeof(FOO_STREAMFILE));
|
||||
if (!streamfile) {
|
||||
free(buffer);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
streamfile->sf.read = (size_t (__cdecl *)(_STREAMFILE *,uint8_t *,off_t,size_t)) read_foo;
|
||||
streamfile->sf.get_size = (size_t (__cdecl *)(_STREAMFILE *)) get_size_foo;
|
||||
streamfile->sf.get_offset = (off_t (__cdecl *)(_STREAMFILE *)) get_offset_foo;
|
||||
streamfile->sf.get_name = (void (__cdecl *)(_STREAMFILE *,char *,size_t)) get_name_foo;
|
||||
streamfile->sf.open = (_STREAMFILE *(__cdecl *)(_STREAMFILE *,const char *const ,size_t)) open_foo;
|
||||
streamfile->sf.close = (void (__cdecl *)(_STREAMFILE *)) close_foo;
|
||||
#ifdef PROFILE_STREAMFILE
|
||||
streamfile->sf.get_bytes_read = (void*)get_bytes_read_stdio;
|
||||
#endif
|
||||
|
||||
streamfile->m_file = m_file;
|
||||
|
||||
streamfile->buffersize = buffersize;
|
||||
streamfile->buffer = buffer;
|
||||
streamfile->p_abort = p_abort;
|
||||
|
||||
strcpy(streamfile->name,filename);
|
||||
|
||||
return &streamfile->sf;
|
||||
}
|
||||
|
||||
STREAMFILE * open_foo_streamfile_buffer(const char * const filename, size_t buffersize, abort_callback * p_abort) {
|
||||
STREAMFILE *streamFile;
|
||||
service_ptr_t<file> infile;
|
||||
|
||||
if(!(filesystem::g_exists(filename, *p_abort)))
|
||||
return NULL;
|
||||
|
||||
filesystem::g_open_read(infile,filename,*p_abort);
|
||||
|
||||
streamFile = open_foo_streamfile_buffer_by_file(infile,filename,buffersize,p_abort);
|
||||
if (!streamFile) {
|
||||
// fclose(infile);
|
||||
}
|
||||
|
||||
return streamFile;
|
||||
}
|
332
fb2k/in_vgmstream.cpp
Normal file
332
fb2k/in_vgmstream.cpp
Normal file
@ -0,0 +1,332 @@
|
||||
/* Winamp plugin interface for vgmstream */
|
||||
/* Based on: */
|
||||
/*
|
||||
** Example Winamp .RAW input plug-in
|
||||
** Copyright (c) 1998, Justin Frankel/Nullsoft Inc.
|
||||
*/
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define _CRT_SECURE_NO_DEPRECATE
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#include <commctrl.h>
|
||||
#include <stdio.h>
|
||||
#include <io.h>
|
||||
|
||||
#include <foobar2000.h>
|
||||
#include <helpers.h>
|
||||
#include <shared.h>
|
||||
|
||||
extern "C" {
|
||||
#include "../src/vgmstream.h"
|
||||
#include "../src/util.h"
|
||||
}
|
||||
#include "foo_vgmstream.h"
|
||||
|
||||
#ifndef VERSION
|
||||
#define VERSION
|
||||
#endif
|
||||
|
||||
#define APP_NAME "vgmstream plugin"
|
||||
#define PLUGIN_DESCRIPTION "vgmstream plugin " VERSION " " __DATE__
|
||||
#define PLUGIN_VERSION VERSION " " __DATE__
|
||||
#define INI_NAME "plugin.ini"
|
||||
|
||||
#define DECODE_SIZE 1024
|
||||
|
||||
/* format detection and VGMSTREAM setup, uses default parameters */
|
||||
VGMSTREAM * init_vgmstream_foo(const char * const filename, abort_callback & p_abort) {
|
||||
VGMSTREAM *vgmstream = NULL;
|
||||
STREAMFILE *streamFile = open_foo_streamfile(filename, &p_abort);
|
||||
if (streamFile) {
|
||||
vgmstream = init_vgmstream_from_STREAMFILE(streamFile);
|
||||
close_streamfile(streamFile);
|
||||
}
|
||||
return vgmstream;
|
||||
}
|
||||
|
||||
class input_vgmstream {
|
||||
public:
|
||||
void open(service_ptr_t<file> p_filehint,const char * p_path,t_input_open_reason p_reason,abort_callback & p_abort) {
|
||||
|
||||
currentreason = p_reason;
|
||||
if(p_path) strcpy(filename, p_path);
|
||||
|
||||
switch(p_reason) {
|
||||
case input_open_decode:
|
||||
vgmstream = init_vgmstream_foo(p_path, p_abort);
|
||||
|
||||
/* were we able to open it? */
|
||||
if (!vgmstream) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ignore_loop) vgmstream->loop_flag = 0;
|
||||
|
||||
/* will we be able to play it? */
|
||||
|
||||
if (vgmstream->channels <= 0) {
|
||||
close_vgmstream(vgmstream);
|
||||
vgmstream=NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
decode_abort = 0;
|
||||
seek_needed_samples = -1;
|
||||
decode_pos_ms = 0;
|
||||
decode_pos_samples = 0;
|
||||
paused = 0;
|
||||
stream_length_samples = get_vgmstream_play_samples(loop_count,fade_seconds,fade_delay_seconds,vgmstream);
|
||||
|
||||
fade_samples = (int)(fade_seconds * vgmstream->sample_rate);
|
||||
|
||||
break;
|
||||
|
||||
case input_open_info_read:
|
||||
break;
|
||||
|
||||
case input_open_info_write:
|
||||
//cant write...ever
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void get_info(file_info & p_info,abort_callback & p_abort ) {
|
||||
int length_in_ms=0, channels = 0, samplerate = 0;
|
||||
char title[256];
|
||||
|
||||
getfileinfo(filename, title, &length_in_ms, &samplerate, &channels, p_abort);
|
||||
|
||||
p_info.info_set_int("samplerate", samplerate);
|
||||
p_info.info_set_int("channels", channels);
|
||||
p_info.info_set_int("bitspersample",16);
|
||||
p_info.info_set("encoding","lossless");
|
||||
p_info.info_set_bitrate(16);
|
||||
|
||||
p_info.set_length(((double)length_in_ms)/1000);
|
||||
}
|
||||
|
||||
void decode_initialize(unsigned p_flags,abort_callback & p_abort) { };
|
||||
|
||||
bool decode_run(audio_chunk & p_chunk,abort_callback & p_abort) {
|
||||
int l = 0, samples_to_do = DECODE_SIZE, t= 0;
|
||||
|
||||
if(vgmstream && (seek_needed_samples == -1 )) {
|
||||
|
||||
if (decode_pos_samples+DECODE_SIZE>stream_length_samples && (!loop_forever || !vgmstream->loop_flag))
|
||||
samples_to_do=stream_length_samples-decode_pos_samples;
|
||||
else
|
||||
samples_to_do=DECODE_SIZE;
|
||||
|
||||
l = (samples_to_do*vgmstream->channels*2);
|
||||
|
||||
if (samples_to_do /*< DECODE_SIZE*/ == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
t = ((test_length*vgmstream->sample_rate)/1000);
|
||||
|
||||
render_vgmstream(sample_buffer,samples_to_do,vgmstream);
|
||||
|
||||
/* fade! */
|
||||
if (vgmstream->loop_flag && fade_samples > 0 && !loop_forever) {
|
||||
int samples_into_fade = decode_pos_samples - (stream_length_samples - fade_samples);
|
||||
if (samples_into_fade + samples_to_do > 0) {
|
||||
int j,k;
|
||||
for (j=0;j<samples_to_do;j++,samples_into_fade++) {
|
||||
if (samples_into_fade > 0) {
|
||||
double fadedness = (double)(fade_samples-samples_into_fade)/fade_samples;
|
||||
for (k=0;k<vgmstream->channels;k++) {
|
||||
sample_buffer[j*vgmstream->channels+k] =
|
||||
(short)(sample_buffer[j*vgmstream->channels+k]*fadedness);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
p_chunk.set_data_fixedpoint((char*)sample_buffer, l, vgmstream->sample_rate,vgmstream->channels,16,audio_chunk::g_guess_channel_config(vgmstream->channels));
|
||||
|
||||
decode_pos_samples+=samples_to_do;
|
||||
decode_pos_ms=decode_pos_samples*1000LL/vgmstream->sample_rate;
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void decode_seek(double p_seconds,abort_callback & p_abort) {
|
||||
}
|
||||
|
||||
input_vgmstream() {
|
||||
vgmstream = NULL;
|
||||
decode_thread_handle = INVALID_HANDLE_VALUE;
|
||||
paused = 0;
|
||||
decode_abort = 0;
|
||||
seek_needed_samples = -1;
|
||||
decode_pos_ms = 0;
|
||||
decode_pos_samples = 0;
|
||||
stream_length_samples = 0;
|
||||
fade_samples = 0;
|
||||
|
||||
fade_seconds = 10.0f;
|
||||
fade_delay_seconds = 0.0f;
|
||||
loop_count = 2.0f;
|
||||
thread_priority = 3;
|
||||
loop_forever = 0;
|
||||
ignore_loop = 0;
|
||||
|
||||
}
|
||||
|
||||
~input_vgmstream() {
|
||||
}
|
||||
|
||||
t_filestats get_file_stats(abort_callback & p_abort) {
|
||||
t_filestats t;
|
||||
return t;
|
||||
}
|
||||
|
||||
bool decode_can_seek() {return false;} /*not implemented yet*/
|
||||
bool decode_get_dynamic_info(file_info & p_out, double & p_timestamp_delta) {
|
||||
//do we need anything else 'cept the samplrate
|
||||
return true;
|
||||
}
|
||||
bool decode_get_dynamic_info_track(file_info & p_out, double & p_timestamp_delta) {return false;}
|
||||
void decode_on_idle(abort_callback & p_abort) {/*m_file->on_idle(p_abort);*/}
|
||||
|
||||
void retag(const file_info & p_info,abort_callback & p_abort) {};
|
||||
|
||||
static bool g_is_our_content_type(const char * p_content_type) {return false;}
|
||||
static bool g_is_our_path(const char * p_path,const char * p_extension) {
|
||||
if(!stricmp_utf8(p_extension,"adx")) return 1;
|
||||
if(!stricmp_utf8(p_extension,"afc")) return 1;
|
||||
if(!stricmp_utf8(p_extension,"agsc")) return 1;
|
||||
if(!stricmp_utf8(p_extension,"ast")) return 1;
|
||||
if(!stricmp_utf8(p_extension,"brstm")) return 1;
|
||||
if(!stricmp_utf8(p_extension,"brstmspm")) return 1;
|
||||
if(!stricmp_utf8(p_extension,"hps")) return 1;
|
||||
if(!stricmp_utf8(p_extension,"strm")) return 1;
|
||||
if(!stricmp_utf8(p_extension,"adp")) return 1;
|
||||
if(!stricmp_utf8(p_extension,"rsf")) return 1;
|
||||
if(!stricmp_utf8(p_extension,"dsp")) return 1;
|
||||
if(!stricmp_utf8(p_extension,"gcw")) return 1;
|
||||
if(!stricmp_utf8(p_extension,"ads")) return 1;
|
||||
if(!stricmp_utf8(p_extension,"ss2")) return 1;
|
||||
if(!stricmp_utf8(p_extension,"npsf")) return 1;
|
||||
if(!stricmp_utf8(p_extension,"rwsd")) return 1;
|
||||
if(!stricmp_utf8(p_extension,"xa")) return 1;
|
||||
if(!stricmp_utf8(p_extension,"rxw")) return 1;
|
||||
if(!stricmp_utf8(p_extension,"int")) return 1;
|
||||
if(!stricmp_utf8(p_extension,"sts")) return 1;
|
||||
if(!stricmp_utf8(p_extension,"svag")) return 1;
|
||||
if(!stricmp_utf8(p_extension,"mib")) return 1;
|
||||
if(!stricmp_utf8(p_extension,"mi4")) return 1;
|
||||
if(!stricmp_utf8(p_extension,"mpdsp")) return 1;
|
||||
if(!stricmp_utf8(p_extension,"mic")) return 1;
|
||||
if(!stricmp_utf8(p_extension,"gcm")) return 1;
|
||||
if(!stricmp_utf8(p_extension,"mss")) return 1;
|
||||
if(!stricmp_utf8(p_extension,"raw")) return 1;
|
||||
if(!stricmp_utf8(p_extension,"vag")) return 1;
|
||||
if(!stricmp_utf8(p_extension,"gms")) return 1;
|
||||
if(!stricmp_utf8(p_extension,"str")) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
public:
|
||||
service_ptr_t<file> m_file;
|
||||
char filename[260];
|
||||
t_input_open_reason currentreason;
|
||||
VGMSTREAM * vgmstream;
|
||||
HANDLE decode_thread_handle;
|
||||
int paused;
|
||||
int decode_abort;
|
||||
int seek_needed_samples;
|
||||
int decode_pos_ms;
|
||||
int decode_pos_samples;
|
||||
int stream_length_samples;
|
||||
int fade_samples;
|
||||
int test_length;
|
||||
|
||||
double fade_seconds;
|
||||
double fade_delay_seconds;
|
||||
double loop_count;
|
||||
int thread_priority;
|
||||
int loop_forever;
|
||||
int ignore_loop;
|
||||
|
||||
short sample_buffer[576*2*2]; /* 576 16-bit samples, stereo, possibly doubled in size for DSP */
|
||||
|
||||
void getfileinfo(char *filename, char *title, int *length_in_ms, int *sample_rate, int *channels, abort_callback & p_abort);
|
||||
};
|
||||
|
||||
|
||||
/* retrieve information on this or possibly another file */
|
||||
void input_vgmstream::getfileinfo(char *filename, char *title, int *length_in_ms, int *sample_rate, int *channels, abort_callback & p_abort) {
|
||||
|
||||
VGMSTREAM * infostream;
|
||||
if (length_in_ms)
|
||||
{
|
||||
*length_in_ms=-1000;
|
||||
if ((infostream=init_vgmstream_foo(filename, p_abort)))
|
||||
{
|
||||
*length_in_ms = get_vgmstream_play_samples(loop_count,fade_seconds,fade_delay_seconds,infostream)*1000LL/infostream->sample_rate;
|
||||
test_length = *length_in_ms;
|
||||
*sample_rate = infostream->sample_rate;
|
||||
*channels = infostream->channels;
|
||||
|
||||
close_vgmstream(infostream);
|
||||
infostream=NULL;
|
||||
}
|
||||
}
|
||||
if (title)
|
||||
{
|
||||
char *p=filename+strlen(filename);
|
||||
while (*p != '\\' && p >= filename) p--;
|
||||
strcpy(title,++p);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
static input_singletrack_factory_t<input_vgmstream> g_input_vgmstream_factory;
|
||||
|
||||
DECLARE_COMPONENT_VERSION(APP_NAME,PLUGIN_VERSION,PLUGIN_DESCRIPTION);
|
||||
|
||||
DECLARE_MULTIPLE_FILE_TYPE("ADX Audio File (*.ADX)", adx);
|
||||
DECLARE_MULTIPLE_FILE_TYPE("AFC Audio File (*.AFC)", afc);
|
||||
DECLARE_MULTIPLE_FILE_TYPE("AGSC Audio File (*.AGSC)", agsc);
|
||||
DECLARE_MULTIPLE_FILE_TYPE("AST Audio File (*.AST)", ast);
|
||||
DECLARE_MULTIPLE_FILE_TYPE("BRSTM Audio File (*.BRSTM)", brstm);
|
||||
DECLARE_MULTIPLE_FILE_TYPE("BRSTM Audio File (*.BRSTMSPM)", brstmspm);
|
||||
DECLARE_MULTIPLE_FILE_TYPE("HALPST Audio File (*.HPS)", hps);
|
||||
DECLARE_MULTIPLE_FILE_TYPE("STRM Audio File (*.STRM)", strm);
|
||||
DECLARE_MULTIPLE_FILE_TYPE("ADP Audio File (*.ADP)", adp);
|
||||
DECLARE_MULTIPLE_FILE_TYPE("RSF Audio File (*.RSF)", rsf);
|
||||
DECLARE_MULTIPLE_FILE_TYPE("DSP Audio File (*.DSP)", dsp);
|
||||
DECLARE_MULTIPLE_FILE_TYPE("GCW Audio File (*.GCW)", gcw);
|
||||
DECLARE_MULTIPLE_FILE_TYPE("PS2 ADS Audio File (*.ADS)", ads);
|
||||
DECLARE_MULTIPLE_FILE_TYPE("PS2 SS2 Audio File (*.SS2)", ss2);
|
||||
DECLARE_MULTIPLE_FILE_TYPE("PS2 NPSF Audio File (*.NPSF)", npsf);
|
||||
DECLARE_MULTIPLE_FILE_TYPE("RWSD Audio File (*.RWSD)", rwsd);
|
||||
DECLARE_MULTIPLE_FILE_TYPE("PSX CD-XA File (*.XA)", xa);
|
||||
DECLARE_MULTIPLE_FILE_TYPE("PS2 RXWS File (*.RXW)", rxw);
|
||||
DECLARE_MULTIPLE_FILE_TYPE("PS2 RAW Interleaved PCM (*.INT)", int);
|
||||
DECLARE_MULTIPLE_FILE_TYPE("PS2 EXST Audio File (*.STS)", sts);
|
||||
DECLARE_MULTIPLE_FILE_TYPE("PS2 SVAG Audio File (*.SVAG)", svag);
|
||||
DECLARE_MULTIPLE_FILE_TYPE("PS2 MIB Audio File (*.MIB)", mib);
|
||||
DECLARE_MULTIPLE_FILE_TYPE("PS2 MI4 Audio File (*.MI4)", mi4);
|
||||
DECLARE_MULTIPLE_FILE_TYPE("MPDSP Audio File (*.MPDSP)", mpdsp);
|
||||
DECLARE_MULTIPLE_FILE_TYPE("PS2 MIC Audio File (*.MIC)", mic);
|
||||
DECLARE_MULTIPLE_FILE_TYPE("GCM Audio File (*.GCM)", gcm);
|
||||
DECLARE_MULTIPLE_FILE_TYPE("MSS Audio File (*.MSS)", mss);
|
||||
DECLARE_MULTIPLE_FILE_TYPE("RAW Audio File (*.RAW)", raw);
|
||||
DECLARE_MULTIPLE_FILE_TYPE("VAG Audio File (*.VAG)", vag);
|
||||
DECLARE_MULTIPLE_FILE_TYPE("GMS Audio File (*.GMS)", gms);
|
||||
DECLARE_MULTIPLE_FILE_TYPE("STR Audio File (*.STR)", str);
|
||||
|
Loading…
Reference in New Issue
Block a user