Click here for lightsabers
  • Home
  • Help
  • Login
  • Register
Pages: [1]   Go Down
Author Topic: Procedurally Generated Lightsaber Hums  (Read 5280 times)
steadfastivory
Knight Lance Corporal
*

Force Alignment: 8
Posts: 40


“That's how I roll."


« on: June 07, 2017, 01:25:26 AM »

I was hoping to get some feedback from people, even though this is very much a proof-of-concept idea.

For a little while now, I've been wondering if it's possible to synthesize lightsaber sounds in a way that doesn't require recorded audio. Instead, a program could continuously generate the audio data according to whatever algorithm is most useful. This could potentially do things like create lightsaber sounds that don't repeat, make each swing as unique as possible, or incorporate velocity of the swing into the swing sound.

Before you can write code to generate a sound, you need to know how the target sound can be constructed. I did a bunch of research, but frankly, I've been reduced to trial and error. I believe the lightsaber noises from the original trilogy were based on motors you'd find in theater projectors, but how do you generate a similar noise? That part I couldn't figure out.

So instead, I took a relatively simple lightsaber hum I found on YouTube, and guessed at something that might work.

An MP3 of the proof-of-concept can be downloaded from this SpiderOak share. If you have particularly cheap speakers, you may find that the filter responsible for removing 60Hz hum sounds also interferes with playing that MP3. If you have a USB DAC or a USB Headset/Headphones, try that.

Right now, the structure is this:
  • Backbone Tone (99Hz Sine Wave + 81 Hz Sine Wave)
  • Backbone High-Noise Tone (40Hz Sawtooth + 44Hz Sawtooth)
  • Filler Tone (120Hz Sine Wave)
  • Diversity Noise (150Hz Saw Tooth w/ manual chaotic amplitude)

All of the frequencies are probably a bit low. The diversity noise needs to change in volume more often (probably 500-1200ms "high-volume" followed by 200-500ms "low volume"). But, I think this demonstrates a decently viable basic structure, even if it sounds very little like a lightsaber.

Does anyone around here have any thoughts on what could make the concept better before I start working on code?
Logged

I'd like to be a Jedi, if I have any choice in the matter.

Felinus
Knight Apprentice
*

Force Alignment: 7
Posts: 33


« Reply #1 on: June 07, 2017, 04:22:42 PM »


For a little while now, I've been wondering if it's possible to synthesize lightsaber sounds in a way that doesn't require recorded audio. Instead, a program could continuously generate the audio data according to whatever algorithm is most useful. This could potentially do things like create lightsaber sounds that don't repeat, make each swing as unique as possible, or incorporate velocity of the swing into the swing sound.

Does anyone around here have any thoughts on what could make the concept better before I start working on code?

This is an interesting approach. One possibility is you might be able to program sound lengths to better match the duration of swings. Though, I think it's going to be far more difficult than doing it with .wav files. Some of these sounds have multiple layers that include a good deal of randomized noise. I'm not sure how you can get a good crackle with code, but perhaps?

Then you have the challenge of actually implementing this in a saber. Would the code compile in software and then just produce a .wav that the saber could play? or do you expect there would be a uC/uP on the saber that could run the code?

This might also limit what a regular user could do with their own fonts. It'd give them more options in one sense, but fewer wrt/ sampling other analog sounds.

I was thinking of another approach - if the hardware included a 2-channel mixer, you could have an ever-present idle hum, and then layer other sounds on top of it. This would make it easier to produce and edit fonts. I'm not sure if any other saber manufacturers have a board that operates like this, but it would be really nice. If it could be combined with your approach, could be interesting.

Another thought - the saber already knows how hard you're swinging. There is a sensitivity slider, so it must be able to differentiate between "barely a swing" and "hard swing" and everything in-between. If you could rank your swing sounds based on how hard the saber is swung, that would be awesome. So, a gentle swing would produce a just slightly audible change to the idle hum, but a hard swing would be loud and a different pitch. Same goes for any other effect.
Logged

steadfastivory
Knight Lance Corporal
*

Force Alignment: 8
Posts: 40


“That's how I roll."


