From 049d2a9a337331295b4a2d4ad13061bc73536236 Mon Sep 17 00:00:00 2001 From: Jedidiah Barber Date: Sun, 2 Jul 2023 21:36:34 +1200 Subject: Initial commit --- example/file_info_example.adb | 70 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 example/file_info_example.adb (limited to 'example/file_info_example.adb') 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; + + -- cgit