Arduino Lightsaber

Ok, guys. Here is another drop of the Universal Saber library. The major addition is: Sound! I finally added sound support. And let me tell you, this one didn’t come easy. I added an example of how to implement a sound-handling class by creating a saber sound player for the WT588D. I’m still working on multi-font support, but the interface will at least support one sound font plus menu sounds. This is likely enough for simple projects.

  1. Added sound support!
    WT588DSoundPlayer: A sabers sound player for the WT588D.

You have to parameterize it to tell it how many sound of each type (swing, clash, power-up, etc) you have by populating a data structure. This is an alternative to a bunch of #define or const int statements that have typically been used. It puts it all in one convenient place. These are all things you would have to define anyway, the constructor just forces you to do it up front.

So for example, if you had in your WT588D equations (play lists) programmed like this:
0x00 = Power Up
0x01 = Hum
0x02 = Swing
0x03 = Clash 1
0x04 = Clash 2
0x05 = Power Down

You’d parameterize as in the following example sketch:

#include<USaber.h>

//The data structure that describes your sound layout
WT588DSoundMap gSoundMap;

//Pointer to the actual sound player
ASoundPlayer* gpSaberSound;

//The I/O pin for one-line serial comms
#define WT588D_SDA 13

void setup()
{
  //Sound font features
  gSoundMap.Features.PowerUpSoundsPerFont = 1;	
  gSoundMap.Features.HumSoundsPerFont = 1;
  gSoundMap.Features.SwingSoundsPerFont = 1;	
  gSoundMap.Features.ClashSoundsPerFont = 2; //0x03 and 0x04 are clash sounds
  gSoundMap.Features.PowerDownSoundsPerFont = 1;

  //Base address offset for all sounds (typically zero)
  gSoundMap.Locations.BaseAddr = 0; 

  //Sound locations on the module
  gSoundMap.Locations.PowerupBase = 0;
  gSoundMap.Locations.HumBase = 1;  
  gSoundMap.Locations.SwingBase = 2;
  gSoundMap.Locations.ClashBase = 3; //0x03 and 0x04 are clash sounds
  gSoundMap.Locations.PowerdownBase = 5;
  

  //Now create the player
  gpSaberSound = new WT588DSoundPlayer(WT588D_SDA, &gSoundMap);

  //And intialize it
  gpSaberSound->Init();
}

void loop()
{
  //code code code...

  //Get to a place where you want play a power up sound and...
  gpSaberSound->PlaySound(eePowerUpSnd, 0); //Play the 0th (the first) power-up sound

  //blah blah blah...

  //Get to a place where you want to play a random clash sound...
  gpSaberSound->PlayRandomSound(eeClashSnd);
}
  1. Fixed a bug in SimpleMotionManager that would sometimes allow double-trigger on clash events.

Whew, I need a break. I hope you all enjoy. MTFBWY.

USaber_3_26_2016.zip (37.4 KB)

Protonerd: I was intrigued so I just looked at how much storage space all 8 of my high-quality saber fonts (all from SaberFont, no advertisement intended, and I was quite affronted by one of the "artists" covertly accusing me of piracy in a comment to one of my YouTube videos, but you can find really good ones there) take, it's 23MB. They are really good fonts, and after some years building saber replicas in my opinion 4-5 fonts are more than enough. You will settle very fast for some favorites...

You may be able to plop down a 16MB flash chip in place of your SD card on a future revision of DIYino. You'll get that USB-sound transfer feature you were looking for a while back in a conversation I remember. I could see two USB ports: One for the MCU, one for the sound. Might take up less room than the SD card too.

And you are right about settling on favorites. I've reprogrammed my Mk. II with several fonts since I built it, but I keep going back to my original set. It supports 3 fonts, but only use my favorite one of them 90% of the time.

JakeSoft: Ok, guys. Here is another drop of the Universal Saber library. The major addition is: Sound! I finally added sound support. And let me tell you, this one didn't come easy. I added an example of how to implement a sound-handling class by creating a saber sound player for the WT588D. I'm still working on multi-font support, but the interface will at least support one sound font plus menu sounds. This is likely enough for simple projects.

  1. Added sound support! WT588DSoundPlayer: A sabers sound player for the WT588D.

You have to parameterize it to tell it how many sound of each type (swing, clash, power-up, etc) you have by populating a data structure. This is an alternative to a bunch of #define or const int statements that have typically been used. It puts it all in one convenient place. These are all things you would have to define anyway, the constructor just forces you to do it up front.

So for example, if you had in your WT588D equations (play lists) programmed like this: 0x00 = Power Up 0x01 = Hum 0x02 = Swing 0x03 = Clash 1 0x04 = Clash 2 0x05 = Power Down

You'd parameterize as in the following example sketch:

#include

//The data structure that describes your sound layout WT588DSoundMap gSoundMap;

//Pointer to the actual sound player ASoundPlayer* gpSaberSound;

//The I/O pin for one-line serial comms

define WT588D_SDA 13

