I tried without any Debug, I you were right, the speed rise up. But it's still to low compare to a normal play.
I use both of your sdcard class and vs1053 class, so I suppose I have the same than you...

  | ||||||||||||||
The Netduino forums have been replaced by new forums at community.wildernesslabs.co.
This site has been preserved for archival purposes only
and the ability to make new accounts or posts has been turned off.
Community Stats
0
Neutral
User ToolsFriendstuff hasn't added any friends yet. Latest VisitorsNo latest visitors to show Posts I've MadeIn Topic: VS1053 breakout board18 October 2013 - 05:05 PM I tried without any Debug, I you were right, the speed rise up. But it's still to low compare to a normal play. I use both of your sdcard class and vs1053 class, so I suppose I have the same than you... In Topic: VS1053 breakout board17 October 2013 - 02:23 PM I send order to my netduino card over network by my windows phone with an app I made. This app send to the netduino the song's name to play, On the netduino there is a socket server witch process the phone request and then send byte data to the vs1053. With hanzibal's code, on the first song, i get this output : RATE=8000 Hz (mono) The music speed is really slow. And when I send a second order with another song : RATE=44100 Hz (stereo) But nothing is play...
I think i should have RATE=44100 Hz (stereo) at the first song to ear a clean sound, isn't it ? In Topic: VS1053 breakout board15 October 2013 - 02:25 PM Ok so the error that I got come from a bad SPI configuration in my code. But I have an other problem now. I can play a file on my sd card but the play rate is really too low, it's like a "slow-motion" but for a song (RATE = 8000 Hz display in the visual output)
How can I speed it up ? (I'm sorry I don't understand perfectly your playstream function hanzibal ^^") In Topic: VS1053 breakout board14 October 2013 - 09:58 AM After some research, I found this in the vs1053 doc :
I also found code example witch wait for the dreq pin goes to true : private void CommandWrite(byte register, ushort data) { while (_dreq.Read() == false) { Debug.Print("- CommandWrite / _dreq : " + _dreq.Read().ToString()); } _spi.Config = CmdConfig; cmdBuffer[0] = CMD_WRITE; cmdBuffer[1] = register; cmdBuffer[2] = (byte)(data >> 8); cmdBuffer[3] = (byte)data; _spi.Write(cmdBuffer); } The result out put I get is : - CommandWrite / _dreq : FALSSE
And that's all, the code is block in the while loop...
The board is supposed to change the state of the dreq pin by herself, right ? In Topic: VS1053 breakout board13 October 2013 - 12:17 PM I finally end up with this resources :
the second one is a c# implementation of the third resources. So i tried to use it but I don't succeed to read any data from the board... This is my code : using System;using System.IO;using Microsoft.SPOT.Hardware;using SecretLabs.NETMF.Hardware.Netduino;using System.Threading;using System.Diagnostics;using Microsoft.SPOT;namespace NetduinoApplication2{ public class VS1053 { // GPIO ports: private OutputPort _reset; private InterruptPort _dreq; private Cpu.Pin PinBsync = Pins.GPIO_PIN_D2; private Cpu.Pin PinDreq = Pins.GPIO_PIN_D3; private Cpu.Pin PinReset = Pins.GPIO_PIN_D6; // NOTE: This doesn't map to an actual pin private Cpu.Pin PinCs = Pins.GPIO_PIN_D9; // Define SPI Configuration for VS1053 MP3 decoder: private SPI.Configuration DataConfig; private SPI.Configuration CmdConfig; private SPI _spi; // Registers: private byte RegisterSciMode = 0x00; private byte RegisterSciVol = 0x0B; private byte RegisterSciClockf = 0x03; public static readonly int BufferSize = 96; private ushort SciMode = 0x880; // SM_SDINEW (default) + SM_EARSPEAKER_HI private bool _isInitialized; private readonly byte[] ReadBuffer = new byte[BufferSize]; private readonly byte[] CmdBuffer = new byte[4]; private readonly AutoResetEvent AutoResetEvent = new AutoResetEvent(false); public void Initialize() { DataConfig = new SPI.Configuration(PinBsync, false, 0, 0, false, true, 3000, SPI.SPI_module.SPI1); CmdConfig = new SPI.Configuration(PinCs, false, 0, 0, false, true, 3000, SPI.SPI_module.SPI1); Debug.Print("--- _isInitialized : " + _isInitialized.ToString()); if (_isInitialized) { Debug.Print("Shutdown !"); Shutdown(); } _spi = new SPI(CmdConfig); _reset = new OutputPort(PinReset, true); _dreq = new InterruptPort(PinDreq, false, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeBoth); _dreq.OnInterrupt += _dreq_OnInterrupt; _isInitialized = true; Reset(); var test = SciMode | (1 << 2); var test2 = (ushort)test; Debug.Print("--- set : " + test2.ToString("x") + " : " + test2.GetType()); CommandWrite(RegisterSciMode, test2); var result = CommandRead(RegisterSciMode); Debug.Print("--- read :"); foreach (byte b in result) { Debug.Print(b.ToString("x")); } //CommandWrite(RegisterSciClockf, 7 << 13); //CommandWrite(RegisterSciVol, 0x2424); //_spi.Config = DataConfig; } private void _dreq_OnInterrupt(uint port, uint state, DateTime time) { if (state == 0) { AutoResetEvent.Set(); } else { AutoResetEvent.WaitOne(); } _dreq.ClearInterrupt(); } private void Reset() { Debug.Print("--- Start reset ---"); _reset.Write(false); Thread.Sleep(1); _reset.Write(true); Thread.Sleep(1); Debug.Print("--- Finish reset ---"); } private void CommandWrite(byte address, ushort data) { CmdBuffer[0] = 0x02; CmdBuffer[1] = address; CmdBuffer[2] = (byte)(data >> 8); CmdBuffer[3] = (byte)data; _spi.Write(CmdBuffer); } private byte[] CommandRead(byte address) { var buffer = new byte[4]; CmdBuffer[0] = 0x03; CmdBuffer[1] = address; CmdBuffer[2] = 0; CmdBuffer[3] = 0; _spi.WriteRead(CmdBuffer, buffer, 0); //ushort command = CmdBuffer[0]; //command <<= 8; //command += CmdBuffer[1]; return buffer; } public void SetVolumePercent(int volume) { if (volume < 0 || volume > 100) throw new ArgumentOutOfRangeException("volume"); SetVolumePercent(volume, volume); } public void SetVolumePercent(int leftChannel, int rightChannel) { if (leftChannel < 0 || leftChannel > 100) throw new ArgumentOutOfRangeException("leftChannel"); if (rightChannel < 0 || rightChannel > 100) throw new ArgumentOutOfRangeException("rightChannel"); // TODO: Invert decibel value, divide by percent, call SetVolume(ushort leftChannel, ushort rightChannel) } public void SetVolume(ushort bothChannels) { CommandWrite(RegisterSciVol, bothChannels); // TODO: This doesn't work outside the Initialize() method } public void SetVolume(ushort leftChannel, ushort rightChannel) { SetVolume((ushort) (leftChannel*256 + rightChannel)); // TODO: Verify no loss of fidelity } public void SendData(FileStream fileStream) { var size = fileStream.Length - fileStream.Length % BufferSize; for (var i = 0; i < size; i += BufferSize) { fileStream.Read(ReadBuffer, 0, BufferSize); _spi.Write(ReadBuffer); } } private void Shutdown() { if (!_isInitialized) return; Reset(); _spi.Dispose(); _reset.Dispose(); _dreq.Dispose(); _isInitialized = false; } }} using System;using System.Net;using System.Net.Sockets;using System.Threading;using Microsoft.SPOT;using Microsoft.SPOT.Hardware;using SecretLabs.NETMF.Hardware;using SecretLabs.NETMF.Hardware.Netduino;namespace NetduinoApplication2{ public class Program { public static void Main() { VS1053 vs = new VS1053(); vs.Initialize(); //vs.SetVolume(0xFEFE); } }} And this is this output I got : --- _isInitialized : False--- Start reset ------ Finish reset ------ set : 884 : System.UInt16--- read :00000000The thread '<No Name>' (0x1) has exited with code 0 (0x0).Done. I think I'm supposed to receive the exact same byte array that I send with CommandWrite, but I just receive 0... Any Idea ?
| ||||||||||||||
|
||||||||||||||
This webpage is licensed under a Creative Commons Attribution-ShareAlike License. | ||||||||||||||