123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|674|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> On Topic -> point between 2 numbers?

Page : 1 2 Next
Prev
Sat, 08 Dec 2018, 04:47
spinal

point between 2 numbers?


I'm stuck on the last part of my sound player. I need to smooth out my wave form (in real time), currently I am re-sampling based on nearest-neighbour type algorithm.


I assume I need to find how far I am between ((snd[s].soundPoint*snd[s].speed)>>8) and ((snd[s].soundPoint*snd[s].speed)>>8)+1, then figure out what number would be at that point. but my brain just can't think of how to do that.
I assume it would be similar to plotting a straight line between 2 pixels on a screen, but as I said, my brain can't quite get it.

Any ideas?

-=-=-
Check out my excellent homepage!
Sat, 08 Dec 2018, 05:13
Jayenkai
Either of these help?



-=-=-
''Load, Next List!''
Sat, 08 Dec 2018, 07:23
spinal
Looks plausible, I'll give it a shot and see how it sounds 😀

-=-=-
Check out my excellent homepage!
Sat, 08 Dec 2018, 11:17
spinal
hmmmm, this idea might be a bit slow.... I wonder if I've got the wrong idea about whats happening.

-=-=-
Check out my excellent homepage!
Sat, 08 Dec 2018, 12:45
spinal
either this isn't working, or it isn't the problme...


-=-=-
Check out my excellent homepage!
Sat, 08 Dec 2018, 15:57
Jayenkai
I can't even begin to guess my way around what that's trying to do.
Sorry, Spinal, you're just going to have to try to simplify it down for me!!

-=-=-
''Load, Next List!''
Sat, 08 Dec 2018, 20:42
Krakatomato
I'd suggest taking a look at low-pass filters. Millions of examples on the internet and I believe a simple version will be all you need (and you're not far off it with the code above anyway).
Sun, 09 Dec 2018, 02:18
spinal
@jay

soundPoint is a counter for reading the data from currentSound[] array, it is incremented in 1's. snd[s].speed is a 'percentage' of 1 multiplied by 256. var2 & 255 should represent what would be a decimal place after dividing by 256, which should give me an idea of the distance between (var1>>8) and (var1>>8)+1. Then that is used to find the number between points currentSound[var1>>8] and currentSound[(var>>8)+1].

PCM audio works only with the difference between numbers, not the numbers themselves. So a run of the same number does not produce a tone, but silence. Upscaling the sample with a nearest neighbour method, results in sections of silence, which sounds awful. So I need to make sure that as much of the data is different from eachother as I can.

-=-=-
Check out my excellent homepage!
Sun, 09 Dec 2018, 02:54
Jayenkai
If that's the case,then any percentages or smoothing is going to result in worse, not better audio.
Instead, then, consider finding the highest point between a and b, then the lowest between b and c...

I'm not sure if that'll sound right, but .. *shrugs*

-=-=-
''Load, Next List!''
Sun, 09 Dec 2018, 03:07
spinal
are you sure?

where my current data is playing something like

127,127,127,127,140,140,140,140,86,86,86,86,200

and I want more like

127,130,133.136,140,126,113, 99, 86,114,143,171,200

-=-=-
Check out my excellent homepage!
Sun, 09 Dec 2018, 03:50
Jayenkai
If you run your fingernail across a comb it goes "crrrrrrr...!"
This is because of the "is a tooth, is not a tooth, is a tooth, is not a tooth" way the teeth of a comb are laid out.

If you want to cut the comb down to half of its size, you can't ignore the tooth, no tooth, methodology. Otherwise when you run your fingernail over it, it'll go clickity click.. click .... click...

You need to trim it, but continue to have the highs and lows, as those are what give it the sound required.

-=-=-
''Load, Next List!''
Sun, 09 Dec 2018, 06:46
spinal
Just noticed I might not have been as clear as I thought I was....

If I want to stretch out my data by 400% from

127,140,86,200,etc.

