Browse code

Port: Use std::filesystem::path for reading/writing files. - before override

Clarissa Walker authored on 2024/08/22 20:57:20
Showing 1 changed files
... ...
@@ -7,6 +7,7 @@
7 7
 
8 8
 #pragma once
9 9
 
10
+#include <filesystem>
10 11
 #include <memory>
11 12
 #include <string>
12 13
 #include <vector>
... ...
@@ -37,10 +38,7 @@ public:
37 38
 	// These are not defined in XSFPlayer.cpp, they should be defined in your own player's source. The Create functions should return a pointer to your player's class.
38 39
 	static const char *WinampDescription;
39 40
 	static const char *WinampExts;
40
-	static XSFPlayer *Create(const std::string &fn);
41
-#ifdef _WIN32
42
-	static XSFPlayer *Create(const std::wstring &fn);
43
-#endif
41
+	static XSFPlayer *Create(const std::filesystem::path &path);
44 42
 
45 43
 	virtual ~XSFPlayer() { }
46 44
 	XSFPlayer &operator=(const XSFPlayer &xSFPlayer);
Browse code

Various changes:

* Use enum class instead of enum (except for the enums for the resource IDs, not really necessary there).
* For NCSF specifically, included a function to convert an enum class to its underlying integral type (as this is needed for use with the std::bitset class).
* Cleanup headers so all the ones needed in a file are explicitly included even if they may possibly be included in another header.
* Used forward declarations in a few spots.
* Explicitly namespaced all (u)int*_t uses (this might seem like overkill, but it helps me see when the standard types are being used with a simple search for std::).
* Made sure it all builds with MinGW-w64 as well (both gcc and clang).
* Removed some std::move from DialogBuilder.cpp based on clang's warnings for that.
* Replaced use of std::copy_n on strings in DialogBuilder.cpp with my CopyToString functions that use wcscpy.
* Replaced CHAR_MIN/CHAR_MAX in eqstr.h and ltstr.h with std::numeric_limits<char>::min/max().

Naram Qashat authored on 2021/03/21 03:16:45
Showing 1 changed files
... ...
@@ -8,8 +8,10 @@
8 8
 #pragma once
9 9
 
10 10
 #include <memory>
11
+#include <string>
12
+#include <vector>
13
+#include <cstdint>
11 14
 #include "XSFFile.h"
12
-
13 15
 #ifdef WINAMP_PLUGIN
14 16
 # include "windowsh_wrapper.h"
15 17
 # include "winamp/out.h"
... ...
@@ -19,12 +21,12 @@
19 21
 class XSFPlayer
20 22
 {
21 23
 protected:
22
-	static const uint32_t CHECK_SILENCE_BIAS = 0x8000000;
23
-	static const uint32_t CHECK_SILENCE_LEVEL = 7;
24
+	static const std::uint32_t CHECK_SILENCE_BIAS = 0x8000000;
25
+	static const std::uint32_t CHECK_SILENCE_LEVEL = 7;
24 26
 
25 27
 	std::unique_ptr<XSFFile> xSF;
26 28
 	unsigned sampleRate, detectedSilenceSample, detectedSilenceSec, skipSilenceOnStartSec, lengthSample, fadeSample, currentSample;
27
-	uint32_t prevSampleL, prevSampleR;
29
+	std::uint32_t prevSampleL, prevSampleR;
28 30
 	int lengthInMS, fadeInMS;
29 31
 	double volume;
30 32
 	bool ignoreVolume, uses32BitSamplesClampedTo16Bit;
... ...
@@ -49,11 +51,11 @@ public:
49 51
 	void SetSampleRate(unsigned newSampleRate) { this->sampleRate = newSampleRate; }
50 52
 	void IgnoreVolume() { this->ignoreVolume = true; }
51 53
 	virtual bool Load();
52
-	bool FillBuffer(std::vector<uint8_t> &buf, unsigned &samplesWritten);
53
-	virtual void GenerateSamples(std::vector<uint8_t> &buf, unsigned offset, unsigned samples) = 0;
54
+	bool FillBuffer(std::vector<std::uint8_t> &buf, unsigned &samplesWritten);
55
+	virtual void GenerateSamples(std::vector<std::uint8_t> &buf, unsigned offset, unsigned samples) = 0;
54 56
 	void SeekTop();
55 57
 #ifdef WINAMP_PLUGIN
56
-	int Seek(unsigned seekPosition, volatile int *killswitch, std::vector<uint8_t> &buf, Out_Module *outMod);
58
+	int Seek(unsigned seekPosition, volatile int *killswitch, std::vector<std::uint8_t> &buf, Out_Module *outMod);
57 59
 #endif
58 60
 	virtual void Terminate() = 0;
59 61
 };
Browse code

