Hi all!
Is it possible to make a tone signal? I've tried with the 1000 Hz 1 second wave file, but I hear small pause every second. Is it possible to make it continuously?
How to make 1000 Hz signal and 1500 Hz signal simultaneously?
UPD: fixed mistakes
How to make tone signal and multiple tone signals?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
How to make tone signal and multiple tone signals?
Last edited by darkfrei on Mon Apr 20, 2020 8:41 am, edited 2 times in total.
- zorg
- Party member
- Posts: 3449
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: How to make ton signal and multiple ton signals?
Hi and welcome to the forums.
you mean a tone signal, and yes, you can do that even without a wave file.
that said, if you are hearing a small pause, that can be because of two things,
- the wav file has some silence somewhere in it, either at the end or at the beginning, or
- the wav file's length isn't a multiple of the sine wave in it, meaning it will pop due to discontinuities.
As for the last question, math to the rescue: you add the two signals together.
...or, just have two Sources play the same wav file, one with :setPitch(1.5).
...or have two separate wav files.
you mean a tone signal, and yes, you can do that even without a wave file.
Code: Select all
local frequency = 1000
local SD = love.sound.newSoundData(math.floor(44100/frequency),44100,16,1)
for i=0, SD:getSampleCount()-1 do
SD:setSample(i, math.sin(i * math.pi * 2 * frequency / 44100))
end
local sound = love.audio.newSource(SD)
sound:setLooping(true)
sound:play()
- the wav file has some silence somewhere in it, either at the end or at the beginning, or
- the wav file's length isn't a multiple of the sine wave in it, meaning it will pop due to discontinuities.
As for the last question, math to the rescue: you add the two signals together.
...or, just have two Sources play the same wav file, one with :setPitch(1.5).
...or have two separate wav files.
Last edited by zorg on Mon Apr 13, 2020 1:59 am, edited 1 time in total.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Re: How to make ton signal and multiple ton signals?
I think, you thought SD:setSample (not SD:setSampleCount in for loop) and you must set sample position (as first parameter) - its variable i in for loop
- zorg
- Party member
- Posts: 3449
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: How to make ton signal and multiple ton signals?
Yep, edited the mistakes.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Re: How to make ton signal and multiple ton signals?
Thank you a lot! I need test it before, but I need also the example how to play two tone signals simultaneously.
For example 440 and 880 Hz with sinus form wave.
- zorg
- Party member
- Posts: 3449
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: How to make tone signal and multiple tone signals?
As i said previously, it depends on how you want to do it; there's no one solution.
If you really want me to give you the answer though, then here's a way of doing it that i don't endorse:
If you really want me to give you the answer though, then here's a way of doing it that i don't endorse:
Code: Select all
local f1 = 440
local f2 = 880
local SD1 = love.sound.newSoundData(math.floor(44100/f1),44100,16,1)
local SD2 = love.sound.newSoundData(math.floor(44100/f2),44100,16,1)
for i=0, SD1:getSampleCount()-1 do
SD1:setSample(i, math.sin(i * math.pi * 2 * f1/ 44100))
end
for i=0, SD2:getSampleCount()-1 do
SD2:setSample(i, math.sin(i * math.pi * 2 * f2/ 44100))
end
local S1= love.audio.newSource(SD1)
local S2= love.audio.newSource(SD1)
S1:setLooping(true)
S2:setLooping(true)
love.audio.play(S1, S2)
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Who is online
Users browsing this forum: Ahrefs [Bot] and 0 guests