Click or drag to resize
SpeechEncoderStreamType Property
Gets or sets or Sets the StreamType property.

Namespace: StreamCoders.Encoder
Assembly: MediaSuite (in MediaSuite.dll) Version: 2.0.5.0 (2.0.5.0)
Syntax
public SpeechStreamType StreamType { get; set; }

Property Value

Type: SpeechStreamType
This is currently only used for AMR-NB, to distinguish between raw and file storage format stream.
Examples
    StreamCoders.Codec codec = StreamCoders.Codec.AMRNB;
    int samplerate = 8000;
    int bitrate = 10200;

    // Open default wavein
    WaveInput win = new WaveInput();
    win.BitsPerSample = 16;
    win.Channels = 1;
    win.SampleRate = samplerate;
    win.OpenDevice(null);
    win.Start();

    // Create G.711 alaw encoder
    SpeechEncoder enc = new SpeechEncoder();
    enc.InputBitsPerSample = 16;
    enc.InputChannels = 1;
    enc.InputSampleRate = samplerate;
    enc.SetCodec(codec);
    enc.OutputBitrate = bitrate;
    enc.PacketDuration = 20;
    enc.StreamType = StreamCoders.SpeechStreamType.StorageFormat;
    bool res = enc.Init();
    if(res == false)
    {
        return;
    }

    // Create G.711 alaw decoder
    SpeechDecoder dec = new SpeechDecoder();
    dec.Bitrate = bitrate;
    dec.StreamType = StreamCoders.SpeechStreamType.StorageFormat;
    dec.SetCodec(codec);
    res = dec.Init();
    if (res == false)
    {
        return;
    }

    // Open default waveout
    WaveOutput wout = new WaveOutput();
    wout.Channels = 1;
    wout.SampleRate = samplerate;
    wout.BitsPerSample = 16;
    wout.Init();
    wout.OpenDevice(null);

    int bytescollected = 0;
    win.ClearBuffers();
    while (true)
    {
        // is data available from device
        if (win.SamplesAvailable == true)
        {
            // get all queued data
            byte[] samples = win.GetAllData();
            bytescollected += samples.Length;
            // encode data to g.711 byte stream
            byte[] g711bytes = enc.EncodeToBuffer(samples);
            if (g711bytes != null)
            {
                // decode byte stream
                byte[] raw = dec.Decode(g711bytes);
                // output to sound device and enjoy the echo
                wout.Enqueue(raw);
            }
        }
    }

}
See Also