« Reply #2 on: June 08, 2017, 01:39:04 AM »

I'm doing this precisely because it's hard (and interesting). I don't expect the end result to be user-friendly at first, but maybe that can be improved once I understand the problem and solution better. That's what I'm really hoping to see; someone who can listen to that MP3 I linked to, and have an informed opinion (or at least an interesting dialog) about how close the basic audio structure is to a lightsaber hum. Crackles/crashing is going to be very interesting indeed, but varying the waveforms I'm already using should help with that a fair bit (for example, instead of a fixed 40Hz/44Hz sawtooth pair, use another sawtooth to control the "center" frequency and "delta" between the two sawtooths).

There's already a microcontroller in the Obsidian, Emerald, and Diamond sabers. I don't own one, but just based on the feature set (and the USB support!), there's a uC in there somewhere. Based on my experience with putting an Arduino into a Portal Gun replica, you could use the uC to put in a mixer or fade-in/fade-out a loopable swing sound. Dunno about pitch bending, but you might be able to do that as well. Combine those, and you can go pretty far with sound fonts. Or, you can have the uC run a block of code 10+ times a second to generate the next block of audio data (My plan! Smiley ).

The sensitivity slider can be misleading. Just because there's a sensitivity setting, doesn't mean that it can always tell between "moderate" swings and "hard" swings. The sensor might pick up on very slow or very slight movements, and consider those swings. Below a certain amount of force, there might even be too much electrical noise to reliably read a "weak" swing.
Logged

I'd like to be a Jedi, if I have any choice in the matter.

Felinus
Knight Apprentice
*

Force Alignment: 7
Posts: 33


« Reply #3 on: June 08, 2017, 03:51:49 PM »

If nothing else, maybe you'll end up with a desktop synthesizer application specifically tailored to generating lightsaber sounds. I'd be interested in that. I've been trying to create some sounds with more traditional synthesizers, and just haven't had the time to really get into it. If you do this, one suggestion - add the ability to envelope the sound in low-frequency amplifier, similar to the Tremolo effect in Audacity. I love adding a little bit of that to my sounds, and syncing the blade color/brightness to match the frequency of the pulsing (usually around 10Hz or so).

If you could implement a mixer in the existing Diamond uC, that'd be pretty cool... but it'd be a pretty radical firmware update, and need a different controller interface. I'm not sure if whatever's in the Diamond has enough bandwidth to do that. Of course, the whole controller board is encased in black 'gunk', and there's no schematic online... just a very simplified diagram of the output pins.

As for the sensitivity, yes these things are very jittery (and noisy on the low end), but that's ok. There's still a definite range in the middle. I can easily tell the difference in the saber's response when I adjust these settings. Even if you just got ~3 distinct levels - low, mid, high - that'd be cool.

Slightly separate topic, but I see so many people swinging incorrectly such that the saber only picks up ~half their swings. They swing with their wrist, but the saber can't easily recognize that. You need to move the whole hilt to activate the sound, and then move the blade as the sound plays. With some practice, it looks really smooth. In my opinion, the sound needs to match the blade movement, and it needs to be consistent. If it's not, it kind of ruins the effect.
Logged

CoderHead
Knight Sergeant
*

Force Alignment: -25
Posts: 78


Blaster-Proof


WWW
« Reply #4 on: June 08, 2017, 05:10:48 PM »

I really like the idea you've got here, though like others I wonder if the boards have the processing power to make it work. Out of curiosity, what are you using to code the procedural generation of the sound?
Logged

Dark Side points, please.

Arbiter Obsidian V4, Fire Orange
Archon V2.1 Obsidian V4, Blazing Red
Menace SE (x2) Obsidian V4, Violet Amethyst
Emerald Catalyst Obsidian V4, Consular Green
Emerald Graflex Obsidian V4, Christmas Red/Green Pulse

steadfastivory
Knight Lance Corporal
*

Force Alignment: 8
Posts: 40


“That's how I roll."


« Reply #5 on: June 09, 2017, 01:00:48 AM »


