Go Down

Topic: Arduino Lightsaber (Read 408532 times) previous topic - next topic

Kdot

hit refresh, made a revision.
I am coming back with great success! Works amazing now! Stage 1 complete, now for swing and clash, this is where it looks like it get's fun. Working on a video right now, although excuse my mess.

Kdot

#586
Jan 28, 2016, 06:07 pm Last Edit: Jan 28, 2016, 06:12 pm by Kdot
Here is a sample video using low powered LED, will work on using High powered soon. Also a sample of my previous stunt saber, however just a picture.

Arduion Lightsaber V1






billpealer

#587
Jan 28, 2016, 06:54 pm Last Edit: Jan 29, 2016, 08:01 pm by billpealer
I am coming back with great success! Works amazing now! Stage 1 complete, now for swing and clash, this is where it looks like it get's fun. Working on a video right now, although excuse my mess.
I watched the video.  bravo.  i now should ask your help.  I have never gotten my hum to loop.  but i also never added the 5ms delay after the on sound.  hmm..  i also think you may have too much decay in your hum.  you can fix it in Audacity.  the beginning of the hum needs to be on a neutral tone, and the end needs to be on the same neutral tone.  I do video production. (my day job). which also means i can produce audio.  audio clips often play the perfect sound once.  what you need is the sound in mid play, let it do it's cool Doppler like vrming and hrming,. then decay on the same sound it started on, but in middle play. open your clips in audigy and make sure the wave form looks identical at the beginning and end.  NO FLAT lines,..   some times simply copy/pasting the first 1/2 of the file, delete the second 1/2 of the sound,..  then paste the first 1/2 at the end, reverse it,. then cross blend (fade) it by 5 frames. This is also called mirroring.  Then remove the last 1/30th of a second of the end of the sound..- export.  now frame 1 of the audio will be what was deleted when you got rid of the tail 1/30th.  aka- a loop. you won't hear the click or tap at the loop replay.

DJWing79

A couple of bad prints, but will hopefully have a test soon. I found that Simplify3D allows me to create multiple processes during the print. I already printed one piece of my test...the majority of the handle is at 30% infill, but the screw threads and about 2mm below it are at 100% infill....hope this cinches it!

billpealer

I really can't speak enough about adding hum in the WT to all of your audio triggers except for the off sound.  It is also about combat.
K-dot,  if you turn on your saber,.  you will have a 1/2 second delay till your arduino will accept a hum or clash.  Now you can turn it on, and immediately receive input from your swing or clash.  because your  code whould look like this if your hums were integrated.

  else //Saber is off, so turn it on
  {
   delay(80);  // don't ask just try it.  I have found waking up the WT, it needs a second to boot.
   WT588D_Send_Command(0x02); //on sound
    delay(5);
   digitalWrite(LED, HIGH);
    saber_is_on = true;
   }
You can turn it on and immateriality parry and pull a clash trigger.  LIKE A BOSS!

"You are unwise to lower your defenses." Darth Vader ROTJ

attacks Luke. Luke turns on his saber an in less than 8 frames from the on sound- has parried and is in Lock up.  8 frames is about 285ms.  It implies a light saber can forgo blade grow effect, and just be "ON."

Kdot

I watched the video.  bravo.  i now should ask your help.  I have never gotten my hum to loop.  but i also never added the 5ms delay after the on sound.  hmm..  i also think you may have too much decay in your hum.  you can fix it in Audigy.  the beginning of the hum needs to be on a neutral tone, and the end needs to be on the same neutral tone.  I do video production. (my day job). which also means i can produce audio.  audio clips often play the perfect sound once.  what you need is the sound in mid play, let it do it's cool Doppler like vrming and hrming,. then decay on the same sound it started on, but in middle play. open your clips in audigy and make sure the wave form looks identical at the beginning and end.  NO FLAT lines,..   some times simply copy/pasting the first 1/2 of the file, delete the second 1/2 of the sound,..  then paste the first 1/2 at the end, reverse it,. then cross blend (fade) it by 5 frames. This is also called mirroring.  Then remove the last 1/30th of a second of the end of the sound..- export.  now frame 1 of the audio will be what was deleted when you got rid of the tail 1/30th.  aka- a loop. you won't hear the click or tap at the loop replay.
Thank you! A good portion of this code was provided by you so a huge thank you for that.

In the code you posted I think I ended up having to remove two } to get to to work. Kept telling me wt command want not defined this this scope.

I'll post it when I get in my lunch break!

billpealer

Thank you! A good portion of this code was provided by you so a huge thank you for that.
Ha!  boy, are you in for some disappointment. :) thank jakesoft. seriously.

In the code you posted I think I ended up having to remove two } to get to to work. Kept telling me wt command want not defined this this scope.
i counted those curlies :)  and put the 3 at the end because they were needed.  you obviously have more code in your loop you must have inserted that to. for every open, you need  a close.  in the code you posted you had 4 open curlies.  doesn't that mean you need 4 total closed?  you only had one.  but i digress,..  let arduino debug it

Kdot

Ok finally on lunch, so hear is the code that ended up working for me. I do notice that i cannot turn off the saber until the Hum starts. I think at this point probably would be best to add in Hum at the end, and think about dropping or do something different than looping it. Although definitely works! Probably needs a bit of refining and the //explanations may not always make sense at this point lol.


void loop()

{
 
  if (digitalRead(button) == LOW) //button is pressed
  {
    if (saber_is_on) //Saber is on, so turn it off
    {
      WT588D_Send_Command(0x00); //off sound
      delay(400); //Added
      digitalWrite(LED, LOW);

      saber_is_on = false;
    }
    else //Saber is off, so turn it on
    {
      delay(80);
      WT588D_Send_Command(0x02); //on sound
      delay(10);
      digitalWrite(LED, HIGH);
      delay(4160); //Just long enough for on sound
      WT588D_Send_Command(0x01); // HUM
      delay(5); //gives WT time to play the above
      WT588D_Send_Command(0xF2);

      saber_is_on = true;
    }

  delay(100); //de-bounce it a little
  while (digitalRead(button) == LOW) {} //Wait for them to let off the button
}
if (reading == LOW && previous == HIGH && millis() - time > debounce) {
  if (state == HIGH)
    state = LOW;
  else
    state = HIGH;
  WT588D_Send_Command(0x00);
  time = millis();
}

previous = reading;
}




JakeSoft

Here is a sample video using low powered LED, will work on using High powered soon. Also a sample of my previous stunt saber, however just a picture.

Arduion Lightsaber V1

Looking good! And wow, I think that's the fastest I've seen anyone go from noob to prototype. And in a hilt, no less!

billpealer

#594
Jan 29, 2016, 01:16 am Last Edit: Jan 29, 2016, 03:33 am by billpealer
dude. why the 4000 ms delay?  you cant clean that up?  that is the reason you can't turn it off.  a delay command pauses the whole arduino from further processing, or I/O.

What is the play time in ms of JUST the on sound?  ... that number can be put in the delay after the on sound.  4.1 seconds of delay is,  your prerogative, but......

billpealer

Haha, you can add my stamp there also. I'm using the same trick with the DFPlayer, cheers from the club of lazy humming-birds. It could be done cleaner, but this method is so much easier and quite robust!
the only way cleaner is ONE COMPOSED FILE.  which won't work.  if there is a way to have ambient hum follow the trigger sounds,. i am all ears!  get it!? sounds?  ears!?

i am currently composing a new sound.    "clash decay'  i will get lock up with no buttons to work.  my guess is people who have tried it, tried to do it with software, instead of sound composition,

i have a fundamental question,  if one were to parry (clash) and NOT lock up,.  (bouncing parry or a beat)  would every clash sound be followed by a swing?

so,..  clash,swing,hum,..

if you were to hold the saber still, and your opponent would repeatedly smack your blade, and you would not move,. that should be...  clash,.. hum. (normal clash)  i don't think that could be done in active combat,. only choreography or geek foreplay.

JakeSoft

#596
Jan 29, 2016, 05:08 am Last Edit: Jan 29, 2016, 05:11 am by JakeSoft
the only way cleaner is ONE COMPOSED FILE.  which won't work.  if there is a way to have ambient hum follow the trigger sounds,. i am all ears!  get it!? sounds?  ears!?

i am currently composing a new sound.    "clash decay'  i will get lock up with no buttons to work.  my guess is people who have tried it, tried to do it with software, instead of sound composition,

