
with text_io; use text_io;
with sysutils;
with Interfaces.C; use Interfaces.C;
with Interfaces.C.Strings; use Interfaces.C.Strings;

package body snd4ada_hpp is


	subtype namerng is integer range 1..80;
	type nametype is new string(namerng);

	maxbuf : constant int := 50;
	subtype bufrng is int range 0..maxbuf;
	tbuf: bufrng := 0;

	buf : array(bufrng) of nametype;
	len : array(bufrng) of namerng;

   procedure termSnds is
	begin
		null;
	end termSnds;

   procedure initSnds is
	begin
		null;
	end initSnds;

   function initSnd (pc : Interfaces.C.Strings.chars_ptr; vol : int) return int is
		lt: constant size_t := Strlen(pc);
		ln: constant namerng := namerng(lt);
	begin


		tbuf:=tbuf+1;

		for i in 1..ln loop
			buf(tbuf)(i) := value(pc)(i);
		end loop;

		len(tbuf):=ln;
		return tbuf;

	end initSnd;

   procedure playSnd (nbuf : int) is
		ln: constant namerng := len(nbuf);
		name: constant string := string( buf(nbuf) );
		ocmd : constant string := "afplay "&name(1..ln);
		Ok: boolean;
	begin
		sysutils.Shell( ocmd, Ok );
	end playSnd;

end snd4ada_hpp;
