Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > irrKlang
Playing byte array

goldengel
Guest
Quote
2012-06-25 19:58:36

Hi

I've tried to play my bytearray by using irrklang. But it does not play anything. Can you help me to get any noises out of the speakers?

   Dim _AudioDevice As New irrklang.ISoundEngine(irrklang.SoundOutputDriver.AutoDetect, irrklang.SoundEngineOptionFlag.DefaultOptions)


Dim Src As irrklang.ISoundSource
Dim Format As New irrklang.AudioFormat()
Format.ChannelCount = 1
Format.Format = irrklang.SampleFormat.Unsigned8Bit
Format.SampleRate = 4000
Dim Bo As Boolean
Dim newD As New List(Of Byte)
For i As Integer = 0 To Data.Length * 100 - 1
If Bo = True Then
newD.Add(255)
Else
newD.Add(0)
End If
Bo = Not Bo
Next
Format.FrameCount = newD.Count
_AudioDevice.SoundVolume = 1

Src = _AudioDevice.AddSoundSourceFromPCMData(newD.ToArray, Now.Ticks.ToString, Format)



niko
Moderator
Quote
2012-06-25 20:37:15

Hm, that code only adds the sound source, you are not actually playing it. Maybe that's the problem?


goldengel
Guest
Quote
2012-06-26 08:18:59

Hm, that code only adds the sound source, you are not actually playing it. Maybe that's the problem?


What a pitty. Yes that was the problem!

new:
        Dim SoundName As String = "Mem"
Src = _AudioDevice.AddSoundSourceFromPCMData(newD.ToArray, SoundName, Format)
_AudioDevice.Play2D(SoundName, False)



goldengel
Guest
Quote
2012-06-26 08:19:43

Thanks Niko for your quick help!!



goldengel
Registered User
Quote
2012-06-27 10:06:11

irrklang does not work because after using the code above I receive an error message after random calls and time:

Attempted to read or write protected memory. This is often an indication that other memory is corrupt.


VisualStudio breaks on line:
 _AudioDevice.Play2D("MEM2", False)


The code is the one above. Content of Data should not be important. But Byte array length goes from 30 to 5000.

But the device does call the _AudioDevice.Play2D methode several times (also possible parallel) with different Tag names to play.

Any advice?


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Int?rnational" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact