Skip to content

Commit

Permalink
Intermediate commit
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg68 committed Dec 28, 2023
1 parent f85fb05 commit 5d2bab9
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/grandorgue/model/GOCacheObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void GOCacheObject::InitBeforeLoad() {
m_LoadError.Clear();
}

const wxString GOCacheObject::GenerateMessage(const wxString &srcMsg) {
const wxString GOCacheObject::GenerateMessage(const wxString &srcMsg) const {
wxString res;

if (!m_group.IsEmpty()) {
Expand Down
7 changes: 6 additions & 1 deletion src/grandorgue/model/GOCacheObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,12 @@ class GOCacheObject {
virtual const wxString &GetLoadTitle() const = 0;

// Returns the message string prefixed with group and keyPrefix
const wxString GenerateMessage(const wxString &srcMsg);
const wxString GenerateMessage(const wxString &srcMsg) const;

static const wxString generateMessage(
const GOCacheObject *pObjectFor, const wxString &srcMsg) {
return pObjectFor ? pObjectFor->GenerateMessage(srcMsg) : srcMsg;
}
};

#endif
1 change: 1 addition & 0 deletions src/grandorgue/model/GOSoundingPipe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ GOSoundingPipe::GOSoundingPipe(
m_SampleMidiPitchFraction(0.0),
m_RetunePipe(retune),
m_IsTemperamentOriginalBased(true),
m_SoundProvider(this),
m_PipeConfigNode(
&rank->GetPipeConfig(), pOrganModel, this, &m_SoundProvider) {}

Expand Down
4 changes: 3 additions & 1 deletion src/grandorgue/sound/GOSoundAudioSection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "GOSoundAudioSection.h"

#include <wx/intl.h>
#include <wx/log.h>

#include "GOAlloc.h"
#include "GOCache.h"
Expand Down Expand Up @@ -636,6 +637,7 @@ void GOAudioSection::DoCrossfade(
}

void GOAudioSection::Setup(
const GOLoaderFilename *pLoaderFilename,
const void *pcm_data,
const GOWave::SAMPLE_FORMAT pcm_data_format,
const unsigned pcm_data_channels,
Expand Down Expand Up @@ -685,7 +687,7 @@ void GOAudioSection::Setup(
= 1 + end_seg.end_offset - start_seg.start_offset;
unsigned end_length;

if (fade_len > end_seg.end_offset - start_seg.start_offset)
if (fade_len > loop_length - 1)
throw(wxString) _("Loop too short for crossfade");

if (start_seg.start_offset < fade_len)
Expand Down
2 changes: 2 additions & 0 deletions src/grandorgue/sound/GOSoundAudioSection.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
class GOAudioSection;
class GOCache;
class GOCacheWriter;
class GOLoaderFilename;
class GOMemoryPool;
class GOSoundReleaseAlignTable;
class GOSampleStatistic;
Expand Down Expand Up @@ -197,6 +198,7 @@ class GOAudioSection {
int history[BLOCK_HISTORY][MAX_OUTPUT_CHANNELS]);

void Setup(
const GOLoaderFilename *pLoaderFilename,
const void *pcm_data,
GOWave::SAMPLE_FORMAT pcm_data_format,
unsigned pcm_data_channels,
Expand Down
2 changes: 2 additions & 0 deletions src/grandorgue/sound/GOSoundProviderSynthedTrem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ void GOSoundProviderSynthedTrem::Create(
m_AttackInfo.push_back(attack_info);
m_Attack.push_back(new GOAudioSection(pool));
m_Attack[0]->Setup(
nullptr,
data.get(),
GOWave::SF_SIGNEDSHORT_16,
1,
Expand All @@ -105,6 +106,7 @@ void GOSoundProviderSynthedTrem::Create(
m_ReleaseInfo.push_back(release_info);
m_Release.push_back(new GOAudioSection(pool));
m_Release[0]->Setup(
nullptr,
data.get() + attack_samples + loop_samples,
GOWave::SF_SIGNEDSHORT_16,
1,
Expand Down
6 changes: 6 additions & 0 deletions src/grandorgue/sound/GOSoundProviderWave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ unsigned GOSoundProviderWave::GetBytesPerSample(unsigned bits_per_sample) {

void GOSoundProviderWave::CreateAttack(
GOMemoryPool &pool,
const GOLoaderFilename &loaderFilename,
const char *data,
GOWave &wave,
int attack_start,
Expand Down Expand Up @@ -120,6 +121,7 @@ void GOSoundProviderWave::CreateAttack(
GOAudioSection *section = new GOAudioSection(pool);
m_Attack.push_back(section);
section->Setup(
&loaderFilename,
data + attack_pos * GetBytesPerSample(bits_per_sample) * channels,
(GOWave::SAMPLE_FORMAT)bits_per_sample,
channels,
Expand All @@ -132,6 +134,7 @@ void GOSoundProviderWave::CreateAttack(

void GOSoundProviderWave::CreateRelease(
GOMemoryPool &pool,
const GOLoaderFilename &loaderFilename,
const char *data,
GOWave &wave,
int sample_group,
Expand Down Expand Up @@ -163,6 +166,7 @@ void GOSoundProviderWave::CreateRelease(
GOAudioSection *section = new GOAudioSection(pool);
m_Release.push_back(section);
section->Setup(
&loaderFilename,
data + release_offset * GetBytesPerSample(bits_per_sample) * channels,
(GOWave::SAMPLE_FORMAT)bits_per_sample,
channels,
Expand Down Expand Up @@ -243,6 +247,7 @@ void GOSoundProviderWave::LoadFromOneFile(
if (is_attack)
CreateAttack(
pool,
loaderFilename,
data.get(),
wave,
attack_start,
Expand All @@ -262,6 +267,7 @@ void GOSoundProviderWave::LoadFromOneFile(
&& (!is_attack || (wave.GetNbLoops() > 0 && wave.HasReleaseMarker() && !percussive)))
CreateRelease(
pool,
loaderFilename,
data.get(),
wave,
sample_group,
Expand Down
9 changes: 9 additions & 0 deletions src/grandorgue/sound/GOSoundProviderWave.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "GOSoundProvider.h"
#include "GOWaveLoop.h"

class GOCacheObject;
class GOWave;

typedef enum {
Expand Down Expand Up @@ -59,10 +60,14 @@ typedef struct {
} release_load_info;

class GOSoundProviderWave : public GOSoundProvider {
// Used for error messages
GOCacheObject *p_ObjectFor;

unsigned GetBytesPerSample(unsigned bits_per_sample);

void CreateAttack(
GOMemoryPool &pool,
const GOLoaderFilename &loaderFilename,
const char *data,
GOWave &wave,
int attack_start,
Expand All @@ -79,6 +84,7 @@ class GOSoundProviderWave : public GOSoundProvider {

void CreateRelease(
GOMemoryPool &pool,
const GOLoaderFilename &loaderFilename,
const char *data,
GOWave &wave,
int sample_group,
Expand Down Expand Up @@ -118,6 +124,9 @@ class GOSoundProviderWave : public GOSoundProvider {
unsigned GetFaderLength(unsigned MidiKeyNumber);

public:
GOSoundProviderWave(GOCacheObject *pObjectFor = nullptr)
: p_ObjectFor(pObjectFor) {}

/*
* Load all attack and release samples from corresponding .wav files or from
* an archive
Expand Down

0 comments on commit 5d2bab9

Please sign in to comment.