- fixed plugin dol path that was broken in last release.

- added option to upsample/resample music audio to 48khz. code taken from wiixplorer thanks to dimok.
This commit is contained in:
Fledge68 2020-05-25 17:17:50 -05:00
parent 0263a20778
commit 64cf5a6858
18 changed files with 130 additions and 67 deletions

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 MiB

After

Width:  |  Height:  |  Size: 4.1 MiB

View File

@ -1,6 +1,6 @@
#define APP_NAME "WiiFlow WFL"
#define APP_VERSION "5.4.6"
#define APP_VERSION "5.4.7"
#define APP_DATA_DIR "wiiflow"
#define APPS_DIR "apps/wiiflow"

View File

@ -416,6 +416,7 @@ bool CMenu::init(bool usb_mounted)
/* Init background Music Player and song info */
MusicPlayer.Init(m_cfg, m_musicDir, fmt("%s/music", m_themeDataDir.c_str()));
m_music_info = m_cfg.getBool("GENERAL", "display_music_info", false);
MusicPlayer.SetResampleSetting(m_cfg.getBool("general", "resample_to_48khz", false));
/* Init Button Manager and build the menus */
_buildMenus();

View File

@ -66,33 +66,21 @@ void CMenu::_showConfig7(int curPage)
if(m_config7LblUser[i] != -1)
m_btnMgr.show(m_config7LblUser[i]);
if(curPage == 13)
{
m_btnMgr.show(m_config7Lbl1);
m_btnMgr.show(m_config7Btn1);
m_btnMgr.show(m_config7Lbl2);
m_btnMgr.show(m_config7Btn2);
m_btnMgr.show(m_config7Lbl3);
m_btnMgr.show(m_config7Btn3);
}
m_btnMgr.show(m_config7Lbl1);
m_btnMgr.show(m_config7Btn1);
m_btnMgr.show(m_config7Lbl2);
m_btnMgr.show(m_config7Btn2);
m_btnMgr.show(m_config7Lbl3);
m_btnMgr.show(m_config7Btn3);
m_btnMgr.show(m_config7Lbl4);
if(curPage == 7 || curPage == 11 || curPage == 12 || curPage == 13)
m_btnMgr.show(m_config7Btn4);
else
{
m_btnMgr.show(m_config7Lbl1);
m_btnMgr.show(m_config7Btn1);
m_btnMgr.show(m_config7Lbl2);
m_btnMgr.show(m_config7Btn2);
m_btnMgr.show(m_config7Lbl3);
m_btnMgr.show(m_config7Btn3);
m_btnMgr.show(m_config7Lbl4);
if(curPage == 7 || curPage == 11 || curPage == 12)
m_btnMgr.show(m_config7Btn4);
else
{
m_btnMgr.show(m_config7Lbl4Val);
m_btnMgr.show(m_config7Btn4M);
m_btnMgr.show(m_config7Btn4P);
}
m_btnMgr.show(m_config7Lbl4Val);
m_btnMgr.show(m_config7Btn4M);
m_btnMgr.show(m_config7Btn4P);
}
if(curPage == 7)
@ -169,6 +157,8 @@ void CMenu::_showConfig7(int curPage)
m_btnMgr.setText(m_config7Btn2, m_cfg.getBool("general", "box_mode", false) ? _t("on", L"On") : _t("off", L"Off"));
m_btnMgr.setText(m_config7Lbl3, _t("cfg727", L"Use Plugin Database Titles"));
m_btnMgr.setText(m_config7Btn3, m_cfg.getBool(PLUGIN_DOMAIN, "database_titles", true) ? _t("yes", L"Yes") : _t("no", L"No"));
m_btnMgr.setText(m_config7Lbl4, _t("cfg728", L"Upsample music to 48khz"));
m_btnMgr.setText(m_config7Btn4, m_cfg.getBool("general", "resample_to_48khz", true) ? _t("yes", L"Yes") : _t("no", L"No"));
}
}
@ -367,6 +357,15 @@ int CMenu::_config7(int curPage)
m_cfg.setBool(PLUGIN_DOMAIN, "database_titles", val);
m_btnMgr.setText(m_config7Btn3, val ? _t("yes", L"Yes") : _t("no", L"No"));
}
if(m_btnMgr.selected(m_config7Btn4))
{
bool val = !m_cfg.getBool("general", "resample_to_48khz");
m_cfg.setBool("general", "resample_to_48khz", val);
m_btnMgr.setText(m_config7Btn4, val ? _t("yes", L"Yes") : _t("no", L"No"));
MusicPlayer.SetResampleSetting(val);
MusicPlayer.Stop();
MusicPlayer.LoadCurrentFile();
}
}
}
}

View File

@ -193,16 +193,16 @@ void CMenu::_launchHomebrew(const char *filepath, vector<string> arguments)
m_cfg.save(true);
Playlog_Delete();
/* no more error msgs - remove btns and sounds */
cleanup();
/* load boot.dol into memory and load app_booter.bin into memory */
bool ret = (LoadHomebrew(filepath) && LoadAppBooter(fmt("%s/app_booter.bin", m_binsDir.c_str())));
if(ret == false)
{
//error(_t("errgame14", L"app_booter.bin not found!"));
error(_t("errgame14", L"app_booter.bin not found!"));
_exitWiiflow();
}
/* no more error msgs - remove btns and sounds */
cleanup();
AddBootArgument(filepath);
for(u32 i = 0; i < arguments.size(); ++i)

View File

@ -35,16 +35,12 @@ public:
AifDecoder(const char *filepath);
AifDecoder(const u8 *snd, int len);
~AifDecoder();
int GetFormat() { return Format; };
int GetSampleRate() { return SampleRate; };
int Read(u8 *buffer, int buffer_size);
protected:
void OpenFile();
void CloseFile();
u32 DataOffset;
u32 DataSize;
u32 SampleRate;
u8 Format;
};
#endif

View File

@ -100,6 +100,9 @@ void BNSDecoder::OpenFile()
CloseFile();
return;
}
// set sound information
Format = SoundData.format;
SampleRate = SoundData.frequency;
Decode();
}

View File

@ -45,8 +45,6 @@ public:
BNSDecoder(const char * filepath);
BNSDecoder(const u8 * snd, int len);
virtual ~BNSDecoder();
int GetFormat() { return SoundData.format; };
int GetSampleRate() { return SoundData.frequency; };
int Read(u8 * buffer, int buffer_size);
protected:
void OpenFile();

View File

@ -33,8 +33,6 @@ public:
Mp3Decoder(const char * filepath);
Mp3Decoder(const u8 * sound, int len);
~Mp3Decoder();
int GetFormat() { return Format; };
int GetSampleRate() { return SampleRate; };
int Rewind();
int Read(u8 * buffer, int buffer_size);
protected:
@ -45,7 +43,5 @@ protected:
mad_timer_t Timer;
u8 * GuardPtr;
u8 * ReadBuffer;
u8 Format;
u32 SampleRate;
u32 SynthPos;
};

View File

@ -135,6 +135,11 @@ void Musicplayer::SetVolume(u8 volume)
MusicFile.SetVolume(CurrentVolume);
}
void Musicplayer::SetResampleSetting(bool resample)
{
ResampleSetting = resample;
}
void Musicplayer::Previous()
{
if(FileNames.empty() || PosFromPrevFile())

View File

@ -31,12 +31,14 @@ public:
void Init(Config &cfg, const string& musicDir, const string& themeMusicDir);
int InitPlaylist(Config &cfg, const char *playlist, u8 device);
void Tick(bool attenuate);
void SetFadeRate(u8 faderate);
void SetVolume(u8 volume);
void SetMaxVolume(u8 volume);
u8 GetVolume() { return CurrentVolume; };
u8 GetMaxVolume() { return Volume; };
bool ResampleSetting;
void SetResampleSetting(bool resample);
void Previous();
void Next();
@ -51,11 +53,11 @@ public:
bool SongChanged();
time_t DisplayTime;
bool OneSong;
/* Plugin */
void LoadFile(const char *name, bool display_change = true);
void LoadCurrentFile();
protected:
bool PosFromPrevFile();
void LoadCurrentFile();
u8 Volume;
u8 CurrentVolume;

View File

@ -96,25 +96,18 @@ void OggDecoder::OpenFile()
}
ogg_info = ov_info(&ogg_file, -1);
if(!ogg_info)
{
ov_clear(&ogg_file);
delete file_fd;
file_fd = NULL;
return;
}
Format = ((ogg_info->channels == 2) ? VOICE_STEREO_16BIT : VOICE_MONO_16BIT);
SampleRate = ogg_info->rate;
Decode();
}
int OggDecoder::GetFormat()
{
if(!file_fd)
return VOICE_STEREO_16BIT;
return ((ogg_info->channels == 2) ? VOICE_STEREO_16BIT : VOICE_MONO_16BIT);
}
int OggDecoder::GetSampleRate()
{
if(!file_fd)
return 0;
return (int) ogg_info->rate;
}
int OggDecoder::Rewind()
{
if(!file_fd)

View File

@ -34,8 +34,6 @@ public:
OggDecoder(const char * filepath);
OggDecoder(const u8 * snd, int len);
~OggDecoder();
int GetFormat();
int GetSampleRate();
int Rewind();
int Read(u8 * buffer, int buffer_size);
int Tell();

View File

@ -26,9 +26,14 @@
* for WiiXplorer 2010
***************************************************************************/
#include <gccore.h>
#include <malloc.h>
#include <string.h>
#include <unistd.h>
#include "SoundDecoder.hpp"
#include "MusicPlayer.hpp"
static const u32 FixedPointShift = 15;
static const u32 FixedPointScale = 1 << FixedPointShift;
SoundDecoder::SoundDecoder()
{
@ -57,6 +62,9 @@ SoundDecoder::~SoundDecoder()
if(file_fd)
delete file_fd;
file_fd = NULL;
if(ResampleBuffer)
free(ResampleBuffer);
}
void SoundDecoder::Init()
@ -64,6 +72,7 @@ void SoundDecoder::Init()
SoundType = SOUND_RAW;
SoundBlocks = 8;
SoundBlockSize = 8192;
ResampleTo48kHz = MusicPlayer.ResampleSetting;
CurPos = 0;
LoopStart = 0;
LoopEnd = 0;
@ -73,6 +82,8 @@ void SoundDecoder::Init()
ExitRequested = false;
SoundBuffer.SetBufferBlockSize(SoundBlockSize);
SoundBuffer.Resize(SoundBlocks);
ResampleBuffer = NULL;
ResampleRatio = 0;
}
int SoundDecoder::Rewind()
@ -92,6 +103,47 @@ int SoundDecoder::Read(u8 * buffer, int buffer_size)
return ret;
}
void SoundDecoder::EnableUpsample(void)
{
if( (ResampleBuffer == NULL)
&& IsStereo() && Is16Bit()
&& SampleRate != 32000
&& SampleRate != 48000)
{
ResampleBuffer = (u8*)memalign(32, SoundBlockSize);
ResampleRatio = ( FixedPointScale * SampleRate ) / 48000;
SoundBlockSize = ( SoundBlockSize * ResampleRatio ) / FixedPointScale;
SoundBlockSize &= ~0x03;
// set new sample rate
SampleRate = 48000;
}
}
void SoundDecoder::Upsample(s16 *src, s16 *dst, u32 nr_src_samples, u32 nr_dst_samples)
{
int timer = 0;
for(u32 i = 0, n = 0; i < nr_dst_samples; i += 2)
{
if((n+3) < nr_src_samples) {
// simple fixed point linear interpolation
dst[i] = src[n] + ( ((src[n+2] - src[n] ) * timer) >> FixedPointShift );
dst[i+1] = src[n+1] + ( ((src[n+3] - src[n+1]) * timer) >> FixedPointShift );
}
else {
dst[i] = src[n];
dst[i+1] = src[n+1];
}
timer += ResampleRatio;
if(timer >= (int)FixedPointScale) {
n += 2;
timer -= FixedPointScale;
}
}
}
void SoundDecoder::Decode()
{
if(!file_fd || ExitRequested || EndOfFile)
@ -121,6 +173,10 @@ void SoundDecoder::Decode()
return;
}
//*******************************************
if(ResampleTo48kHz && !ResampleBuffer)
EnableUpsample();
while(done < SoundBlockSize)
{
int ret = Read(&write_buf[done], SoundBlockSize-done);
@ -146,6 +202,17 @@ void SoundDecoder::Decode()
if(done > 0)
{
// check if we need to resample
if(ResampleBuffer && ResampleRatio)
{
memcpy(ResampleBuffer, write_buf, done);
int src_samples = done >> 1;
int dest_samples = ( src_samples * FixedPointScale ) / ResampleRatio;
dest_samples &= ~0x01;
Upsample((s16*)ResampleBuffer, (s16*)write_buf, src_samples, dest_samples);
done = dest_samples << 1;
}
SoundBuffer.SetBufferSize(newWhich, done);
SoundBuffer.SetBufferReady(newWhich, true);
}

View File

@ -55,8 +55,8 @@ public:
virtual int Tell() { return CurPos; };
virtual int Seek(int pos) { CurPos = pos; return file_fd->seek(CurPos, SEEK_SET); };
virtual int Rewind();
virtual int GetFormat() { return VOICE_STEREO_16BIT; };
virtual int GetSampleRate() { return 48000; };
virtual u8 GetFormat() { return Format; }
virtual u16 GetSampleRate() { return SampleRate; }
virtual void Decode();
virtual u32 GetBufferSize() { return SoundBuffer.GetBufferSize(); };
virtual u8 * GetBuffer() { return SoundBuffer.GetBuffer(); };
@ -74,21 +74,29 @@ public:
virtual void ClearBuffer() { SoundBuffer.ClearBuffer(); };
virtual bool IsStereo() { return (GetFormat() == VOICE_STEREO_16BIT || GetFormat() == VOICE_STEREO_8BIT); };
virtual bool Is16Bit() { return (GetFormat() == VOICE_STEREO_16BIT || GetFormat() == VOICE_MONO_16BIT); };
void EnableUpsample(void);
protected:
void Init();
void Upsample(s16 *src, s16 *dst, u32 nr_src_samples, u32 nr_dst_samples);
CFile * file_fd;
BufferCircle SoundBuffer;
u8 SoundType;
u16 SoundBlocks;
int SoundBlockSize;
int CurPos;
bool ResampleTo48kHz;
bool Loop;
int LoopStart;
int LoopEnd;
bool EndOfFile;
bool Decoding;
bool ExitRequested;
u8 Format;
u16 SampleRate;
u8 *ResampleBuffer;
u32 ResampleRatio;
};
#endif

View File

@ -82,16 +82,12 @@ public:
WavDecoder(const char * filepath);
WavDecoder(const u8 * snd, int len);
~WavDecoder();
int GetFormat() { return Format; };
int GetSampleRate() { return SampleRate; };
int Read(u8 * buffer, int buffer_size);
protected:
void OpenFile();
void CloseFile();
u32 DataOffset;
u32 DataSize;
u32 SampleRate;
u8 Format;
bool Is16Bit;
};

View File

@ -69,6 +69,7 @@ cfg724=Lock coverflow layouts
cfg725=Shutdown to idle standby
cfg726=Covers Box Mode
cfg727=Use Plugin Database Titles
cfg728=Upsample music to 48khz
cfga2=Install game
cfga3=Install
cfga6=Language