Skip to content

Commit

Permalink
Removed libfmt dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
stijnfrishert committed Dec 9, 2018
1 parent a1653b1 commit 85c4297
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 23 deletions.
3 changes: 1 addition & 2 deletions lsdj_wavetable_import/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ cmake_minimum_required(VERSION 3.0.0)

set(Boost_USE_STATIC_LIBS ON)
find_package(Boost REQUIRED COMPONENTS filesystem program_options)
find_library(Fmt fmt)

# Create the executable target
add_executable(lsdj-wavetable-import main.cpp ../common/common.hpp ../common/common.cpp)
source_group(\\ FILES main.cpp ../common/common.hpp ../common/common.cpp)

target_compile_features(lsdj-wavetable-import PUBLIC cxx_std_14)
target_include_directories(lsdj-wavetable-import PUBLIC ${Boost_INCLUDE_DIRS})
target_link_libraries(lsdj-wavetable-import liblsdj ${Boost_LIBRARIES} ${Fmt})
target_link_libraries(lsdj-wavetable-import liblsdj ${Boost_LIBRARIES})

install(TARGETS lsdj-wavetable-import DESTINATION bin)
28 changes: 7 additions & 21 deletions lsdj_wavetable_import/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@
#include <boost/filesystem.hpp>
#include <boost/program_options.hpp>

#include <fmt/format.h>

#include "../common/common.hpp"
#include "../liblsdj/project.h"

Expand Down Expand Up @@ -106,15 +104,15 @@ int apply(const std::string& projectName, const std::string& outputName, const s
// Compute the amount of frames we will write
const auto frameCount = wavetableSize / 16;
if (verbose)
fmt::print("Found {} frames in {}\n", frameCount, wavetablePath.string());
std::cout << "Found " << std::dec << frameCount << " frames in " << wavetablePath.string() << std::endl;

const auto actualFrameCount = std::min<unsigned int>(0x100 - wavetableIndex, frameCount);
if (frameCount != actualFrameCount)
{
fmt::print("Last {} frames won't fit in the song\n", frameCount - actualFrameCount);
std::cout << "Last " << std::dec << (frameCount - actualFrameCount) << " won't fit in the song" << std::endl;

if (verbose)
fmt::print("Writing only {} frames due to space limits\n", actualFrameCount);
std::cout << "Writing only " << std::dec << actualFrameCount << " frames due to space limits" << std::endl;
}

// Check to see if we're overwriting non-default wavetables
Expand All @@ -139,7 +137,7 @@ int apply(const std::string& projectName, const std::string& outputName, const s
break;
}
} else if (verbose) {
fmt::print("Frame 0x{0:02X} is default\n", wavetableIndex + frame);
std::cout << "Frame 0x" << std::hex << (wavetableIndex + frame) << " is default" << std::endl;
}
}
}
Expand All @@ -151,13 +149,7 @@ int apply(const std::string& projectName, const std::string& outputName, const s
wavetableStream.read(reinterpret_cast<char*>(wave->data), sizeof(wave->data));

if (verbose)
{
fmt::print("Wrote {} bytes to frame 0x{:02X} (", sizeof(wave->data), wavetableIndex + frame);

for (auto i = 0; i < sizeof(wave->data); i++)
fmt::print("{:02X}", wave->data[i]);
std::cout << ")" << std::endl;
}
std::cout << "Wrote " << std::dec << sizeof(wave->data) << " bytes to frame 0x" << std::hex << (wavetableIndex + frame) << std::endl;
}

// Write zero wavetables
Expand All @@ -175,13 +167,7 @@ int apply(const std::string& projectName, const std::string& outputName, const s
memcpy(wave->data, table.data(), sizeof(table));

if (verbose)
{
fmt::print("Wrote {} bytes to frame 0x{:02X} (", sizeof(wave->data), wavetableIndex + frame);

for (auto i = 0; i < sizeof(wave->data); i++)
fmt::print("{:02X}", wave->data[i]);
std::cout << ")" << std::endl;
}
std::cout << "Wrote default bytes to frame 0x" << std::hex << (wavetableIndex + frame) << std::endl;
}
}

Expand All @@ -194,7 +180,7 @@ int apply(const std::string& projectName, const std::string& outputName, const s
return 1;
}

fmt::print("Wrote {} frames starting at 0x{:02X} to {}\n", actualFrameCount, wavetableIndex, outputPath.filename().string());
std::cout << "Wrote " << std::dec << actualFrameCount << " frames starting at 0x" << std::hex << wavetableIndex << " to " << outputPath.string() << std::endl;

return 0;
}
Expand Down

0 comments on commit 85c4297

Please sign in to comment.