Return to LanScape's home page Go back a page...       Active TopicsActive Topics   Display List of Forum MembersMember List   Knowledge Base SearchSearch   HelpHelp  RegisterRegister  LoginLogin

LanScape VOIP Media Engine™ - Pre-Sales Technical Support
 LanScape Support Forum -> LanScape VOIP Media Engine™ - Pre-Sales Technical Support
Subject Topic: Reading wave file in managed code Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
Geoff Day
Intermediate
Intermediate


Joined: November 19 2009
Posts: 9
Posted: December 30 2009 at 5:17pm | IP Logged Quote Geoff Day

When reading a wave file in managed code I tried this (as
part of a larger function of course where I had
previously created the 'wave' object and opened a file):

byte[] buffer = new byte[bytes_per_buffer];
wave.GetWaveBuffer(buffer);

but it wouldn't compile with the error "cannot convert
byte[] to object[]". What is the recommended way to do
this in managed code?

Thanks.
Back to Top View Geoff Day's Profile Search for other posts by Geoff Day
 
support
Administrator
Administrator


Joined: January 26 2005
Location: United States
Posts: 1666
Posted: December 31 2009 at 1:00pm | IP Logged Quote support

Hello Geoff,

Quick Note:
When reading wave files, the media engine supports wave file samples using aLaw, uLaw or PCM sample formats. So your wav files should be in one of these three supported formats.


The simplest way to remove the compiler error you have is to create your sample buffer as a generic C# Object array. Instead of using “byte” use “Object” such as:

Code:

    // create a new sample buffer.
    WaveSampleBuffer = new Object[SamplesPerBuffer];



Then pass this C# buffer to the “GetWaveBuffer()” proc like:

Code:

    // Read a single wave buffer block.
    WaveFile.GetWaveBuffer(WaveSampleBuffer)



After you call the GetWaveBuffer() proc, your generic Object buffer will take on the type cast of either byte or short depending on if your wav file contained aLaw/uLaw or PCM samples.


There is a common C# code module in the samples that come with the media engine. See the module VoipApplication.cs. This module contains a proc called MusicOnHoldThreadHandler(). In this proc, it calls the wave buffer read procs. Take a look at the code if you want, it will give you an example of how the VOIP code samples read wave buffers from files using C#.

I hope this helps…..


Thank you,

Randal

Back to Top View support's Profile Search for other posts by support Visit support's Homepage
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum






Contact LanScape Hear what the Lawyers have to say How youm may use this site Read your privacy rights