-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not add duplicate sounds for merging.
- Loading branch information
1 parent
beb3d3b
commit d919d4d
Showing
8 changed files
with
85 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include "soundreaderformerger.h" | ||
|
||
#include "Sound/soundmerger.h" | ||
|
||
SoundReaderForMerger::SoundReaderForMerger( | ||
SoundHandler* const cacheHandler, | ||
const stdsptr<AudioStreamsData>& openedAudio, | ||
const int secondId, const SampleRange& sampleRange) : | ||
SoundReader(cacheHandler, openedAudio, secondId, sampleRange) {} | ||
|
||
void SoundReaderForMerger::afterProcessing() { | ||
for(const auto& merger : mMergers) { | ||
if(!merger) continue; | ||
for(const auto& ss : mSSAbsRanges) { | ||
merger->addSoundToMerge({ss.fSampleShift, ss.fSamplesRange, | ||
ss.fVolume, ss.fSpeed, | ||
enve::make_shared<Samples>(getSamples())}); | ||
} | ||
} | ||
SoundReader::afterProcessing(); | ||
} | ||
|
||
void SoundReaderForMerger::addSingleSound(void* const soundPtr, | ||
const int sampleShift, | ||
const SampleRange& absRange, | ||
const QrealSnapshot& volume, | ||
const qreal speed) { | ||
const bool c = mSoundPtrs.contains(soundPtr); | ||
if(c) return; | ||
mSoundPtrs.append(soundPtr); | ||
mSSAbsRanges.append({sampleShift, absRange, volume, speed}); | ||
} | ||
|
||
void SoundReaderForMerger::addMerger(SoundMerger* const merger) { | ||
mMergers << merger; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#ifndef SOUNDREADERFORMERGER_H | ||
#define SOUNDREADERFORMERGER_H | ||
|
||
#include "soundreader.h" | ||
|
||
#include "Animators/qrealsnapshot.h" | ||
|
||
class SoundMerger; | ||
|
||
class CORE_EXPORT SoundReaderForMerger : public SoundReader { | ||
e_OBJECT | ||
struct SingleSound { | ||
int fSampleShift; | ||
SampleRange fSamplesRange; | ||
QrealSnapshot fVolume; | ||
qreal fSpeed; | ||
}; | ||
protected: | ||
SoundReaderForMerger(SoundHandler * const cacheHandler, | ||
const stdsptr<AudioStreamsData>& openedAudio, | ||
const int secondId, const SampleRange& sampleRange); | ||
|
||
void afterProcessing(); | ||
public: | ||
void addSingleSound(void* const soundPtr, | ||
const int sampleShift, | ||
const SampleRange& absRange, | ||
const QrealSnapshot& volume, | ||
const qreal speed); | ||
|
||
void addMerger(SoundMerger * const merger); | ||
private: | ||
QList<void*> mSoundPtrs; | ||
QList<SingleSound> mSSAbsRanges; | ||
QList<stdptr<SoundMerger>> mMergers; | ||
}; | ||
|
||
#endif // SOUNDREADERFORMERGER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters