Skip to content

Commit

Permalink
Sound dev (#12)
Browse files Browse the repository at this point in the history
* Added more granular information of the original video file

Co-authored-by: Sound Development <info@sounddevelopment.nl>
  • Loading branch information
ffAudio and SoundDevelopment authored May 18, 2021
1 parent 7fb18b1 commit 641c1ce
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions Basics/foleys_Structures.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,11 @@ struct Size final
int width = 0;
int height = 0;

double getAspectRatio()
{
return (height > 0) ? width / double (height) : 1.33;
}
double getAspectRatio() const { return (height > 0) ? width / double (height) : 1.33; }

juce::String toString() const
{
return juce::String (width) + "x" + juce::String (height);
}
juce::String toString() const { return juce::String(width) + "x" + juce::String(height); }

bool isEmpty() const { return ( ( width * height ) == 0 ); }
};

enum class Aspect
Expand All @@ -53,17 +49,27 @@ enum class Aspect
/** Defines the size and time settings for a VideoStream */
struct VideoStreamSettings final
{
Size frameSize;
int defaultDuration = 1001;
int timebase = 24000;
Size frameSize;
int defaultDuration = 1001;
int timebase = 24000;

bool isValid() const { return (!frameSize.isEmpty()) && (timebase != 0) && (defaultDuration != 0); }
double getFrameRate() const { return (timebase > 0 ? (timebase / static_cast<double>(defaultDuration)) : 0.0); }
double getFrameDurationSeconds() const { return defaultDuration / static_cast<double>( timebase); }
juce::String toString() const { return frameSize.toString() + " " + juce::String(getFrameRate(), 2) + " FPS"; }
};

/** Defines the number of channels and time settings for an AudioStream */
struct AudioStreamSettings final
{
int numChannels = 2;
int numChannels = 2;
int defaultNumSamples = 1024;
int timebase = 48000;
int timebase = 48000;
int bitsPerSample = 0;
[[nodiscard]] bool isValid() const { return (timebase > 0) && (numChannels > 0) && (bitsPerSample > 0); }
[[nodiscard]] juce::String toString() const { return juce::String(numChannels) + " channels at " + juce::String(timebase) + " Hz @ " + juce::String(bitsPerSample) + " bits"; }
[[nodiscard]] int getFrameSize() const { return numChannels * getSampleSize(); }
[[nodiscard]] int getSampleSize() const { return (bitsPerSample / 8); }
};

/** Convert a time in seconds in frame counts, using the time base and duration in VideoStreamSettings */
Expand Down

0 comments on commit 641c1ce

Please sign in to comment.