Cleanup a few comments and strings.

Naram Qashat authored on 2021/03/20 20:25:12
Showing 1 changed files
... ...
@@ -32,7 +32,7 @@ protected:
32 32
 	XSFPlayer();
33 33
 	XSFPlayer(const XSFPlayer &xSFPLayer);
34 34
 public:
35
-	// These are not defined in XSFPlayer.cpp, they should be defined in your own player's source.  The Create functions should return a pointer to your player's class.
35
+	// These are not defined in XSFPlayer.cpp, they should be defined in your own player's source. The Create functions should return a pointer to your player's class.
36 36
 	static const char *WinampDescription;
37 37
 	static const char *WinampExts;
38 38
 	static XSFPlayer *Create(const std::string &fn);
Browse code

Remove last modification date from files.

(I never remember to update these and besides, GitHub history can show when they were last modified.)

Naram Qashat authored on 2021/03/19 10:58:12
Showing 1 changed files
... ...
@@ -1,7 +1,6 @@
1 1
 /*
2 2
  * xSF - Core Player
3 3
  * By Naram Qashat (CyberBotX) [cyberbotx@cyberbotx.com]
4
- * Last modification on 2014-09-24
5 4
  *
6 5
  * Partially based on the vio*sf framework
7 6
  */
Browse code

update for C++17 compliance, update to latest 2sf, add WINE cross-compile makefiles

Adam Higerd authored on 2021/02/11 15:36:17
Showing 1 changed files
... ...
@@ -13,7 +13,7 @@
13 13
 
14 14
 #ifdef WINAMP_PLUGIN
15 15
 # include "windowsh_wrapper.h"
16
-# include <winamp/out.h>
16
+# include "winamp/out.h"
17 17
 #endif
18 18
 
19 19
 // This is a base class, a player for a specific type of xSF should inherit from this.
Browse code

Lots of changes in regards to strings, as follows:

* Removed my custom String class, as well as removed the really old
Unicode ConvertUTF, the UTF Converter, and the UTF Encode/Decode
functions.
* Replaced the above with using standard C++ std::wstring_convert and
std::codecvt_utf8.
* Added headers adapted from llvm's libc++ project for allowing the
above C++ classes to exist with GCC and Clang when libc++ isn't being
used.
* Used std::string over std::wstring whenever possible.
* Added header adapted from llvm's libc++ project to create special
versions of the ifstream and ofstream classes that would utilize _wfopen
on non-MSVC Windows compilers, so those compilers could access files on
Windows that use characters outside the current codepage.
* Removed the -static-libgcc and -static-libstdc++ flags from the
Makefile for non-MSVC builds. The generated DLLs will require extra DLLs
from either Cygwin or MinGW (whichever is used to compile), I've only
tested with MinGW and for some reason they crash Winamp on exit, I have
no idea why.

Naram Qashat authored on 2014/09/24 13:58:55
Showing 1 changed files
... ...
@@ -1,7 +1,7 @@
1 1
 /*
2 2
  * xSF - Core Player
3 3
  * By Naram Qashat (CyberBotX) [cyberbotx@cyberbotx.com]
4
- * Last modification on 2014-09-17
4
+ * Last modification on 2014-09-24
5 5
  *
6 6
  * Partially based on the vio*sf framework
7 7
  */
... ...
@@ -37,7 +37,7 @@ public:
37 37
 	static const char *WinampDescription;
38 38
 	static const char *WinampExts;
39 39
 	static XSFPlayer *Create(const std::string &fn);
40
-#ifdef _MSC_VER
40
+#ifdef _WIN32
41 41
 	static XSFPlayer *Create(const std::wstring &fn);
42 42
 #endif
43 43
 
Browse code

* Fixes for gcc and clang (while they can compile the code, the DLLs made aren't functional, but oh well).

* [2SF] Used more up-to-date asmjit, despite the ugly looking code.

Naram Qashat authored on 2014/09/17 19:51:45
Showing 1 changed files
... ...
@@ -1,13 +1,14 @@
1 1
 /*
2 2
  * xSF - Core Player
3 3
  * By Naram Qashat (CyberBotX) [cyberbotx@cyberbotx.com]
4
- * Last modification on 2014-09-08
4
+ * Last modification on 2014-09-17
5 5
  *
6 6
  * Partially based on the vio*sf framework
7 7
  */
8 8
 
9 9
 #pragma once
10 10
 
11
+#include <memory>
11 12
 #include "XSFFile.h"
12 13
 
13 14
 #ifdef WINAMP_PLUGIN
... ...
@@ -36,7 +37,9 @@ public:
36 37
 	static const char *WinampDescription;
37 38
 	static const char *WinampExts;
38 39
 	static XSFPlayer *Create(const std::string &fn);
40
+#ifdef _MSC_VER
39 41
 	static XSFPlayer *Create(const std::wstring &fn);
42
+#endif
40 43
 
41 44
 	virtual ~XSFPlayer() { }
42 45
 	XSFPlayer &operator=(const XSFPlayer &xSFPlayer);
Browse code

Use #pragma once instead of include guards.

Naram Qashat authored on 2014/09/08 14:47:36
Showing 1 changed files
... ...
@@ -1,13 +1,12 @@
1 1
 /*
2 2
  * xSF - Core Player
3 3
  * By Naram Qashat (CyberBotX) [cyberbotx@cyberbotx.com]
4
- * Last modification on 2013-05-07
4
+ * Last modification on 2014-09-08
5 5
  *
6 6
  * Partially based on the vio*sf framework
7 7
  */
8 8
 
9
-#ifndef XSFPLAYER_H
10
-#define XSFPLAYER_H
9
+#pragma once
11 10
 
12 11
 #include "XSFFile.h"
13 12
 
... ...
@@ -56,5 +55,3 @@ public:
56 55
 #endif
57 56
 	virtual void Terminate() = 0;
58 57
 };
59
-
60
-#endif
Browse code

* Replaced Lanczos window with Hann window for the windowed sinc function in the NCSF plugin. * Added a ring buffer specifically designed for working with SWAVs to replace the one provided by kode54, still have to give him thanks for the original though. * Fixed clipping issue caused by invalid clamping values. * Minor fix to using the min()/max() functions of numeric_limits because Winamp's out.h includes windows.h without my specific wrapper to redefine things.

Naram Qashat authored on 2013/05/07 05:42:46
Showing 1 changed files
... ...
@@ -1,7 +1,7 @@
1 1
 /*
2 2
  * xSF - Core Player
3 3
  * By Naram Qashat (CyberBotX) [cyberbotx@cyberbotx.com]
4
- * Last modification on 2013-04-26
4
+ * Last modification on 2013-05-07
5 5
  *
6 6
  * Partially based on the vio*sf framework
7 7
  */
... ...
@@ -12,6 +12,7 @@
12 12
 #include "XSFFile.h"
13 13
 
14 14
 #ifdef WINAMP_PLUGIN
15
+# include "windowsh_wrapper.h"
15 16
 # include <winamp/out.h>
16 17
 #endif
17 18
 
Browse code

Fixed up the Lanczos interpolation in NCSF (thanks to kode54), also allowed the NCSF plugin to use 32-bit samples in it's GenerateSamples function.

Naram Qashat authored on 2013/04/26 00:54:28
Showing 1 changed files
... ...
@@ -1,7 +1,7 @@
1 1
 /*
2 2
  * xSF - Core Player
3 3
  * By Naram Qashat (CyberBotX) [cyberbotx@cyberbotx.com]
4
- * Last modification on 2013-04-23
4
+ * Last modification on 2013-04-26
5 5
  *
6 6
  * Partially based on the vio*sf framework
7 7
  */
... ...
@@ -19,15 +19,15 @@
19 19
 class XSFPlayer
20 20
 {
21 21
 protected:
22
-	static const unsigned CHECK_SILENCE_BIAS = 0x8000000;
23
-	static const unsigned CHECK_SILENCE_LEVEL = 7;
22
+	static const uint32_t CHECK_SILENCE_BIAS = 0x8000000;
23
+	static const uint32_t CHECK_SILENCE_LEVEL = 7;
24 24
 
25 25
 	std::unique_ptr<XSFFile> xSF;
26 26
 	unsigned sampleRate, detectedSilenceSample, detectedSilenceSec, skipSilenceOnStartSec, lengthSample, fadeSample, currentSample;
27
-	unsigned long prevSampleL, prevSampleR;
27
+	uint32_t prevSampleL, prevSampleR;
28 28
 	int lengthInMS, fadeInMS;
29 29
 	double volume;
30
-	bool ignoreVolume;
30
+	bool ignoreVolume, uses32BitSamplesClampedTo16Bit;
31 31
 
32 32
 	XSFPlayer();
33 33
 	XSFPlayer(const XSFPlayer &xSFPLayer);
Browse code

Added Lanczos interpolation to the NCSF plugin, and cleaned up a bit of the other code, as well as removing pstdint.h since it's no longer needed.

Naram Qashat authored on 2013/04/23 20:29:21
Showing 1 changed files
... ...
@@ -1,7 +1,7 @@
1 1
 /*
2 2
  * xSF - Core Player
3 3
  * By Naram Qashat (CyberBotX) [cyberbotx@cyberbotx.com]
4
- * Last modification on 2013-03-25
4
+ * Last modification on 2013-04-23
5 5
  *
6 6
  * Partially based on the vio*sf framework
7 7
  */
... ...
@@ -22,7 +22,7 @@ protected:
22 22
 	static const unsigned CHECK_SILENCE_BIAS = 0x8000000;
23 23
 	static const unsigned CHECK_SILENCE_LEVEL = 7;
24 24
 
25
-	XSFFile *xSF;
25
+	std::unique_ptr<XSFFile> xSF;
26 26
 	unsigned sampleRate, detectedSilenceSample, detectedSilenceSec, skipSilenceOnStartSec, lengthSample, fadeSample, currentSample;
27 27
 	unsigned long prevSampleL, prevSampleR;
28 28
 	int lengthInMS, fadeInMS;
... ...
@@ -38,10 +38,10 @@ public:
38 38
 	static XSFPlayer *Create(const std::string &fn);
39 39
 	static XSFPlayer *Create(const std::wstring &fn);
40 40
 
41
-	virtual ~XSFPlayer() { if (this->xSF) delete this->xSF; }
41
+	virtual ~XSFPlayer() { }
42 42
 	XSFPlayer &operator=(const XSFPlayer &xSFPlayer);
43
-	XSFFile *GetXSFFile() { return this->xSF; }
44
-	const XSFFile *GetXSFFile() const { return this->xSF; }
43
+	XSFFile *GetXSFFile() { return this->xSF.get(); }
44
+	const XSFFile *GetXSFFile() const { return this->xSF.get(); }
45 45
 	unsigned GetLengthInSamples() const { return this->lengthSample + this->fadeSample; }
46 46
 	unsigned GetSampleRate() const { return this->sampleRate; }
47 47
 	void SetSampleRate(unsigned newSampleRate) { this->sampleRate = newSampleRate; }
Browse code

Import actual code.

Naram Qashat authored on 2013/03/26 02:41:19
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,59 @@
1
+/*
2
+ * xSF - Core Player
3
+ * By Naram Qashat (CyberBotX) [cyberbotx@cyberbotx.com]
4
+ * Last modification on 2013-03-25
5
+ *
6
+ * Partially based on the vio*sf framework
7
+ */
8
+
9
+#ifndef XSFPLAYER_H
10
+#define XSFPLAYER_H
11
+
12
+#include "XSFFile.h"
13
+
14
+#ifdef WINAMP_PLUGIN
15
+# include <winamp/out.h>
16
+#endif
17
+
18
+// This is a base class, a player for a specific type of xSF should inherit from this.
19
+class XSFPlayer
20
+{
21
+protected:
22
+	static const unsigned CHECK_SILENCE_BIAS = 0x8000000;
23
+	static const unsigned CHECK_SILENCE_LEVEL = 7;
24
+
25
+	XSFFile *xSF;
26
+	unsigned sampleRate, detectedSilenceSample, detectedSilenceSec, skipSilenceOnStartSec, lengthSample, fadeSample, currentSample;
27
+	unsigned long prevSampleL, prevSampleR;
28
+	int lengthInMS, fadeInMS;
29
+	double volume;
30
+	bool ignoreVolume;
31
+
32
+	XSFPlayer();
33
+	XSFPlayer(const XSFPlayer &xSFPLayer);
34
+public:
35
+	// These are not defined in XSFPlayer.cpp, they should be defined in your own player's source.  The Create functions should return a pointer to your player's class.
36
+	static const char *WinampDescription;
37
+	static const char *WinampExts;
38
+	static XSFPlayer *Create(const std::string &fn);
39
+	static XSFPlayer *Create(const std::wstring &fn);
40
+
41
+	virtual ~XSFPlayer() { if (this->xSF) delete this->xSF; }
42
+	XSFPlayer &operator=(const XSFPlayer &xSFPlayer);
43
+	XSFFile *GetXSFFile() { return this->xSF; }
44
+	const XSFFile *GetXSFFile() const { return this->xSF; }
45
+	unsigned GetLengthInSamples() const { return this->lengthSample + this->fadeSample; }
46
+	unsigned GetSampleRate() const { return this->sampleRate; }
47
+	void SetSampleRate(unsigned newSampleRate) { this->sampleRate = newSampleRate; }
48
+	void IgnoreVolume() { this->ignoreVolume = true; }
49
+	virtual bool Load();
50
+	bool FillBuffer(std::vector<uint8_t> &buf, unsigned &samplesWritten);
51
+	virtual void GenerateSamples(std::vector<uint8_t> &buf, unsigned offset, unsigned samples) = 0;
52
+	void SeekTop();
53
+#ifdef WINAMP_PLUGIN
54
+	int Seek(unsigned seekPosition, volatile int *killswitch, std::vector<uint8_t> &buf, Out_Module *outMod);
55
+#endif
56
+	virtual void Terminate() = 0;
57
+};
58
+
59
+#endif