If you could implement a mixer in the existing Diamond uC, that'd be pretty cool... but it'd be a pretty radical firmware update, and need a different controller interface. I'm not sure if whatever's in the Diamond has enough bandwidth to do that. Of course, the whole controller board is encased in black 'gunk', and there's no schematic online... just a very simplified diagram of the output pins.

Sorry if I misled you with an earlier post. I don't have the skill to reverse-engineer a Diamond board, nor do I care to. Ultrasabers is doing a great job with their products as far as I can tell, and I'd rather keep it that way, given whose forums I'm using right now. All I meant to say earlier is that I'm reasonably certain someone could do such a thing, given what limited knowledge I have of what the hardware already does.

As for the sensitivity, yes these things are very jittery (and noisy on the low end), but that's ok. There's still a definite range in the middle. I can easily tell the difference in the saber's response when I adjust these settings. Even if you just got ~3 distinct levels - low, mid, high - that'd be cool.

I leave doing this as an exercise to the reader. Smiley As I said above, I don't know how the Ultrasabers work, and have no interest in reverse-engineering one. I thought I saw someone talk about a "tilt sensor" somewhere, but I have no idea how that'd work, or if it's how Ultrasabers actually work.

----------------------------------------------------

Moving on!

I really like the idea you've got here, though like others I wonder if the boards have the processing power to make it work. Out of curiosity, what are you using to code the procedural generation of the sound?

If nothing else, maybe you'll end up with a desktop synthesizer application specifically tailored to generating lightsaber sounds. I'd be interested in that. I've been trying to create some sounds with more traditional synthesizers, and just haven't had the time to really get into it. If you do this, one suggestion - add the ability to envelope the sound in low-frequency amplifier, similar to the Tremolo effect in Audacity. I love adding a little bit of that to my sounds, and syncing the blade color/brightness to match the frequency of the pulsing (usually around 10Hz or so).

...

Slightly separate topic, but I see so many people swinging incorrectly such that the saber only picks up ~half their swings. They swing with their wrist, but the saber can't easily recognize that. You need to move the whole hilt to activate the sound, and then move the blade as the sound plays. With some practice, it looks really smooth. In my opinion, the sound needs to match the blade movement, and it needs to be consistent. If it's not, it kind of ruins the effect.

This PoC was made with some VERY simple Audacity work. I restrained myself to Generate Tone so that I knew what I was doing could be replicated in code.

I've got a Python script somewhere that does something similar, but it probably needs work. I learned pretty quickly that while text files are great for flexibility, they're terrible for quick prototyping and user-friendliness. If I can polish it to the point where a maker-hacker can read the script, and use it to synthesize their own sounds based on waveforms, and maybe even use that to PoC a few non-looping lightsaber sounds, that's probably enough for me. For the approach I'm using, there will always be tighter limits than for people using Audacity and a good sound effects library. That said, using waveform generators to control other waveform generators is definitely going to be a thing; a varying-amplitude static/crackle requires a Noise waveform controlling the amplitude of a Sawtooth waveform.

I think the end-goal for me is getting this idea onto a Teensy. There's a "shield" for it that includes an LED controller (useless for high-power LEDs, mind you), an audio amplifier, and an IMU. It's significantly more powerful than an Arduino, but still somewhat limited as a platform. I might be able to get away with using an Arduino IDE, or I might have to get into C in order to make everything work. I'm not anywhere near that point yet. By the time I get to the point of working on a uC, the biggest problem will likely be getting the movement info I need out of the IMU. IMUs are powerful, but there's likely some math involved.
Logged

I'd like to be a Jedi, if I have any choice in the matter.

steadfastivory
Knight Lance Corporal
*

Force Alignment: 8
Posts: 40


“That's how I roll."


« Reply #6 on: June 27, 2017, 11:30:34 PM »

Double-posts are frowned on, but I feel like over a week later means this isn't a double-post.

I found a program called SuperCollider that makes prototyping with sound a lot easier, but I'm still figuring out how to get the right sound out.

Here's what I've put together so far:

({
   Mix([
      Mix([SinOsc.ar(99,0,0.075), SinOsc.ar(81,0,0.075)]),
      Mix([Saw.ar(40, 0.05), Saw.ar(44, 0.05)]),
      SinOsc.ar(120,0,0.1),
      Saw.ar(150, StandardL.ar(StandardL.ar(freq:3, mul: 0.5, add: 5, xi: Rand(3.0, 4.0)), xi: Rand(0.01, 0.1), mul: 0.05, add: 0.05))
   ]);
}.play;)

Haven't bothered to record/upload an MP3 for this yet, since it's still very much a work-in-progress. The last sawtooth (Saw.ar(150...)) definitely doesn't sound right, but overall, at least I've got something in the right direction.

Next step is I want to fix the sawtooth. Kind of a fiddly detail, but the details matter with getting the right sound. After that, I can probably look into varying the frequencies to make it sound like there's a swing happening.
Logged

I'd like to be a Jedi, if I have any choice in the matter.

Draq
Knight Apprentice
*

Force Alignment: 10
Posts: 32



« Reply #7 on: September 26, 2017, 06:46:22 AM »

Ah. This is similar to what I was talking about in the suggestion box thread. The difference being that I was talking about pitching an existing sound like the idle hum. This seems to be about creating a digital sound.

I do wonder why the current boards can't layer sounds, but that explains why the fonts have swings and clashes that are mixed with part of the idle hum so the sounds play seemlessly.
Logged

projectno253
Knight Lt. Commander
*

Force Alignment: -88
Posts: 487


There is no Peace...only Victory


« Reply #8 on: September 26, 2017, 02:48:32 PM »

Ah. This is similar to what I was talking about in the suggestion box thread. The difference being that I was talking about pitching an existing sound like the idle hum. This seems to be about creating a digital sound.

I do wonder why the current boards can't layer sounds, but that explains why the fonts have swings and clashes that are mixed with part of the idle hum so the sounds play seemlessly.

I agree on both points, that I would like to see the Obsidian potentially be upgraded to handle both of these requests. It does turn out, however, that there are other boards on the market that can do these things (though not both), but I'm not at leisure to discuss these boards on this forum.
Logged


GFX Jedi
Knight Apprentice
*

Force Alignment: 7
Posts: 22


« Reply #9 on: October 18, 2017, 08:22:19 AM »

There is an entire field of graphics called texture synthesis.  They are mainly for 2d pattern generation but it would be easy to apply to 1d case and probably quite a bit faster.  Google texture synthesis and possibly image analogies as this is rather simple algorithm that produces nice results.  Essentially it picks a random starting place and searches the example image for how to proceed.  In each step progressively builds it.  There are modifications to make the textures tileable which would be ideal for sound on loop.  Deep learning methods can do better but the amount of effort is often not worth the increase in quality.

edit: by the way that paper(image analogies) is a good reference of the field(circa 2002ish) and still produces good results.  he references  Michael Ashikhmin's "Synthesizing Natural Textures" which might be more easily digestible, but improves upon that quite a bit with multi scale approach.  when i was starting reading this kind of stuff i found this particular good starting point, followed by the image analogies one. 
Logged

projectno253
Knight Lt. Commander
*

Force Alignment: -88
Posts: 487


There is no Peace...only Victory


« Reply #10 on: October 18, 2017, 02:53:54 PM »

https://www.youtube.com/watch?v=LHpzbtBo-5w

This is the the best dynamic saber sound system I've heard.
Logged


Draq
Knight Apprentice
*

Force Alignment: 10
Posts: 32



« Reply #11 on: October 18, 2017, 08:40:10 PM »

That's pretty impressive. Some of the swings near the end sounded sort of broken though. Sort of like a cross between a wookiee and a lightsaber.
Logged

GFX Jedi
Knight Apprentice
*

Force Alignment: 7
Posts: 22


« Reply #12 on: October 20, 2017, 12:33:57 AM »

Very cooll.  I'd assume they would have to expose some API to read accelerometer or whatever they are using to base it on swing speed.  Can you guys think of any other way? Don't think gestures are sensitive enough but might work to cycle through a few different frequencies
Logged

Pages: [1]   Go Up
Send this topic | Print
Jump to: