Welcome to Synthiam!

The easiest way to program the most powerful robots. Use technologies by leading industry experts. ARC is a free-to-use robot programming software that makes servo automation, computer vision, autonomous navigation, and artificial intelligence easy.

Get Started
Israel
Asked

Question

Hello,
I'm trying to play an audio (I'm coding in C# SDK) 

I converted .mp3 to raw by audio conversion software, and when i play the .raw on audacity is sounds pretty fine

I tried to use _ezb.SoundV4.PlayData function like this:

byte[] bytes = File.ReadAllBytes("../path");

_ezb.SoundV4.PlayData(bytes,100);

 but the audio sounds really bad

when i try to play the .mp3 in EZbuilder it sounds better. 

any ideas?
thank you!




ARC Pro

Upgrade to ARC Pro

Unleash your creativity with the power of easy robot programming using Synthiam ARC Pro

AI Support Bot
Related Content
Synthiam
PRO
Synthiam
#1   — Edited
Must save PCM as MONO 8 BIT and 14700 hz

I recommend loading and playing the file in real-time like this... Here's how the soundboard loads and plays the file. I compress the file so it can be stored in a much smaller memory footprint

Code:


if (openFileDialog1.FileName.ToLower().Contains(".mp3")) {

  using (NAudio.Wave.Mp3FileReader mp3 = new NAudio.Wave.Mp3FileReader(openFileDialog1.FileName)) {

    using (NAudio.Wave.WaveFormatConversionStream pcm = new NAudio.Wave.WaveFormatConversionStream(new NAudio.Wave.WaveFormat(EZ_B.EZBv4Sound.AUDIO_SAMPLE_BITRATE, 8, 1), mp3)) {

      using (MemoryStream ms = new MemoryStream()) {

        using (GZipStream gz = new GZipStream(ms, CompressionMode.Compress))
          pcm.CopyTo(gz);

        _compressedAudioArray = ms.ToArray();
      }
    }
  }
} else if (openFileDialog1.FileName.ToLower().Contains(".wav")) {

  using (NAudio.Wave.WaveStream wav = new NAudio.Wave.WaveFileReader(openFileDialog1.FileName)) {

    using (NAudio.Wave.WaveFormatConversionStream pcm = new NAudio.Wave.WaveFormatConversionStream(new NAudio.Wave.WaveFormat(EZ_B.EZBv4Sound.AUDIO_SAMPLE_BITRATE, 8, 1), wav)) {

      using (MemoryStream ms = new MemoryStream()) {

        using (GZipStream gz = new GZipStream(ms, CompressionMode.Compress))
          pcm.CopyTo(gz);

        _compressedAudioArray = ms.ToArray();
      }
    }
  }
} else {

  throw new Exception("Unsupported audio file type.");
}



Playback like this... 

Code:


using (MemoryStream ms = new MemoryStream(_compressedAudioArray))
using (GZipStream gz = new GZipStream(ms, CompressionMode.Decompress))
  EZBManager.EZBs[_cf.SoundBoardv4.EZBIndex].SoundV4.PlayData(gz, 100);
Israel
#2  
It worked! Thank you very much!