where my current data is playing something like

127,127,127,127,140,140,140,140,86,86,86,86,200

Those repeating numbers are interpreted as silence in pcm format. resulting in audible gaps in the sound.

PCM format does not use the numbers themselves at all, only the difference between the previous and current number. If there is no difference, then there is no sound.
so I want more like

127,130,133.136,140,126,113, 99, 86,114,143,171,200

which would ramp between the clicks resulting in a tone.

-=-=-
Check out my excellent homepage!
Mon, 10 Dec 2018, 03:19
steve_ancell
To (attempt to) clarify it some more, do you mean like a bridge between the numbers?, sort of like how 3D animation is tweened between frames but with sound?
Mon, 10 Dec 2018, 04:25
steve_ancell
Ah!, I just read through your last comment again. That's a proper **** how that works. The only thing I can think of right now is doing something like (currentNumber - lastNumber) and then add that to the current number.
Mon, 10 Dec 2018, 04:27
steve_ancell
Although, that probably sounds like jibberish too, brain ain't with it today!
Mon, 10 Dec 2018, 04:59
Jayenkai


socoder.net/uploads/1/Spinal_Beep_1.mp3



socoder.net/uploads/1/Spinal_Beep_2.mp3



socoder.net/uploads/1/Spinal_Beep_3.mp3

In order to "extend" the number of points between the wave of a sound, you need to interpolate a LOT more than just "what lies between each"

If you simply interpolate the points inbetween a and b, all you're doing is literally extending the gap in the frequency of the wave, which in turn lowers the pitch of the wave.
What most complex tools tend to do is to find a pattern, and then loop that pattern for each "gap" in the wave. It's exceedingly complicated to do, and I really wouldn't recommend attempting it, especially in realtime.

-=-=-
''Load, Next List!''
Mon, 10 Dec 2018, 05:37
steve_ancell
It's most certainly extended a gap in my brain, that's for sure!
Mon, 10 Dec 2018, 09:29
Krakatomato
I'm still not sure why this is so complicated.

When I re-read your original comment of "I need to smooth out my wave form (in real time)" then this is exactly what a low-pass filter does. You can even knock one up in a single line of code - even for fixed point arithmetic.
Mon, 10 Dec 2018, 10:08
spinal
@jay - yes. That's what I'm doing. Currently playing the wave at the new pitch sounds bad, but the pitch is correct.

-=-=-
Check out my excellent homepage!
Mon, 10 Dec 2018, 10:52
Jayenkai
Are you remembering to multiply the requested pitch rate with the offset of the sample rate and base pitch of the original sample..?

-=-=-
''Load, Next List!''
Mon, 10 Dec 2018, 11:39
spinal


that second method gets a bit clicky at higher sample rates, it seems close to acceptable at 22050... I might stick with that.

-=-=-
Check out my excellent homepage!
Mon, 10 Dec 2018, 13:27
steve_ancell
Krakatomato I'm still not sure why this is so complicated.

When I re-read your original comment of "I need to smooth out my wave form (in real time)" then this is exactly what a low-pass filter does. You can even knock one up in a single line of code - even for fixed point arithmetic.


Go on then fella!, put us all out of misery already.
Tue, 11 Dec 2018, 00:19
spinal
I thought a low pass filter was to remove data, not add it?

-=-=-
Check out my excellent homepage!
Tue, 11 Dec 2018, 02:01
Krakatomato
Probably a good starting point is something like: kiritchatterjee.wordpress.com/2014/11/10/a-simple-digital-low-pass-filter-in-c/
Tue, 11 Dec 2018, 03:37
spinal
that doesn't sound any better at all, a lot worse even.

-=-=-
Check out my excellent homepage!
Tue, 11 Dec 2018, 06:31
Krakatomato
Then you need to tweak the value of Beta to suit. Since all you want is your waveform smoothing then this is all you need - because that's exactly what it does.
Page : 1 2 Next
Prev