i have a fundamental question,  if one were to parry (clash) and NOT lock up,.  (bouncing parry or a beat)  would every clash sound be followed by a swing?

so,..  clash,swing,hum,..

if you were to hold the saber still, and your opponent would repeatedly smack your blade, and you would not move,. that should be...  clash,.. hum. (normal clash)  i don't think that could be done in active combat,. only choreography or geek foreplay.
I'm sure there are schools of thought on this. (Or maybe not... who except us would spend so much time thinking about this?! haha!) Personally, I don't like my clash sounds being interrupted by anything, so I let them play out fully before allowing swing sounds to happen again. I think the toy lightsabers and MR boards work the same way.

But hey, that's the joy of building your own board. You can make it work the way YOU want it to.

Kdot

Looking good! And wow, I think that's the fastest I've seen anyone go from noob to prototype. And in a hilt, no less!
Thanks! You really motivated me! Never would have thought this to be possible

Kdot

dude. why the 4000 ms delay?  you cant clean that up?  that is the reason you can't turn it off.  a delay command pauses the whole arduino from further processing, or I/O.

What is the play time in ms of JUST the on sound?  ... that number can be put in the delay after the on sound.  4.1 seconds of delay is,  your prerogative, but......
Ha yeah about that, i reprogrammed my WT with some new sounds and last minute i realized the start up sound was like 19xx ms and the hum was a little over 2000ms. Working find a sound i like, so i can spend a little more time with the audio files themselves.

I also removed the Hum from the start up sound, it wasnt terrible, however there was a slight click between the Startup to Hum, reduced delay and it got smaller, but wondering if that could be cleaned up in the audio side for slightly smoother transition like you mentioned before.


billpealer

#599
Jan 29, 2016, 02:55 pm Last Edit: Jan 29, 2016, 08:02 pm by billpealer
, but wondering if that could be cleaned up in the audio side for slightly smoother transition like you mentioned before.
if you don't want to marry sounds in the the WT playlist,..
one way to cheat seamless playback (this is old school) with arduino commands is fades to near silence. (but i think if you use the WT-28pin-U and a 16mhz arduino, the gaps for commands to the WT are ... 2ms?  I think i read that back on like page 7 or 9.  Back there somewhere. Jake and Illuis were talking about it. Jake?  2ms?  do you actually trigger hum? or do you marry it too in your MKIII+ versions?  What ever happened to Illuis?  He is the 1 Line Serial Mode Guy! He must be a coder and not a saber builder.
anyway...
have all sounds fade DOWN to almost silence at the end,  make your own hum cycle in audigy, (maybe a 6 second total file) then a fade to near silence at the end. export. when the sound loops,.  or really plays after your ON, SWING, OR CLASH,.. it will have little to no "taps" tween sound files.  Just make sure your ON, SWING, and CLASH, all fade down at the end of the clip. a 10-15 frame fade is all that is needed. if need be i can post an audacity tute on how to do this. or if anyone has adobe premier, or elements, or sony vegas, imove, final cut,.. PM me, i will talk u thru it. if you sound edit in pro software, you will have to master in Audigy, for the 22khz audio.  in the audio world there really is only 22,050 Hz sample rate.  but the WT can't use that rate. It needs 22,000 hz exactly.  the 50 throws it off.  That set me back a week actually. I was like,.  "i don't need BS hackware Audacity.  I'll just use my $4,000 Adobe Suite."  Nope.  All my pro audio packages won't let me make audio to that sample rate.  Because it is a junk rate- 22,050 is 1/2 CD PWM audio sample.  44.1khz.  20,000hz is,..  well..  nothing. it's just an arbitrary rate the WT accepts. Most likely a goof up in the firmware code.  it should be taking 20,050hz.
Also, all this sound triggering that we do with the WT from what i am learning this is the difference tween "sound fonts" and "sound files". A sound font is one file with all the sounds in it.  The MCU just tells the player module WHERE to play and end (like a vinyl record).  where as in the WT which plays files not fonts,...  just triggers the uploaded file or playlists to play (like a CD).  You can't in the WT tell it to play clip 1 ( a 20 second clip)  from second 3-7 and loop it. If you download a sound font file, you have to chop it up in Audacity.  make sure you slice where it loops :)

Jake did you buy your audio?

Go Up