audio_wavefiles_2.0.0_8e1162c5/src/audio-wavefiles-report.adb

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
------------------------------------------------------------------------------
--                                                                          --
--                               WAVEFILES                                  --
--                                                                          --
--                       Wavefile reporting routines                        --
--                                                                          --
--  The MIT License (MIT)                                                   --
--                                                                          --
--  Copyright (c) 2015 -- 2020 Gustavo A. Hoffmann                          --
--                                                                          --
--  Permission is hereby granted, free of charge, to any person obtaining   --
--  a copy of this software and associated documentation files (the         --
--  "Software"), to deal in the Software without restriction, including     --
--  without limitation the rights to use, copy, modify, merge, publish,     --
--  distribute, sublicense, and / or sell copies of the Software, and to    --
--  permit persons to whom the Software is furnished to do so, subject to   --
--  the following conditions:                                               --
--                                                                          --
--  The above copyright notice and this permission notice shall be          --
--  included in all copies or substantial portions of the Software.         --
--                                                                          --
--  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,         --
--  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF      --
--  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  --
--  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY    --
--  CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,    --
--  TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE       --
--  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                  --
------------------------------------------------------------------------------

with Ada.Text_IO;                    use Ada.Text_IO;

with Audio.RIFF.Wav.Formats.Report;

package body Audio.Wavefiles.Report is

   function To_String (Err : Wavefile_Error_Code) return String;

   function To_String (Err : Wavefile_Warning_Code) return String;

   ------------------
   -- Display_Info --
   ------------------

   procedure Display_Info (WF : Wavefile) is
   begin
      Audio.RIFF.Wav.Formats.Report.Print (WF.Wave_Format);
   end Display_Info;

   ------------------
   -- Display_Info --
   ------------------

   procedure Display_Info (RIFF_Info : RIFF_Information) is
   begin
      Put_Line ("---- RIFF Chunks Information ----");
      Put_Line ("Id:          " & RIFF_Identifier'Image (RIFF_Info.Id));
      Put_Line ("Format:      " & RIFF_Format'Image (RIFF_Info.Format));
      Put_Line ("Chunk count: "
                & Ada.Containers.Count_Type'Image (RIFF_Info.Chunks.Length));
      New_Line;

      for Chunk_Element of RIFF_Info.Chunks loop
         Put_Line ("- ID:           "
                   & Chunk_Element.ID);
         Put_Line ("  Internal tag: "
                   & Wav_Chunk_Tag'Image (Chunk_Element.Chunk_Tag));
         Put_Line ("  Size:         "
                   & Long_Integer'Image (Chunk_Element.Size));
         Put_Line ("  Start index:  "
                   & Ada.Streams.Stream_IO.Positive_Count'Image
                     (Chunk_Element.Start_Index));
         Put_Line ("  Consolidated: "
                   & Boolean'Image (Chunk_Element.Consolidated));
         New_Line;
      end loop;
      Put_Line ("---------------------------------");

   end Display_Info;

   ---------------
   -- To_String --
   ---------------

   function To_String (Err : Wavefile_Error_Code) return String is
   begin
      case Err is
      when Wavefile_Error_File_Not_Open =>
         return "File not open";
      when Wavefile_Error_File_Already_Open =>
         return "File already open";
      when Wavefile_Error_File_Too_Short =>
         return "File too short";
      when Wavefile_Error_Format_Chuck_Not_Found =>
         return "Format chunk not found";
      when Wavefile_Error_Data_Chuck_Not_Found =>
         return "Data chunk not found";
      when Wavefile_Error_Unsupported_Wavefile_Format =>
         return "Unsupported wavefile format";
      when Wavefile_Error_Unsupported_Bit_Depth =>
         return "Unsupported bit depth";
      when Wavefile_Error_Unsupported_Format_Size =>
         return "Unsupported format size";
      end case;
   end To_String;

   ---------------
   -- To_String --
   ---------------

   function To_String (Err : Wavefile_Warning_Code) return String is
   begin
      case Err is
      when Wavefile_Warning_Inconsistent_Channel_Mask =>
         return "Inconsistent channel mask";
      end case;
   end To_String;

   --------------------
   -- Display_Errors --
   --------------------

   procedure Display_Errors (WF : Wavefile) is
   begin
      Put_Line ("---------------- Wavefile errors ----------------");
      New_Line;

      for Error_Code in WF.Errors'Range loop
         if WF.Errors (Error_Code) then
            Put_Line ("- " & To_String (Error_Code));
         end if;
      end loop;

      New_Line;
      Put_Line ("-------------------------------------------------");
   end Display_Errors;

   ----------------------
   -- Display_Warnings --
   ----------------------

   procedure Display_Warnings (WF : Wavefile) is
   begin
      Put_Line ("-------------- Wavefile warnings ----------------");
      New_Line;

      for Warning_Code in WF.Warnings'Range loop
         if WF.Warnings (Warning_Code) then
            Put_Line ("- " & To_String (Warning_Code));
         end if;
      end loop;

      New_Line;
      Put_Line ("-------------------------------------------------");
   end Display_Warnings;

end Audio.Wavefiles.Report;