Sequence file decod...
 
Notifications
Clear all

Sequence file decoding on Arduino

62 Posts
8 Users
0 Reactions
35.2 K Views
Posts: 180
Topic starter
(@jonpro03)
Estimable Member
Joined: 15 years ago
[#18910]

Time to start cracking away at this piece of the puzzle. Question number one is what sequence file to use? I understand that Vixen uses base64 encoding. I found a base64 decoding library for Arduino. Is this the best route to take? Is there another file format that should be used?


61 Replies
kychristmas
Posts: 3947
(@kychristmas)
Famed Member
Joined: 18 years ago

Maybe I missed something. Are you planning on using the controller to play Vixen Sequences? Like a standalone controller mode or are you just looking to have the Arduino recieve sequence data just like Renard-basd controllers do?

Jonpro03 wrote:Time to start cracking away at this piece of the puzzle. Question number one is what sequence file to use? I understand that Vixen uses base64 encoding. I found a base64 decoding library for Arduino. Is this the best route to take? Is there another file format that should be used?

Reply
Posts: 180
Topic starter
(@jonpro03)
Estimable Member
Joined: 15 years ago

Sorry, this will be a standalone player.

Although, I suppose another approach would be to have the arduino 'record' a datastream from a player pc and replay that stream along with the audio...


Reply
kychristmas
Posts: 3947
(@kychristmas)
Famed Member
Joined: 18 years ago
Jonpro03 wrote:Sorry, this will be a standalone player.

Although, I suppose another approach would be to have the arduino 'record' a datastream from a player pc and replay that stream along with the audio...

Sounds cool. Looking forward to seeing it. Do you have a description somewhere of what you are building in terms of the controller? Will it play Audio as well? I believe Greg Bartlett has a similar configuraiton for his Helix stuff.

Kelly


Reply
Posts: 180
Topic starter
(@jonpro03)
Estimable Member
Joined: 15 years ago

It's a long read, but here is the thread: http://doityourselfchristmas.com/forums/showthread.php?19483-Vixen-Arduino-Standardization-HELP-WANTED !

In a nutshell, different shields for different configurations and supporting libraries, all stackable.
Examples may be:

RF broadcaster
MP3 playback
Ethernet/Wifi
Renard8
SDcard

My interest is in seeing the Arduino run a lightshow without a PC. 😀


Reply
Posts: 180
Topic starter
(@jonpro03)
Estimable Member
Joined: 15 years ago

Ok, back to work on decoding .vix files.

I made a simple sequence:

Inside the .vix file you can see the base64 encoding

<EventValues>/////////////wAAAAAAAAAAAAD/////////////AAAAAAAAAAAAAAAcOFVxjarG4v8AAAAAAAAAAAAA/////////////wAAAAAAAAAAAACAgICAgICAgICAAAAAAAAAAAAAAP////////////8AAAAAAAAAAAAA/////////////wAAAAAAAAAAAAD/////////////AAAAAAAAAAAAAP////////////8AAAAAAAAAAAAApqampqampqampgAAAAAAAAAAAAA=</EventValues>

After decoding base64 to hex, I get the following:

ff ff ff ff ff ff ff ff ff ff 00 00 00 00 00 00 00 00 00 00 ff ff ff ff ff ff ff ff ff ff 00 00 00 00 00 00 00 00 00 00 00 1c 38 55 71 8d aa c6 e2 ff 00 00 00 00 00 00 00 00 00 00 ff ff ff ff ff ff ff ff ff ff 00 00 00 00 00 00 00 00 00 00 80 80 80 80 80 80 80 80 80 80 00 00 00 00 00 00 00 00 00 00 ff ff ff ff ff ff ff ff ff ff 00 00 00 00 00 00 00 00 00 00 ff ff ff ff ff ff ff ff ff ff 00 00 00 00 00 00 00 00 00 00 ff ff ff ff ff ff ff ff ff ff 00 00 00 00 00 00 00 00 00 00 ff ff ff ff ff ff ff ff ff ff 00 00 00 00 00 00 00 00 00 00 a6 a6 a6 a6 a6 a6 a6 a6 a6 a6 00 00 00 00 00 00 00 00 00 00

So it appears to me that the vixen saves all the data for the first channel, then moves to the next:

Channel1: ff ff ff ff ff ff ff ff ff ff 00 00 00 00 00 00 00 00 00 00 ff ff ff ff ff ff ff ff ff ff 00 00 00 00 00 00 00 00 00 00 00 1c 38 55 71 8d aa c6 e2 ff
Channel2: 00 00 00 00 00 00 00 00 00 00 ff ff ff ff ff ff ff ff ff ff 00 00 00 00 00 00 00 00 00 00 80 80 80 80 80 80 80 80 80 80 00 00 00 00 00 00 00 00 00 00
Channel3: ff ff ff ff ff ff ff ff ff ff 00 00 00 00 00 00 00 00 00 00 ff ff ff ff ff ff ff ff ff ff 00 00 00 00 00 00 00 00 00 00 ff ff ff ff ff ff ff ff ff ff
Channel4: 00 00 00 00 00 00 00 00 00 00 ff ff ff ff ff ff ff ff ff ff 00 00 00 00 00 00 00 00 00 00 a6 a6 a6 a6 a6 a6 a6 a6 a6 a6 00 00 00 00 00 00 00 00 00 00


Reply
Posts: 6720
(@p-short)
Illustrious Member
Joined: 20 years ago

Yes, it does.


Reply
Posts: 180
Topic starter
(@jonpro03)
Estimable Member
Joined: 15 years ago

Instead of trying to get the the arduino to pull only the information it needs from the vixen file, I think it might be fruitful to just copy/paste the base64 needed for the arduino to read. Then have the track length and event period defined at the beginning of the sketch.

If this is too much work, I'll just figure out how to get the arduino to pull only the info it needs from the vixen file. It's just that the .seek() function really sucks because it will only accept an integer for the location in the file, and that location will always be different based on #of channels, track length, and event period...


Reply
Posts: 180
Topic starter
(@jonpro03)
Estimable Member
Joined: 15 years ago

Here's where I'm at so far with the code:



/*
 
 The circuit:
 * SD card attached to SPI bus as follows:
 ** MOSI - pin 11
 ** MISO - pin 12
 ** CLK - pin 13
 ** CS - pin 10
 */

#include <SD.h>
//#include <Base64.h>
const int chipSelect = 10;
File vixlog;

void setup()
{
  Serial.begin(9600);
  Serial.print("Initializing SD card...");
  // make sure that the default chip select pin is set to
  // output, even if you don't use it:
  pinMode(10, OUTPUT);

  // see if the card is present and can be initialized:

  if (!SD.begin(chipSelect)) {
    Serial.println("Card failed, or not present");
    // don't do anything more:
    return;
  }
  Serial.println("card initialized.");

  if (SD.exists("vixlog.txt"))
  {
    Serial.print("Deleting old vixlog.txt file...");
    SD.remove("vixlog.txt");
    Serial.println("finished.");
  }


  // open the file. note that only one file can be open at a time,
  // so you have to close this one before opening another.
  Serial.print("Creating new vixlog.txt file...");
  vixlog = SD.open("vixlog.txt", FILE_WRITE);
  vixlog.println("vixlog file initialized.");
  Serial.println("vixlog file initialized.");


  if (SD.exists("1.vix"))
  {
    vixlog.println("1.vix file found. Decoding...");
    Serial.println("1.vix file found. Decoding...");    

  }
  else
  {
    vixlog.println("ERROR - 1.vix - File not found.");
    vixlog.println("Ensure that the first vixen file you wish to play is named 1.vix");
    vixlog.println("Exiting...");
    Serial.println("ERROR - 1.vix - File not found.");
    Serial.println("Ensure that the first vixen file you wish to play is named 1.vix");
    Serial.println("Exiting...");
    vixlog.flush();
    vixlog.close();
    return;
  }

  vixlog.flush();
  vixlog.close();
  File vixen1 = SD.open("1.vix", FILE_READ);
  Serial.println("1.vix opened... ");
  if (vixen1) 
  {
    //note to self: Add 3
    vixen1.seek(102);
    while (vixen1.available()) 
    {
      
      Serial.write(vixen1.read());
    }

    Serial.println("end");
    //vixen1.seek(i);
  }


  //Conversion code goes here


  // vixlog.flush();
  //vixlog.close();
  vixen1.close();
}

void loop()
{
}

Reply
Posts: 3650
(@jhinkle)
Famed Member
Joined: 15 years ago

I believe you stated your intent was to run a Vixen sequence as a stand alone device.

I would suggest not attempting to use the Vixen data as it is currently encoded - you have to decode a complete channel before you get to the next channel - you don't have enough ram.

May I suggest decoding the Vixen bases 64 data on your PC and then recoded that data in a manner that can be placed in rom and read directly for each time slice each channel. That will minimize your ram requirements and speed up your processing.

The more work you can do to the data on the PC before you place it into rom - the better it will be for the micro.

Joe


Reply
Page 1 / 7
Share: