-
Notifications
You must be signed in to change notification settings - Fork 12
Merge pr-105 #106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Merge pr-105 #106
Changes from all commits
169da59
4ebe66b
33d7cfa
0838802
366df28
0106ae2
60eba82
866c7f7
cbeb11b
bc362ba
b9a8dec
d6dff84
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,15 +40,15 @@ FileOutputProcessor::FileOutputProcessor( | |
| mixPresentationRepository_(mixPresentationRepository), | ||
| mixPresentationLoudnessRepository_(mixPresentationLoudnessRepository) {} | ||
|
|
||
| FileOutputProcessor::~FileOutputProcessor() {} | ||
| FileOutputProcessor::~FileOutputProcessor() = default; | ||
|
|
||
| //============================================================================== | ||
| const juce::String FileOutputProcessor::getName() const { | ||
| return {"FileOutput"}; | ||
| } | ||
| //============================================================================== | ||
| void FileOutputProcessor::prepareToPlay(double sampleRate, | ||
| int samplesPerBlock) { | ||
| void FileOutputProcessor::prepareToPlay(const double sampleRate, | ||
| const int samplesPerBlock) { | ||
| FileExport configParams = fileExportRepository_.get(); | ||
| if (configParams.getSampleRate() != sampleRate) { | ||
| LOG_ANALYTICS(0, "FileOutputProcessor sample rate changed to " + | ||
|
|
@@ -61,7 +61,8 @@ void FileOutputProcessor::prepareToPlay(double sampleRate, | |
| sampleRate_ = sampleRate; | ||
| } | ||
|
|
||
| void FileOutputProcessor::setNonRealtime(bool isNonRealtime) noexcept { | ||
| void FileOutputProcessor::setNonRealtime(const bool isNonRealtime) noexcept { | ||
| // Bouncing in DAW and currently rendering || not bouncing and not rendering | ||
| if (isNonRealtime == performingRender_) { | ||
| return; | ||
| } | ||
|
|
@@ -92,10 +93,12 @@ void FileOutputProcessor::processBlock(juce::AudioBuffer<float>& buffer, | |
| return; | ||
| } | ||
|
|
||
| // Process audio elements individually as Wav files | ||
| for (int i = 0; i < iamfWavFileWriters_.size(); ++i) { | ||
| iamfWavFileWriters_[i]->write(buffer); | ||
| } | ||
|
|
||
| // Process IAMF File | ||
| if (iamfFileWriter_) { | ||
| iamfFileWriter_->writeFrame(buffer); | ||
| } | ||
|
|
@@ -105,8 +108,8 @@ void FileOutputProcessor::processBlock(juce::AudioBuffer<float>& buffer, | |
| void FileOutputProcessor::initializeFileExport(FileExport& config) { | ||
| LOG_ANALYTICS(0, "Beginning .iamf file export"); | ||
| performingRender_ = true; | ||
| startTime_ = config.getStartTime(); | ||
| endTime_ = config.getEndTime(); | ||
| startTime_ = config.getStartTime() / 1000.0; | ||
| endTime_ = config.getEndTime() / 1000.0; | ||
| std::string exportFile = config.getExportFile().toStdString(); | ||
|
|
||
| // To create the IAMF file, create a list of all the audio element wav | ||
|
|
@@ -159,10 +162,10 @@ void FileOutputProcessor::initializeFileExport(FileExport& config) { | |
| } | ||
| } | ||
|
|
||
| void FileOutputProcessor::closeFileExport(FileExport& config) { | ||
| void FileOutputProcessor::closeFileExport(const FileExport& config) { | ||
| LOG_ANALYTICS(0, "closing writers and exporting IAMF file"); | ||
| // close the output file, since rendering is completed | ||
| for (auto& writer : iamfWavFileWriters_) { | ||
| for (const auto& writer : iamfWavFileWriters_) { | ||
| writer->close(); | ||
| } | ||
|
|
||
|
|
@@ -209,20 +212,24 @@ bool FileOutputProcessor::shouldBufferBeWritten( | |
|
|
||
| // Calculate the current time with the existing number of samples that have | ||
| // been processed | ||
| long currentTime = sampleTally_ / sampleRate_; | ||
| const double currentTime = static_cast<double>(sampleTally_) / sampleRate_; | ||
| // update the sample tally | ||
| sampleTally_ += buffer.getNumSamples(); | ||
| // with the updated sample tally, calculate the next time | ||
| long nextTime = sampleTally_ / sampleRate_; | ||
|
|
||
| if (startTime_ != 0 || endTime_ != 0) { | ||
| // Handle the case where startTime and endTime are set, implying we | ||
| // are only bouncing a subset of the mix | ||
| // No range specified — write everything | ||
| if (startTime_ <= 0 && endTime_ <= 0) { | ||
| return true; | ||
| } | ||
|
|
||
| // do not render | ||
| if (currentTime < startTime_ || nextTime > endTime_) { | ||
| return false; | ||
| } | ||
| // Skip if buffer starts before the requested start time | ||
| if (startTime_ > 0 && currentTime < startTime_) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to check is startTime > 0 or endTime is > 0. Looks like above we are returning if startTime or endTime are <= 0 already?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you make the suggested change, I would combine these into one statement |
||
| return false; | ||
| } | ||
|
|
||
| // Skip if buffer starts at or past the requested end time | ||
| if (endTime_ > 0 && currentTime >= endTime_) { | ||
| return false; | ||
| } | ||
|
|
||
| return true; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -79,8 +79,8 @@ void WavFileOutputProcessor::setNonRealtime(bool isNonRealtime) noexcept { | |
| // Start Rendering | ||
| FileExport configParams = fileExportRepository_.get(); | ||
| RoomSetup roomSetup = roomSetupRepository_.get(); | ||
| startTime_ = configParams.getStartTime(); | ||
| endTime_ = configParams.getEndTime(); | ||
| startTime_ = configParams.getStartTime() / 1000.0; | ||
| endTime_ = configParams.getEndTime() / 1000.0; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems like every time we fetch these values we're dividing them by 1000. Does it make more sense to divide them when we store them instead, since that will be one place instead of on each fetch? I'm genuinely asking, there might be a good reason to divide the value this way instead. |
||
| if ((configParams.getAudioFileFormat() == AudioFileFormat::WAV) && | ||
| configParams.getExportAudio()) { | ||
| fileWriter_ = new FileWriter( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather then casting here, should we just make sampleTally_ a double?
In general, this math seems a bit confused since sampleRate_ is already a long cast from a double. So feels like they could both become doubles here and it will be more straightforward?