Skip to content

Commit

Permalink
fix TestUtils bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
madronalabs committed Mar 16, 2024
1 parent 73dd1ab commit 17c8fe2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
5 changes: 5 additions & 0 deletions Tests/dspOpsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,11 @@ TEST_CASE("madronalib/core/projections", "[projections]")
REQUIRE(nearlyEqual(p0(p1(x)), x));
}
}

// print interval
Interval v1{0.123, 5.567};

std::cout << "interval: " << v1 << "\n";
}

TEST_CASE("madronalib/core/sse-ops", "[sse-ops]") {
Expand Down
2 changes: 1 addition & 1 deletion source/DSP/MLDSPProjections.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ inline void printTable(const Projection& p, std::string pName, Interval domain,

inline std::ostream& operator<<(std::ostream& out, const ml::Interval& m)
{
std::cout << "[" << m.mX1 << "" << m.mX2 << "]";
std::cout << "[" << m.mX1 << " - " << m.mX2 << "]";
return out;
}

Expand Down
3 changes: 3 additions & 0 deletions source/DSP/MLDSPSample.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ inline size_t getSize(const Sample& s)

inline size_t getFrames(const Sample& s)
{
if (s.channels == 0) return 0;
return s.sampleData.size() / s.channels;
}

Expand All @@ -56,6 +57,7 @@ inline float getRate(const Sample& s)

inline float getDuration(const Sample& s)
{
if (s.sampleRate == 0) return 0.f;
return getFrames(s) / (float)(s.sampleRate);
}

Expand Down Expand Up @@ -87,6 +89,7 @@ inline float findMaximumValue(const Sample& x)

inline void normalize(Sample& x)
{
if (x.sampleData.size() == 0) return;
float ratio = 1.0f / findMaximumValue(x);
for (int i = 0; i < x.sampleData.size(); ++i)
{
Expand Down
4 changes: 2 additions & 2 deletions source/app/MLTextUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ TextFragment getExtension(const TextFragment& frag)
size_t len = frag.lengthInCodePoints();
return subText(frag, dotLoc + 1, len);
}
return frag;
return TextFragment();
}


Expand All @@ -566,7 +566,7 @@ TextFragment getPath(const TextFragment& frag)
{
return subText(frag, 0, slashLoc);
}
return frag;
return TextFragment();
}

// TODO extend to recognize Cyrillic and other scripts
Expand Down

0 comments on commit 17c8fe2

Please sign in to comment.