emdee_0.2.1_514ac5e1/src/midi_files.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
--  SPDX-License-Identifier: GPL-3.0-or-later
--  SPDX-FileCopyrightText: Copyright 2024 Stephen Merrony

with Ada.Directories;
with Ada.Sequential_IO;

with Interfaces;

with Embedded;       use Embedded;

package body Midi_Files is

   procedure Create_Notes_Off_MIDI is
      package IO is new Ada.Sequential_IO (Interfaces.Unsigned_8);
      File_Emb       : constant Content_Type := Get_Content (Notes_Off_Embedded);
      MIDI_Filename  : constant String := Notes_Off_Embedded;
      MIDI_File      : IO.File_Type;
   begin
      if Ada.Directories.Exists (MIDI_Filename) then
         Ada.Directories.Delete_File (MIDI_Filename);
      end if;
      IO.Create (File => MIDI_File, Name => MIDI_Filename);
      for Val of File_Emb.Content.all loop
         IO.Write (MIDI_File, Interfaces.Unsigned_8 (Val));
      end loop;
      IO.Close (MIDI_File);
   end Create_Notes_Off_MIDI;

end Midi_Files;