├── .gitattributes ├── .gitignore ├── README.md ├── foo_input_msu.sln ├── foo_input_msu.vcxproj ├── foo_input_msu.vcxproj.filters ├── foo_input_msu.vcxproj.user ├── foobar2000 └── install_foobar2000_portable_here ├── input_msu.cpp ├── input_msu.h ├── stdafx.cpp └── stdafx.h /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | [Xx]64/ 19 | [Xx]86/ 20 | [Bb]uild/ 21 | bld/ 22 | [Bb]in/ 23 | [Oo]bj/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | artifacts/ 46 | 47 | *_i.c 48 | *_p.c 49 | *_i.h 50 | *.ilk 51 | *.meta 52 | *.obj 53 | *.pch 54 | *.pdb 55 | *.pgc 56 | *.pgd 57 | *.rsp 58 | *.sbr 59 | *.tlb 60 | *.tli 61 | *.tlh 62 | *.tmp 63 | *.tmp_proj 64 | *.log 65 | *.vspscc 66 | *.vssscc 67 | .builds 68 | *.pidb 69 | *.svclog 70 | *.scc 71 | 72 | # Chutzpah Test files 73 | _Chutzpah* 74 | 75 | # Visual C++ cache files 76 | ipch/ 77 | *.aps 78 | *.ncb 79 | *.opendb 80 | *.opensdf 81 | *.sdf 82 | *.cachefile 83 | *.VC.db 84 | 85 | # Visual Studio profiler 86 | *.psess 87 | *.vsp 88 | *.vspx 89 | *.sap 90 | 91 | # TFS 2012 Local Workspace 92 | $tf/ 93 | 94 | # Guidance Automation Toolkit 95 | *.gpState 96 | 97 | # ReSharper is a .NET coding add-in 98 | _ReSharper*/ 99 | *.[Rr]e[Ss]harper 100 | *.DotSettings.user 101 | 102 | # JustCode is a .NET coding add-in 103 | .JustCode 104 | 105 | # TeamCity is a build add-in 106 | _TeamCity* 107 | 108 | # DotCover is a Code Coverage Tool 109 | *.dotCover 110 | 111 | # NCrunch 112 | _NCrunch_* 113 | .*crunch*.local.xml 114 | nCrunchTemp_* 115 | 116 | # MightyMoose 117 | *.mm.* 118 | AutoTest.Net/ 119 | 120 | # Web workbench (sass) 121 | .sass-cache/ 122 | 123 | # Installshield output folder 124 | [Ee]xpress/ 125 | 126 | # DocProject is a documentation generator add-in 127 | DocProject/buildhelp/ 128 | DocProject/Help/*.HxT 129 | DocProject/Help/*.HxC 130 | DocProject/Help/*.hhc 131 | DocProject/Help/*.hhk 132 | DocProject/Help/*.hhp 133 | DocProject/Help/Html2 134 | DocProject/Help/html 135 | 136 | # Click-Once directory 137 | publish/ 138 | 139 | # Publish Web Output 140 | *.[Pp]ublish.xml 141 | *.azurePubxml 142 | 143 | # TODO: Un-comment the next line if you do not want to checkin 144 | # your web deploy settings because they may include unencrypted 145 | # passwords 146 | #*.pubxml 147 | *.publishproj 148 | 149 | # NuGet Packages 150 | *.nupkg 151 | # The packages folder can be ignored because of Package Restore 152 | **/packages/* 153 | # except build/, which is used as an MSBuild target. 154 | !**/packages/build/ 155 | # Uncomment if necessary however generally it will be regenerated when needed 156 | #!**/packages/repositories.config 157 | # NuGet v3's project.json files produces more ignoreable files 158 | *.nuget.props 159 | *.nuget.targets 160 | 161 | # Microsoft Azure Build Output 162 | csx/ 163 | *.build.csdef 164 | 165 | # Microsoft Azure Emulator 166 | ecf/ 167 | rcf/ 168 | 169 | # Microsoft Azure ApplicationInsights config file 170 | ApplicationInsights.config 171 | 172 | # Windows Store app package directory 173 | AppPackages/ 174 | BundleArtifacts/ 175 | 176 | # Visual Studio cache files 177 | # files ending in .cache can be ignored 178 | *.[Cc]ache 179 | # but keep track of directories ending in .cache 180 | !*.[Cc]ache/ 181 | 182 | # Others 183 | ClientBin/ 184 | [Ss]tyle[Cc]op.* 185 | ~$* 186 | *~ 187 | *.dbmdl 188 | *.dbproj.schemaview 189 | *.pfx 190 | *.publishsettings 191 | node_modules/ 192 | orleans.codegen.cs 193 | 194 | # RIA/Silverlight projects 195 | Generated_Code/ 196 | 197 | # Backup & report files from converting an old project file 198 | # to a newer Visual Studio version. Backup files are not needed, 199 | # because we have git ;-) 200 | _UpgradeReport_Files/ 201 | Backup*/ 202 | UpgradeLog*.XML 203 | UpgradeLog*.htm 204 | 205 | # SQL Server files 206 | *.mdf 207 | *.ldf 208 | 209 | # Business Intelligence projects 210 | *.rdl.data 211 | *.bim.layout 212 | *.bim_*.settings 213 | 214 | # Microsoft Fakes 215 | FakesAssemblies/ 216 | 217 | # GhostDoc plugin setting file 218 | *.GhostDoc.xml 219 | 220 | # Node.js Tools for Visual Studio 221 | .ntvs_analysis.dat 222 | 223 | # Visual Studio 6 build log 224 | *.plg 225 | 226 | # Visual Studio 6 workspace options file 227 | *.opt 228 | 229 | # Visual Studio LightSwitch build output 230 | **/*.HTMLClient/GeneratedArtifacts 231 | **/*.DesktopClient/GeneratedArtifacts 232 | **/*.DesktopClient/ModelManifest.xml 233 | **/*.Server/GeneratedArtifacts 234 | **/*.Server/ModelManifest.xml 235 | _Pvt_Extensions 236 | 237 | # LightSwitch generated files 238 | GeneratedArtifacts/ 239 | ModelManifest.xml 240 | 241 | # Paket dependency manager 242 | .paket/paket.exe 243 | 244 | # FAKE - F# Make 245 | .fake/ 246 | 247 | # Foobar2000 portable installation directory 248 | foobar2000/ -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # foo_input_msu 2 | 3 | MSU-1 PCM audio input decoder for [foobar2000](http://www.foobar2000.org/) 4 | 5 | Implements basic playback and gapless looping 6 | 7 | # Installation 8 | 9 | Download foo_input_msu.dll and copy into your \components directory 10 | 11 | # Building From Source 12 | 13 | - Download and install Visual Studio Express 2015 14 | - Download the latest [foobar2000 SDK](http://www.foobar2000.org/SDK) and extract it 15 | - Open the foobar2000 folder containing the various SDK projects 16 | - Check out this repository into its own folder alongside the existing SDK projects 17 | 18 | e.g. 19 | 20 | somedir\\ 21 | |\`-foobar2000\\ 22 | |    |\`-ATLHelpers\\ 23 | |    |\`--foo_input_msu\\ 24 | |    |    |\`-foobar2000\\ 25 | |    |    |\`-foo_input_msu.sln 26 | |    |     \`-... 27 | |    |\`-foo_input_validators\\ 28 | |    |\`-foo_sample\\ 29 | |    |\`-foobar2000_component_client\\ 30 | |    |\`-helpers\\ 31 | |    |\`-SDK\\ 32 | |     \`-shared\\ 33 |  `-pfc\\ 34 | 35 | - If you want to be able to debug and execute directly from Visual Studio, download the latest release of [foobar2000](http://www.foobar2000.org/download) and do a portable installation into the foo_input_msu\\foobar2000 directory 36 | - Be sure to set the project build configuration to x86, then build the solution 37 | -------------------------------------------------------------------------------- /foo_input_msu.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "foo_input_msu", "foo_input_msu.vcxproj", "{D3E95978-7893-404D-9491-054318803426}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "foobar2000_SDK", "..\SDK\foobar2000_SDK.vcxproj", "{E8091321-D79D-4575-86EF-064EA1A4A20D}" 9 | EndProject 10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "foobar2000_component_client", "..\foobar2000_component_client\foobar2000_component_client.vcxproj", "{71AD2674-065B-48F5-B8B0-E1F9D3892081}" 11 | EndProject 12 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pfc", "..\..\pfc\pfc.vcxproj", "{EBFFFB4E-261D-44D3-B89C-957B31A0BF9C}" 13 | EndProject 14 | Global 15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 16 | Debug|x64 = Debug|x64 17 | Debug|x86 = Debug|x86 18 | Release|x64 = Release|x64 19 | Release|x86 = Release|x86 20 | EndGlobalSection 21 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 22 | {D3E95978-7893-404D-9491-054318803426}.Debug|x64.ActiveCfg = Debug|x64 23 | {D3E95978-7893-404D-9491-054318803426}.Debug|x64.Build.0 = Debug|x64 24 | {D3E95978-7893-404D-9491-054318803426}.Debug|x86.ActiveCfg = Debug|Win32 25 | {D3E95978-7893-404D-9491-054318803426}.Debug|x86.Build.0 = Debug|Win32 26 | {D3E95978-7893-404D-9491-054318803426}.Release|x64.ActiveCfg = Release|x64 27 | {D3E95978-7893-404D-9491-054318803426}.Release|x64.Build.0 = Release|x64 28 | {D3E95978-7893-404D-9491-054318803426}.Release|x86.ActiveCfg = Release|Win32 29 | {D3E95978-7893-404D-9491-054318803426}.Release|x86.Build.0 = Release|Win32 30 | {E8091321-D79D-4575-86EF-064EA1A4A20D}.Debug|x64.ActiveCfg = Debug|x64 31 | {E8091321-D79D-4575-86EF-064EA1A4A20D}.Debug|x64.Build.0 = Debug|x64 32 | {E8091321-D79D-4575-86EF-064EA1A4A20D}.Debug|x86.ActiveCfg = Debug|Win32 33 | {E8091321-D79D-4575-86EF-064EA1A4A20D}.Debug|x86.Build.0 = Debug|Win32 34 | {E8091321-D79D-4575-86EF-064EA1A4A20D}.Release|x64.ActiveCfg = Release|x64 35 | {E8091321-D79D-4575-86EF-064EA1A4A20D}.Release|x64.Build.0 = Release|x64 36 | {E8091321-D79D-4575-86EF-064EA1A4A20D}.Release|x86.ActiveCfg = Release|Win32 37 | {E8091321-D79D-4575-86EF-064EA1A4A20D}.Release|x86.Build.0 = Release|Win32 38 | {71AD2674-065B-48F5-B8B0-E1F9D3892081}.Debug|x64.ActiveCfg = Debug|x64 39 | {71AD2674-065B-48F5-B8B0-E1F9D3892081}.Debug|x64.Build.0 = Debug|x64 40 | {71AD2674-065B-48F5-B8B0-E1F9D3892081}.Debug|x86.ActiveCfg = Debug|Win32 41 | {71AD2674-065B-48F5-B8B0-E1F9D3892081}.Debug|x86.Build.0 = Debug|Win32 42 | {71AD2674-065B-48F5-B8B0-E1F9D3892081}.Release|x64.ActiveCfg = Release|x64 43 | {71AD2674-065B-48F5-B8B0-E1F9D3892081}.Release|x64.Build.0 = Release|x64 44 | {71AD2674-065B-48F5-B8B0-E1F9D3892081}.Release|x86.ActiveCfg = Release|Win32 45 | {71AD2674-065B-48F5-B8B0-E1F9D3892081}.Release|x86.Build.0 = Release|Win32 46 | {EBFFFB4E-261D-44D3-B89C-957B31A0BF9C}.Debug|x64.ActiveCfg = Debug|x64 47 | {EBFFFB4E-261D-44D3-B89C-957B31A0BF9C}.Debug|x64.Build.0 = Debug|x64 48 | {EBFFFB4E-261D-44D3-B89C-957B31A0BF9C}.Debug|x86.ActiveCfg = Debug|Win32 49 | {EBFFFB4E-261D-44D3-B89C-957B31A0BF9C}.Debug|x86.Build.0 = Debug|Win32 50 | {EBFFFB4E-261D-44D3-B89C-957B31A0BF9C}.Release|x64.ActiveCfg = Release|x64 51 | {EBFFFB4E-261D-44D3-B89C-957B31A0BF9C}.Release|x64.Build.0 = Release|x64 52 | {EBFFFB4E-261D-44D3-B89C-957B31A0BF9C}.Release|x86.ActiveCfg = Release|Win32 53 | {EBFFFB4E-261D-44D3-B89C-957B31A0BF9C}.Release|x86.Build.0 = Release|Win32 54 | EndGlobalSection 55 | GlobalSection(SolutionProperties) = preSolution 56 | HideSolutionNode = FALSE 57 | EndGlobalSection 58 | EndGlobal 59 | -------------------------------------------------------------------------------- /foo_input_msu.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {D3E95978-7893-404D-9491-054318803426} 23 | Win32Proj 24 | foo_input_msu 25 | 8.1 26 | foo_input_msu 27 | 28 | 29 | 30 | DynamicLibrary 31 | true 32 | v140 33 | Unicode 34 | 35 | 36 | DynamicLibrary 37 | false 38 | v140 39 | true 40 | Unicode 41 | 42 | 43 | DynamicLibrary 44 | true 45 | v140 46 | Unicode 47 | 48 | 49 | DynamicLibrary 50 | false 51 | v140 52 | true 53 | Unicode 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | true 75 | 76 | 77 | true 78 | 79 | 80 | false 81 | 82 | 83 | false 84 | 85 | 86 | 87 | Use 88 | Level3 89 | Disabled 90 | WIN32;_DEBUG;_WINDOWS;_USRDLL;FOO_INPUT_MSU_EXPORTS;%(PreprocessorDefinitions) 91 | true 92 | MultiThreadedDebug 93 | 94 | 95 | Windows 96 | true 97 | $(SolutionDir)..\shared\shared.lib;shlwapi.lib;%(AdditionalDependencies) 98 | $(OutDir)$(TargetName)$(TargetExt) 99 | 100 | 101 | if exist "$(SolutionDir)foobar2000\components" copy "$(TargetPath)" "$(SolutionDir)foobar2000\components" 102 | 103 | 104 | Copy output to foobar2000 components folder 105 | 106 | 107 | 108 | 109 | Use 110 | Level3 111 | Disabled 112 | _DEBUG;_WINDOWS;_USRDLL;FOO_INPUT_MSU_EXPORTS;%(PreprocessorDefinitions) 113 | true 114 | MultiThreadedDebug 115 | 116 | 117 | Windows 118 | true 119 | $(SolutionDir)..\shared\shared.lib;shlwapi.lib;%(AdditionalDependencies) 120 | $(OutDir)$(TargetName)$(TargetExt) 121 | 122 | 123 | if exist "$(SolutionDir)foobar2000\components" copy "$(TargetPath)" "$(SolutionDir)foobar2000\components" 124 | 125 | 126 | Copy output to foobar2000 components folder 127 | 128 | 129 | 130 | 131 | Level3 132 | Use 133 | MaxSpeed 134 | true 135 | true 136 | WIN32;NDEBUG;_WINDOWS;_USRDLL;FOO_INPUT_MSU_EXPORTS;%(PreprocessorDefinitions) 137 | true 138 | MultiThreaded 139 | 140 | 141 | Windows 142 | true 143 | true 144 | true 145 | $(SolutionDir)..\shared\shared.lib;shlwapi.lib;%(AdditionalDependencies) 146 | $(OutDir)$(TargetName)$(TargetExt) 147 | 148 | 149 | if exist "$(SolutionDir)foobar2000\components" copy "$(TargetPath)" "$(SolutionDir)foobar2000\components" 150 | 151 | 152 | Copy output to foobar2000 components folder 153 | 154 | 155 | 156 | 157 | Level3 158 | Use 159 | MaxSpeed 160 | true 161 | true 162 | NDEBUG;_WINDOWS;_USRDLL;FOO_INPUT_MSU_EXPORTS;%(PreprocessorDefinitions) 163 | true 164 | MultiThreaded 165 | 166 | 167 | Windows 168 | true 169 | true 170 | true 171 | $(SolutionDir)..\shared\shared.lib;shlwapi.lib;%(AdditionalDependencies) 172 | $(OutDir)$(TargetName)$(TargetExt) 173 | 174 | 175 | if exist "$(SolutionDir)foobar2000\components" copy "$(TargetPath)" "$(SolutionDir)foobar2000\components" 176 | 177 | 178 | Copy output to foobar2000 components folder 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | Create 189 | Create 190 | Create 191 | Create 192 | 193 | 194 | 195 | 196 | {ebfffb4e-261d-44d3-b89c-957b31a0bf9c} 197 | 198 | 199 | {71ad2674-065b-48f5-b8b0-e1f9d3892081} 200 | 201 | 202 | {e8091321-d79d-4575-86ef-064ea1a4a20d} 203 | 204 | 205 | 206 | 207 | 208 | -------------------------------------------------------------------------------- /foo_input_msu.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | 26 | 27 | Source Files 28 | 29 | 30 | Source Files 31 | 32 | 33 | -------------------------------------------------------------------------------- /foo_input_msu.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(SolutionDir)..\foobar2000\foobar2000.exe 5 | $(SolutionDir)..\foobar2000 6 | WindowsLocalDebugger 7 | 8 | 9 | $(SolutionDir)..\foobar2000\foobar2000.exe 10 | $(SolutionDir)..\foobar2000 11 | WindowsLocalDebugger 12 | 13 | 14 | $(SolutionDir)..\foobar2000\foobar2000.exe 15 | $(SolutionDir)..\foobar2000 16 | WindowsLocalDebugger 17 | 18 | 19 | $(SolutionDir)..\foobar2000\foobar2000.exe 20 | $(SolutionDir)..\foobar2000 21 | WindowsLocalDebugger 22 | 23 | -------------------------------------------------------------------------------- /foobar2000/install_foobar2000_portable_here: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qwertymodo/foo_input_msu/55d2ff82de35fe007e24c7f22c1aa2e6850d8a64/foobar2000/install_foobar2000_portable_here -------------------------------------------------------------------------------- /input_msu.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include 3 | #include "input_msu.h" 4 | 5 | #define MSU_MAGIC "MSU1" 6 | 7 | // larger values cause seeking distortion [ms] 8 | static const uint32_t BUFFER_DURATION = 100; 9 | 10 | input_msu::input_msu() 11 | { 12 | m_PcmFilePos = 0; 13 | m_PcmFileLoop = 0; 14 | m_PcmFileLength = 0; 15 | } 16 | 17 | input_msu::~input_msu() 18 | { 19 | 20 | } 21 | 22 | /** 23 | * Open file 24 | * 25 | * @param p_filehint 26 | * @param p_path 27 | * @param p_reason 28 | * @param p_abort 29 | * 30 | */ 31 | void input_msu::open(service_ptr_t p_filehint, const char *p_path, t_input_open_reason p_reason, abort_callback &p_abort) 32 | { 33 | m_File = p_filehint; 34 | m_PcmPath.set_string(p_path); 35 | input_open_file_helper(m_File, p_path, p_reason, p_abort); 36 | 37 | // read spc file 38 | m_PcmFileLength = static_cast(m_File->get_size(p_abort)); 39 | m_PcmFile.set_size(m_PcmFileLength); 40 | m_File->read(m_PcmFile.get_ptr(), m_PcmFileLength, p_abort); 41 | 42 | // check header 43 | if (::memcmp(m_PcmFile.get_ptr(), MSU_MAGIC, 4)) { 44 | throw exception_io_unsupported_format(); 45 | } 46 | } 47 | 48 | /** 49 | * Get track info 50 | * 51 | * @param p_info 52 | * @param p_abort 53 | * 54 | */ 55 | void input_msu::get_info(file_info &p_info, abort_callback &p_abort) 56 | { 57 | p_info.set_length((m_PcmFileLength - 8.0) / (44100.0 * 4.0)); 58 | 59 | p_info.info_set_int("samplerate", 44100); 60 | p_info.info_set_int("channels", 2); 61 | p_info.info_set_int("bitspersample", 16); 62 | 63 | std::string p = m_PcmPath.toString(); 64 | std::string t = p.substr(p.find_last_of("-") + 1, p.find_last_of(".") - p.find_last_of("-") - 1); 65 | p_info.meta_add("tracknumber", t.c_str()); 66 | } 67 | 68 | /** 69 | * Initialize for decode 70 | * 71 | * @param p_flags 72 | * @param p_abort 73 | * 74 | */ 75 | void input_msu::decode_initialize(unsigned int p_flags, abort_callback &p_abort) 76 | { 77 | m_PcmFilePos = 8; 78 | m_PcmFileLoop = (*((uint32_t *)(m_PcmFile.get_ptr() + 4)) * 4) + 8; 79 | } 80 | 81 | /** 82 | * Decode 83 | * 84 | * @param p_chunk 85 | * @param p_abort 86 | * @return true / false 87 | */ 88 | bool input_msu::decode_run(audio_chunk &p_chunk, abort_callback &p_abort) 89 | { 90 | uint32_t wanted_ms = BUFFER_DURATION; 91 | int16_t buf[44100 * BUFFER_DURATION * 4 / 1000]; 92 | 93 | if (m_PcmFilePos >= m_PcmFileLength) 94 | { 95 | if (m_PcmFileLoop < m_PcmFileLength) 96 | { 97 | m_PcmFilePos = m_PcmFileLoop; 98 | } 99 | else 100 | { 101 | return false; 102 | } 103 | } 104 | 105 | uint32_t buffer_size = m_PcmFilePos + sizeof(buf) < m_PcmFileLength ? sizeof(buf) : m_PcmFileLength - m_PcmFilePos; 106 | 107 | //memcpy(buf, m_PcmFile.get_ptr() + m_PcmFilePos, buffer_size); 108 | 109 | if (buffer_size < sizeof(buf)) 110 | { 111 | buffer_size -= 0; 112 | } 113 | 114 | p_chunk.set_data_int16(reinterpret_cast(m_PcmFile.get_ptr() + m_PcmFilePos), buffer_size / 4, 2, 44100, audio_chunk::channel_config_stereo); 115 | 116 | m_PcmFilePos += buffer_size; 117 | 118 | return true; 119 | } 120 | 121 | /** 122 | * Seek 123 | * 124 | * @param p_seconds 125 | * @param p_abort 126 | */ 127 | void input_msu::decode_seek(double p_seconds, abort_callback &p_abort) 128 | { 129 | // compare desired seek pos with current pos 130 | uint32_t NewPos = static_cast(p_seconds * 4 * 44100) & ~0x0007; 131 | 132 | m_PcmFilePos = NewPos + 8 <= m_PcmFileLength ? NewPos + 8 : m_PcmFileLength; 133 | } 134 | 135 | static input_singletrack_factory_t g_input_msu_factory; 136 | 137 | // version info 138 | DECLARE_COMPONENT_VERSION("MSU-1 PCM Player", 139 | "0.1", 140 | "MSU-1 audio playback plug-in.\n(c) 2017, qwertymodo") 141 | DECLARE_FILE_TYPE("MSU-1 audio files", "*.pcm"); 142 | 143 | // This will prevent users from renaming your component around (important for proper troubleshooter behaviors) or loading multiple instances of it. 144 | VALIDATE_COMPONENT_FILENAME("foo_input_msu.dll"); -------------------------------------------------------------------------------- /input_msu.h: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "stdint.h" 3 | 4 | #ifndef __INPUT_MSU_H__ 5 | #define __INPUT_MSU_H__ 6 | 7 | 8 | class input_msu 9 | { 10 | private: 11 | service_ptr_t m_File; 12 | pfc::array_t m_DecodeBuffer; 13 | 14 | uint32_t m_PcmFileLength; 15 | uint32_t m_PcmFileLoop; 16 | uint32_t m_PcmFilePos; 17 | pfc::array_t m_PcmFile; // in-memory copy of PCM file 18 | pfc::string8 m_PcmPath; // PCM file path 19 | 20 | public: 21 | input_msu(); 22 | ~input_msu(); 23 | 24 | static bool g_is_our_path(const char *p_path, const char *p_extension) { 25 | return (::stricmp_utf8(p_extension, "pcm") == 0); 26 | } 27 | 28 | void open(service_ptr_t p_filehint, const char * p_path, t_input_open_reason p_reason, abort_callback &p_abort); 29 | void get_info(file_info &p_info, abort_callback &p_abort); 30 | void decode_initialize(unsigned int p_flags, abort_callback &p_abort); 31 | bool decode_run(audio_chunk &p_chunk, abort_callback &p_abort); 32 | void decode_seek(double p_seconds, abort_callback &p_abort); 33 | bool decode_can_seek() { return true; } 34 | 35 | t_filestats get_file_stats(abort_callback & p_abort) { return m_File->get_stats(p_abort); } 36 | void decode_on_idle(abort_callback & p_abort) { m_File->on_idle(p_abort); } 37 | bool decode_get_dynamic_info(file_info &p_out, double &p_timestamp_delta) { return false; } 38 | bool decode_get_dynamic_info_track(file_info &p_out, double &p_timestamp_delta) { return false; } 39 | static bool g_is_our_content_type(const char *p_content_type) { return false; } 40 | void retag(const file_info &p_info, abort_callback &p_abort) {} 41 | }; 42 | 43 | #endif /* __INPUT_SNESAPU___ */ -------------------------------------------------------------------------------- /stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // foo_msu.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /stdafx.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../SDK/foobar2000.h" --------------------------------------------------------------------------------