summaryrefslogtreecommitdiff
path: root/example/file_info_example.adb
diff options
context:
space:
mode:
authorJedidiah Barber <contact@jedbarber.id.au>2023-07-02 21:36:34 +1200
committerJedidiah Barber <contact@jedbarber.id.au>2023-07-02 21:36:34 +1200
commit049d2a9a337331295b4a2d4ad13061bc73536236 (patch)
treec360b2ce05f91d070c14dad7a3691c1435df7df7 /example/file_info_example.adb
Initial commit
Diffstat (limited to 'example/file_info_example.adb')
-rw-r--r--example/file_info_example.adb70
1 files changed, 70 insertions, 0 deletions
diff --git a/example/file_info_example.adb b/example/file_info_example.adb
new file mode 100644
index 0000000..3971163
--- /dev/null
+++ b/example/file_info_example.adb
@@ -0,0 +1,70 @@
+
+
+-- Programmed by Jedidiah Barber
+-- Released into the public domain
+
+-- This program opens the file supplied as a command line argument, outputs the
+-- file info from it, then closes the file. No modifications are made.
+
+
+with
+
+ Ada.Command_Line,
+ Ada.Directories,
+ Ada.Text_IO,
+ Libsndfile;
+
+
+procedure File_Info_Example is
+
+
+ package ACom renames Ada.Command_Line;
+ package ADir renames Ada.Directories;
+ package TIO renames Ada.Text_IO;
+
+
+ My_Info : Libsndfile.File_Info := Libsndfile.Blank_Info;
+ My_Sound_File : Libsndfile.Sound_File;
+
+
+begin
+
+
+ if ACom.Argument_Count < 1 then
+ TIO.Put_Line ("No filename provided");
+ ACom.Set_Exit_Status (ACom.Failure);
+ return;
+ end if;
+
+ if not ADir.Exists (ACom.Argument (1)) then
+ TIO.Put_Line ("File does not exist");
+ ACom.Set_Exit_Status (ACom.Failure);
+ return;
+ end if;
+
+
+ TIO.Put_Line ("Load file " & ACom.Argument (1));
+ My_Sound_File.Open (ACom.Argument (1), Libsndfile.Read_Only, My_Info);
+ TIO.New_Line;
+
+ TIO.Put_Line ("Open frame count:" &
+ Libsndfile.Count_Type'Image (Libsndfile.Frames (My_Info)));
+ TIO.Put_Line ("Open sample rate:" & Natural'Image (Libsndfile.Rate (My_Info)));
+ TIO.Put_Line ("Open channel count:" & Natural'Image (Libsndfile.Channels (My_Info)));
+ TIO.Put_Line ("Open major format: " &
+ Libsndfile.Major_Format'Image (Libsndfile.Major (My_Info)));
+ TIO.Put_Line ("Open minor format: " &
+ Libsndfile.Minor_Format'Image (Libsndfile.Minor (My_Info)));
+ TIO.Put_Line ("Open endianness: " &
+ Libsndfile.Endianness'Image (Libsndfile.Endian (My_Info)));
+ TIO.Put_Line ("Open section count:" & Natural'Image (Libsndfile.Sections (My_Info)));
+ TIO.Put_Line ("Open seekable: " & Boolean'Image (Libsndfile.Seekable (My_Info)));
+
+ TIO.New_Line;
+ My_Sound_File.Close;
+ TIO.Put_Line ("File closed");
+
+
+end File_Info_Example;
+
+