/* * A simple example showing how to stream a file through a source. */ #include #include #include #include #include #include #include "alure2.h" namespace { // Helper class+method to print the time with human-readable formatting. struct PrettyTime { alure::Seconds mTime; }; inline std::ostream &operator<<(std::ostream &os, const PrettyTime &rhs) { using hours = std::chrono::hours; using minutes = std::chrono::minutes; using seconds = std::chrono::seconds; using centiseconds = std::chrono::duration>; using std::chrono::duration_cast; centiseconds t = duration_cast(rhs.mTime); if(t.count() < 0) { os << '-'; t *= -1; } // Only handle up to hour formatting if(t >= hours(1)) os << duration_cast(t).count() << 'h' << std::setfill('0') << std::setw(2) << duration_cast(t).count() << 'm'; else os << duration_cast(t).count() << 'm' << std::setfill('0'); os << std::setw(2) << (duration_cast(t).count() % 60) << '.' << std::setw(2) << (t.count() % 100) << 's' << std::setw(0) << std::setfill(' '); return os; } } // namespace int main(int argc, char *argv[]) { alure::ArrayView args(argv, argc); if(args.size() < 2) { std::cerr<< "Usage: "< 2 && args[0] == alure::StringView("-device")) { dev = devMgr.openPlayback(args[1], std::nothrow); if(!dev) std::cerr<< "Failed to open \""< decoder = ctx.createDecoder(args.front()); alure::Source source = ctx.createSource(); source.play(decoder, 12000, 4); std::cout<< "Playing "<getSampleType())<<", " << alure::GetChannelConfigName(decoder->getChannelConfig())<<", " << decoder->getFrequency()<<"hz)" <getFrequency(); while(source.isPlaying()) { std::cout<< "\r "<getLength()*invfreq)}; std::cout.flush(); std::this_thread::sleep_for(std::chrono::milliseconds(25)); ctx.update(); } std::cout<