Exemplo n.º 1
0
        public EsdStream RecordStream(string name, EsdChannels channels,
						int rate, EsdBits bits)
        {
            EsdStream stream;
            int id, format;

            format = Format(bits, channels, EsdMode.Stream, EsdFunc.Record);
            id = esd_record_stream(format, rate, host, name);
            if (id < 0)
                throw new EsdException("Could not open record stream");

            return CreateStream(id, name, EsdFunc.Record);
        }
Exemplo n.º 2
0
        internal int Format(EsdBits bits, EsdChannels channels,
					EsdMode mode, EsdFunc func)
        {
            return (int) bits | (int) channels | (int) mode | (int) func;
        }
Exemplo n.º 3
0
        public EsdSample CacheSample(string name, Stream stream, EsdChannels channels,
						int rate, EsdBits bits)
        {
            byte[] buffer = new byte[BufferSize];
            int len, id, format;
            IntPtr ptr;
            EsdSample sample;

            format = (int) bits | (int) channels
                    | (int) EsdMode.Stream
                    | (int) EsdFunc.Play;

            id = esd_sample_cache(socket, format, rate,
                        (int) stream.Length, name);
            if (id < 0)
                throw new EsdCacheException("Could not cache sample", null);

            ptr = Marshal.AllocHGlobal(BufferSize);

            while ((len = stream.Read(buffer, 0, buffer.Length)) > 0)
            {
                Marshal.Copy(buffer, 0, ptr, len);
                write(socket, ptr, len);
            }

            Marshal.FreeHGlobal(ptr);

            if (id != esd_confirm_sample_cache(socket))
                throw new EsdCacheException("Could not cache sample", null);

            sample = new EsdSample(this);
            sample.id = id;
            sample.name = name;
            return sample;
        }