forked from SerenityOS/serenity
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LibAudio+aplay: Make the aplay output look a little funner.
Show some information about the file we're playing, and display how many samples we've played out of how many total. This might be a bit buggy as I haven't tested it with many different files, but it's a start. :^)
- Loading branch information
1 parent
b44d3fa
commit ae4a9e0
Showing
3 changed files
with
31 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,36 @@ | ||
#include <LibCore/CEventLoop.h> | ||
#include <LibAudio/AWavLoader.h> | ||
#include <LibAudio/AClientConnection.h> | ||
#include <LibAudio/ABuffer.h> | ||
#include <LibAudio/AClientConnection.h> | ||
#include <LibAudio/AWavLoader.h> | ||
#include <LibCore/CEventLoop.h> | ||
#include <cstdio> | ||
|
||
int main(int argc, char **argv) | ||
int main(int argc, char** argv) | ||
{ | ||
CEventLoop loop; | ||
if (argc < 2) { | ||
fprintf(stderr, "Need a WAV to play\n"); | ||
return 1; | ||
} | ||
|
||
printf("Establishing connection\n"); | ||
AClientConnection a_conn; | ||
a_conn.handshake(); | ||
printf("Established connection\n"); | ||
AWavLoader loader(argv[1]); | ||
printf("Loaded WAV\n"); | ||
|
||
printf("\033[34;1mPlaying\033[0m: %s\n", argv[1]); | ||
printf("\033[34;1m Format\033[0m: %u Hz, %u-bit, %s\n", | ||
loader.sample_rate(), | ||
loader.bits_per_sample(), | ||
loader.num_channels() == 1 ? "Mono" : "Stereo"); | ||
printf("\033[34;1m Sample\033[0m: \033[s"); | ||
for (;;) { | ||
auto samples = loader.get_more_samples(); | ||
if (!samples) { | ||
if (!samples) | ||
break; | ||
} | ||
printf("Playing %d sample(s)\n", samples->sample_count()); | ||
printf("\033[u"); | ||
printf("%d/%d", loader.loaded_samples(), loader.total_samples()); | ||
fflush(stdout); | ||
a_conn.enqueue(*samples); | ||
} | ||
|
||
printf("Exiting! :)\n"); | ||
printf("\n"); | ||
return 0; | ||
} |