void setup() {   //Sound font features   gSoundMap.Features.PowerUpSoundsPerFont = 1;   gSoundMap.Features.HumSoundsPerFont = 1;   gSoundMap.Features.SwingSoundsPerFont = 1;
  gSoundMap.Features.ClashSoundsPerFont = 2; //0x03 and 0x04 are clash sounds   gSoundMap.Features.PowerDownSoundsPerFont = 1;

  //Base address offset for all sounds (typically zero)   gSoundMap.Locations.BaseAddr = 0;

  //Sound locations on the module   gSoundMap.Locations.PowerupBase = 0;   gSoundMap.Locations.HumBase = 1;    gSoundMap.Locations.SwingBase = 2;   gSoundMap.Locations.ClashBase = 3; //0x03 and 0x04 are clash sounds   gSoundMap.Locations.PowerdownBase = 5;  

  //Now create the player   gpSaberSound = new WT588DSoundPlayer(WT588D_SDA, &gSoundMap);

  //And intialize it   gpSaberSound->Init(); }

void loop() {   //code code code...

  //Get to a place where you want play a power up sound and...   gpSaberSound->PlaySound(eePowerUpSnd, 0); //Play the 0th (the first) power-up sound

  //blah blah blah...

  //Get to a place where you want to play a random clash sound...   gpSaberSound->PlayRandomSound(eeClashSnd); }




2. Fixed a bug in **SimpleMotionManager** that would sometimes allow double-trigger on clash events.

Whew, I need a break. I hope you all enjoy. MTFBWY.

EXCELENT JAKESOFT ...... !!!!!!

In the future, I will try this library.

In the past weekend, I have advanced in my project.

I found a library, a talking clock that left me run sounds WT588D-U.

I share a video of the tests.

Prueba de Sable - Massabers

Now we must work on the look and feel of the saber.

Thanks to all for the help.

JakeSoft: You may be able to plop down a 16MB flash chip in place of your SD card on a future revision of DIYino. You'll get that USB-sound transfer feature you were looking for a while back in a conversation I remember. I could see two USB ports: One for the MCU, one for the sound. Might take up less room than the SD card too.

You remember right, once I reach break-even with my DIYino design, I want to embark on a quest for a high-end Arduino saber core. I already sketched up in my mind the core requirements: 1. Flash instead of SD 2. Equally important in my eyes is that it must have only a single USB port. An USB takes up nearly the same room as an SD, and latter is flatter. 3. I think about an Atmega with more memory. 4. Use flash to store arbitrary data accessible by the uC.

However this one I intend to do in a team.

JakeSoft: Ok, guys. Here is another drop of the Universal Saber library. The major addition is: Sound! I finally added sound support. And let me tell you, this one didn't come easy. I added an example of how to implement a sound-handling class by creating a saber sound player for the WT588D. I'm still working on multi-font support, but the interface will at least support one sound font plus menu sounds. This is likely enough for simple projects.

  1. Added sound support! WT588DSoundPlayer: A sabers sound player for the WT588D.

You have to parameterize it to tell it how many sound of each type (swing, clash, power-up, etc) you have by populating a data structure. This is an alternative to a bunch of #define or const int statements that have typically been used. It puts it all in one convenient place. These are all things you would have to define anyway, the constructor just forces you to do it up front.

So for example, if you had in your WT588D equations (play lists) programmed like this: 0x00 = Power Up 0x01 = Hum 0x02 = Swing 0x03 = Clash 1 0x04 = Clash 2 0x05 = Power Down

You'd parameterize as in the following example sketch:

#include

//The data structure that describes your sound layout WT588DSoundMap gSoundMap;

//Pointer to the actual sound player ASoundPlayer* gpSaberSound;

//The I/O pin for one-line serial comms

define WT588D_SDA 13

void setup() {   //Sound font features   gSoundMap.Features.PowerUpSoundsPerFont = 1;   gSoundMap.Features.HumSoundsPerFont = 1;   gSoundMap.Features.SwingSoundsPerFont = 1;
  gSoundMap.Features.ClashSoundsPerFont = 2; //0x03 and 0x04 are clash sounds   gSoundMap.Features.PowerDownSoundsPerFont = 1;

  //Base address offset for all sounds (typically zero)   gSoundMap.Locations.BaseAddr = 0;

  //Sound locations on the module   gSoundMap.Locations.PowerupBase = 0;   gSoundMap.Locations.HumBase = 1;    gSoundMap.Locations.SwingBase = 2;   gSoundMap.Locations.ClashBase = 3; //0x03 and 0x04 are clash sounds   gSoundMap.Locations.PowerdownBase = 5;  

  //Now create the player   gpSaberSound = new WT588DSoundPlayer(WT588D_SDA, &gSoundMap);

  //And intialize it   gpSaberSound->Init(); }

void loop() {   //code code code...

  //Get to a place where you want play a power up sound and...   gpSaberSound->PlaySound(eePowerUpSnd, 0); //Play the 0th (the first) power-up sound

  //blah blah blah...

  //Get to a place where you want to play a random clash sound...   gpSaberSound->PlayRandomSound(eeClashSnd); }




2. Fixed a bug in **SimpleMotionManager** that would sometimes allow double-trigger on clash events.

Whew, I need a break. I hope you all enjoy. MTFBWY.

Awesome work JakeSoft!

I think i'm gonna have to do a LSOS and USaber hybrid.

There is a place just down the street from me that makes PCBs, they also populate boards etc,.. After I get everything working I was planing on going-over to them to see what they can do. They maybe able give me some direction on both the flash and single USB for all shortage. I'd also like ubs recharge for the batteries if it can all be one port. That kills alot of birds with one stone.

Soulbp: There is a place just down the street from me that makes PCBs, they also populate boards etc,.. After I get everything working I was planing on going-over to them to see what they can do. They maybe able give me some direction on both the flash and single USB for all shortage. I'd also like ubs recharge for the batteries if it can all be one port. That kills alot of birds with one stone.

Lucky you! That'll make shipping a non-issue for you. Are you state side? So far, the only folks who have shown enough ambition to build PCBs are in Europe. Great for them, but the shipping is painful for us Yankees.

Yes, im state side. Once I have a working model and talk to them I can let you know what they quote and what they say.

JakeSoft: Lucky you! That'll make shipping a non-issue for you. Are you state side? So far, the only folks who have shown enough ambition to build PCBs are in Europe. Great for them, but the shipping is painful for us Yankees.

No need to shed Yankee tears :) I talked to the local post clerk, it seems an insured, bubble foil envelope costs about 10$, actually no matter where I send it (US the same as when I send to a neighboring country), non-insured is ~4$.

Look what I've found: http://www.ebay.de/itm/4-Stueck-USB-Rechargeable-4200mAh-3-7V-BRC-18650-Batterie-Battery-Li-ion-AKKU-UK-/272065940619?_trksid=p2141725.m3641.l6368

A 3.7V type 18650 battery with in-built USB recharger...? How cool is that? It seems it's only slightly longer (67mm instead of 65) but has a great capacity. Maybe such a battery can be tweaked to connect to the USB of the board and have it charged while connected.

Protonerd: No need to shed Yankee tears :) I talked to the local post clerk, it seems an insured, bubble foil envelope costs about 10$, actually no matter where I send it (US the same as when I send to a neighboring country), non-insured is ~4$.

Well, that's good news. For comparison, domestic uninsured padded envelope from the United States Postal Service is ~2 USD according to my local post office. It goes up from there depending on how much insurance you add.

Hi guys

Started populating the boards only to find the provided SOT-23-5 footprint (used for the 3v3 regulator) is way off scale so had to make my own and mod the layout artwork. Major bummer as finding the couple hrs straight needed to make them was not easy. Got time off next week so I'll see about re doing them then.

I'm also having trouble with converted audio as well. For some reason the WT software won't accept anything above 8Khz, anyone else had this problem?

Protonerd: Look what I've found: http://www.ebay.de/itm/4-Stueck-USB-Rechargeable-4200mAh-3-7V-BRC-18650-Batterie-Battery-Li-ion-AKKU-UK-/272065940619?_trksid=p2141725.m3641.l6368

A 3.7V type 18650 battery with in-built USB recharger...? How cool is that? It seems it's only slightly longer (67mm instead of 65) but has a great capacity. Maybe such a battery can be tweaked to connect to the USB of the board and have it charged while connected.

I would not suggest those, the highest 18650 capacity is 3400mah from phillip NCR cells that are pretty expensive. Those are probably some 14500 cells inside a 18650 body with a usb lipo charger, probably a 900mah actuall capacity.

Canobi: I'm also having trouble with converted audio as well. For some reason the WT software won't accept anything above 8Khz, anyone else had this problem?

thats weird, i just open my wavs in audacity, manually change the project rate to 22000 hz and save the new wavs

splinter182: thats weird, i just open my wavs in audacity, manually change the project rate to 22000 hz and save the new wavs

I'm doing exactly that using three audio software packages, audacity (the only free one I've used), acid pro 6 and soundforge 7 but no joy :/

Might do a wt software reinstall and see if that helps.

Canobi: I'm doing exactly that using three audio software packages, audacity (the only free one I've used), acid pro 6 and soundforge 7 but no joy :/

Might do a wt software reinstall and see if that helps.

Is the WT software rejecting your sound files when you attempt to import?

Make sure you actually type "22000" in the project rate menu. If you use the pull down menu without typing, then it will go to 22050, which won't work.

JakeSoft:
Is the WT software rejecting your sound files when you attempt to import?

Make sure you actually type “22000” in the project rate menu. If you use the pull down menu without typing, then it will go to 22050, which won’t work.

Tried that, same story :frowning:

Canobi:
Tried that, same story :frowning:

Hmm. That’s weird. I’ve converted probably hundreds of files that way at 10K, 20K, and 22K Hz and it’s always worked. If you continue to have problems, you could send me your sound files and I could possibly build the binary for you.

Thanks Jake, I'll bare that in mind.

I'm sure it's something stupidly simple going on, not heard anyone else complain about sampling frequency problems.

Found out what the issue was.

The sound files I was trying to convert were mono so I switched to a set of stereo files and it worked a treat.