-- computerman is multiway user tools.
-- Computerman is Copyright (C) 2024 Manuel De Girardi ; 
--
--   This program is free software; you can redistribute it and/or modify
--   it under the terms of the GNU General Public License as published by
--   the Free Software Foundation; either version 2 of the License, or
--   (at your option) any later version.
--
--   This program is distributed in the hope that it will be useful,
--   but WITHOUT ANY WARRANTY; without even the implied warranty of
--   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
--   GNU General Public License for more details.
--
--   You should have received a copy of the GNU General Public License
--   along with this program; if not, write to the Free Software
--   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
--
-- Date := "2024-05-10 09:03:04"
-- Version := "0.0.0r"
with System;

with Computer.MIDI.Portmidi;             use Computer.MIDI.Portmidi;

with Interfaces.C;
use Interfaces;

package Computer.Midi.Devices is
   pragma Elaborate_Body(Computer.MIDI.Devices);
   
   type Mode_Type is (MIDI_In, MIDI_Out);
   -- Le mode de dentrée/sortie
   
   type Device_Type is
      record
         Initialized    : Boolean := False;
         Mode           : Mode_Type;
         Id             : Integer := -1;
         Addr           : access System.Address;
         The_Deviceinfo : access Portmidi.DeviceInfo;
      end record;   
   -- Le type Device_type.   

   
   type Device_Access is access Device_Type;
      
   procedure Initialize (Device : in out Device_Type; Mode : in Mode_Type);
   -- Initialise un périphérique MIDI
   
   function  Initialized(Device : in     Device_Type) return Boolean;
   -- Renvoie vrai si le périphérique est initialisé.   
   
   procedure Open       (Device : in out Device_Type);
   -- Ouvre un périphérique selon le mode d'entrée sortie du périphérique.
   
   procedure Write      (Device : in     Device_Type; Message : in C.Long);
   -- Ecrit un message court à detisnation du périphérique de sortie.
   
   procedure Read       (Device : in     Device_Type; Message : out C.Long);
   -- Lit un message en provenance du périphérique d'entrée.
   
   procedure Close      (Device : in out Device_Type);
   -- Ferme un périphérique.
   
   function Name(Device : in Device_Type) return String;
   -- Renvoie le nom du périphérique.
   
   Not_Initialized : exception;
   -- Sera levée si l'on tente d'ouvrir un périphérique non initilaisé.
   
   Mode_Error      : exception;
   -- Sera levée si l'on tente d'écrire sur un périphérique d'entrée ou
   -- si l'on tente de lire sur un périphérique de sortie.               

end Computer.Midi.Devices ;