Please post any sugestions or comments about my tutorial here.
What would you like to see in my tutorial ? (keep in mind that it is about sound using DirectXSound)
Any comments about what I already have ? something that needs more explaining, or not clear enough ?
Did I make any mistakes in that thread ? am I saying something that is not true/wrong ?
Keep in mind that it is under construction, and it will be for a long time. I'm doing this in my free time (at work, and home).
Re: Sugestions or Comments about my Sound Tutorial
Sorry, I don't know anything about MIDI, so I won't cover it.
About the dummy file: vbforums.com will display the attached picture in the attachment section if there is only one picture attached. If there is more than one picture, it won't display any of them. This way i'm tricking it into not displaying the picture, because I don't want to display it there, I want to display the picture at the beginning of the post.
The non-DX sound, I mean wave files, creating and modifying sounds directly in the Byte (or Integer) arrays, as opposed to modify the sound in the DX buffer, or DX functions.
Last edited by CVMichael; Feb 22nd, 2006 at 06:18 PM.
Re: Sugestions or Comments about my Sound Tutorial
It looks good so far.
You can put the image attachment in a post in the Support Images forum, and just link to it.
The only comment I have is the "Sound format: What is ..." section seems to run-on, I'd prefer to see it either as a list, or with each item (eg: Block Align) underlined and/or bold to make them stand out.
I tried one (IrfanView 3.98) from download.com and I found the interface so difficult, I could not figure out how to even make a simple GIF, so I just un-installed it.
Re: Sugestions or Comments about my Sound Tutorial
"What is sound ?":
What about frequencies, and their representation as samples?
"Sound format":
Samplerate - I think you should also explain the Nyquist frequency.
"How to read or write to a wave file ?":
I thought those headers were called chunks.
Also your WaveReadFormat function may not work for all wavs,
there could also be other chunks (for example comments) before
the data chunk, or the data could be compressed, so the format
chunk could be much bigger.
I'm excited about the more advaned topics like tone recognition
and resampling. Will you also cover the FFT and digital filters (IIR, FIR)?
For the ACM encoder, I could give you a class I've written,
if you're interested.
Re: Sugestions or Comments about my Sound Tutorial
Originally Posted by rm_03
"What is sound ?":
What about frequencies, and their representation as samples?
I can explain about frequencies... but I'm not sure what you mean by "and their representation as samples"
Originally Posted by rm_03
"Sound format":
Samplerate - I think you should also explain the Nyquist frequency.
I don't know anything about Nyquist frequency, I heared before about Nyquist theorem. But as I was saying don't know anything about it.
Maybe you can exaplain it, and I'll put it in the tutorial (giving credit to you for that part of course)
Originally Posted by rm_03
"How to read or write to a wave file ?":
I thought those headers were called chunks.
Yea... I do have a "ChunkHeader" structure there...
Originally Posted by rm_03
Also your WaveReadFormat function may not work for all wavs,
there could also be other chunks (for example comments) before
the data chunk, or the data could be compressed, so the format
chunk could be much bigger.
That's what this code does (From the WaveReadFormat):
VB Code:
' Ignore chunks until we get to the "data" chunk.
Get #InFileNum, , chunk
Do While chunk.lType <> &H61746164
For i = 1 To chunk.lLen
Get #InFileNum, , by
Next
Get #InFileNum, , chunk
Loop
Originally Posted by rm_03
Will you also cover the FFT and digital filters (IIR, FIR)?
I was thinking to write something about FFT, but I have only little experience with it.
And I don't know about filters, but I'm excited to learn. And when I know something then i'll put it in the tutorial.
I was actually looking for a long time for code (or formulas) about digital filters, but I could not find anything usefull.
Originally Posted by rm_03
For the ACM encoder, I could give you a class I've written,
if you're interested.
I saw you code already, not long before you posted it in the CodeBank, but one problem I found with it is that it does not convert in real time, you have to give it a wave file, and then it will convert to MP3.
I want to do this in real time, the code that I will explaing in the tutorial will be for both actually, for real time, and separate converting wave file to MP3 file.
Last edited by CVMichael; Feb 23rd, 2006 at 01:21 PM.
Re: Sugestions or Comments about my Sound Tutorial
I can explain about frequesncies... but I'm not sure what you mean by "and their representation as samples"
Basic stuff like how does a frequency at 10 Hz with the amplitude 16000 look like, and how to use sample points to create such a frequency.
Nyquist frequency
Never heard of the "Nyquist theorem" , but the Nyquist frequency (the highest possible freq) would
be samplerate / 2, because you need at least 2 sample points for a frequency.
That's what this code does (From the WaveReadFormat):
Oops, didn't see that, sorry
I was actually looking for a long time for code (or formulas) about digital filters, but I could not find anything usefull.
Re: Sugestions or Comments about my Sound Tutorial
Originally Posted by rm_03
Basic stuff like how does a frequency at 10 Hz with the amplitude 16000 look like, and how to use sample points to create such a frequency.
I was planing to show how to create tones of certain frequencyes, if you look at "My Objectives", You will see "How to dinamically create tones/beeps with custom frequencies."
I'm gonna put some images showing the wave data in that section of the tutorial.
Originally Posted by rm_03
Never heard of the "Nyquist theorem" , but the Nyquist frequency (the highest possible freq) would
be samplerate / 2, because you need at least 2 sample points for a frequency.
Ow yea, that ring a bell
Yea, I think I'll explain it, but I have to read a little more about it, so that I can explain in words that actually make sence
Nice !
I will definitelly spend some time checking the filters, and if I can get (at least one) of them to work, then I'll put that in the tutorial too.
Originally Posted by rm_03
there's nothing comparable to it in the VB world yet.
What do you mean by that ?
You mean no one made a tutorial about sound in VB yet ? (I doubt that)
Re: Sugestions or Comments about my Sound Tutorial
You mean no one made a tutorial about sound in VB yet ? (I doubt that)
At least I havn't seen anything for VB which deals with the lower level parts.
You just can't call "how to use MCI/WMP" a sound tutorial.
BTW, IIR filter for 16 bit:
in a module:
Code:
Option Explicit
Private Const Pi As Single = 3.14159265358979
Private Const LN2 As Single = 0.693147180559945
Public Enum IIR_TYPE
IIR_LOW_PASS
IIR_HIGH_PASS
IIR_BAND_PASS
IIR_NOTCH
IIR_PEAK_EQ
IIR_LOW_SHELVE
IIR_HIGH_SHELVE
End Enum
Public Function CreateBiquadIIR( _
ByVal iirtype As IIR_TYPE, _
ByVal dBGain As Single, _
ByVal freq As Single, _
ByVal srate As Single, _
ByVal bandwidth As Single _
) As IIRFilter
Dim A As Single, omega As Single
Dim sn As Single, cs As Single
Dim Alpha As Single, Beta As Single
Dim a0 As Single, a1 As Single, a2 As Single
Dim b0 As Single, b1 As Single, b2 As Single
Dim filter As IIRFilter
Set filter = New IIRFilter
A = 10 ^ (dBGain / 40)
omega = 2 * Pi * freq / srate
sn = Sin(omega)
cs = Cos(omega)
Alpha = sn * sinh(LN2 / 2 * bandwidth * omega / sn)
Beta = Sqr(A + A)
Select Case iirtype
Case IIR_LOW_PASS
b0 = (1 - cs) / 2
b1 = 1 - cs
b2 = (1 - cs) / 2
a0 = 1 + Alpha
a1 = -2 * cs
a2 = 1 - Alpha
Case IIR_HIGH_PASS
b0 = (1 + cs) / 2
b1 = -(1 + cs)
b2 = (1 + cs) / 2
a0 = 1 + Alpha
a1 = -2 * cs
a2 = 1 - Alpha
Case IIR_BAND_PASS
b0 = Alpha
b1 = 0
b2 = -Alpha
a0 = 1 + Alpha
a1 = -2 * cs
a2 = 1 - Alpha
Case IIR_NOTCH
b0 = 1
b1 = -2 * cs
b2 = 1
a0 = 1 + Alpha
a1 = -2 * cs
a2 = 1 - Alpha
Case IIR_PEAK_EQ
b0 = 1 + (Alpha * A)
b1 = -2 * cs
b2 = 1 - (Alpha * A)
a0 = 1 + (Alpha / A)
a1 = -2 * cs
a2 = 1 - (Alpha / A)
Case IIR_LOW_SHELVE
b0 = A * ((A + 1) - (A - 1) * cs + Beta * sn)
b1 = 2 * A * ((A - 1) - (A + 1) * cs)
b2 = A * ((A + 1) - (A - 1) * cs - Beta * sn)
a0 = (A + 1) + (A - 1) * cs + Beta * sn
a1 = -2 * ((A - 1) + (A + 1) * cs)
a2 = (A + 1) + (A - 1) * cs - Beta * sn
Case IIR_HIGH_SHELVE
b0 = A * ((A + 1) + (A - 1) * cs + Beta * sn)
b1 = -2 * A * ((A - 1) + (A + 1) * cs)
b2 = A * ((A + 1) + (A - 1) * cs - Beta * sn)
a0 = (A + 1) - (A - 1) * cs + Beta * sn
a1 = 2 * ((A - 1) - (A + 1) * cs)
a2 = (A + 1) - (A - 1) * cs - Beta * sn
End Select
filter.a0 = b0 / a0
filter.a1 = b1 / a0
filter.a2 = b2 / a0
filter.a3 = a1 / a0
filter.a4 = a2 / a0
filter.x1 = 0: filter.x2 = 0
filter.y1 = 0: filter.y2 = 0
Set CreateBiquadIIR = filter
End Function
Private Function sinh(angle As Single) As Single
sinh = (Exp(angle) - Exp(-angle)) / 2#
End Function
class "IIRFilter":
Code:
Option Explicit
' http://www.dspguru.com/sw/lib/biquad.c
Public a0 As Single
Public a1 As Single
Public a2 As Single
Public a3 As Single
Public a4 As Single
Public x1 As Single
Public x2 As Single
Public y1 As Single
Public y2 As Single
Public Sub ProcessSamples( _
intSamples() As Integer, _
ByVal datalen As Long _
)
Dim result As Single
Dim sample As Single
Dim i As Long
For i = 0 To datalen
sample = intSamples(i) / 32767
result = a0 * sample + a1 * x1 + a2 * x2 - a3 * y1 - a4 * y2
x2 = x1
x1 = sample
y2 = y1
y1 = result
If result > 1# Then
intSamples(i) = 32767
ElseIf result < -1# Then
intSamples(i) = -32768
Else
intSamples(i) = CInt(result * 32767)
End If
Next
End Sub
Usage:
Code:
Dim clsIIR as IIRFilter
Dim intSamples(44100 - 1) As Integer ' could be any size
Set clsIIR = CreateBiquadIIR(IIR_PEAK_EQ, 6, 170, 44100, 1)
clsIIR.ProcessSamples intSamples, UBound(intSamples)
Will boost your signal at 170 Hz by 6 dB with a bandwidth of 1 octave.
I love them Create some of them in a row and you got an equalizer.
Re: Sugestions or Comments about my Sound Tutorial
Not much left...
FFT with windowing:
Code:
Option Explicit
Private Const Pi As Single = 3.14159265358979
Private Const AngleNum As Single = 2 * Pi
Private lngPow2(31) As Long
Public Enum FFT_WINDOW
WINDOW_FUNC_NONE
WINDOW_FUNC_HANNING
WINDOW_FUNC_HAMMING
WINDOW_FUNC_BLACKMAN
End Enum
' http://www.fullspectrum.com/deeth/main.html
Public Sub FastFourierTransform( _
NumSamples As Long, _
RealIn() As Integer, _
RealOut() As Single, _
Optional wnd As FFT_WINDOW = WINDOW_FUNC_NONE _
)
Dim NumBits As Long
Dim Rev As Long
Dim index As Long
Dim i As Long, j As Long
Dim k As Long, n As Long
Dim BlockSize As Long, BlockEnd As Long
Dim DeltaAngle As Single, DeltaAr As Single
Dim Alpha As Single, Beta As Single
Dim TR As Single, TI As Single
Dim AR As Single, AI As Single
Dim dblWnd() As Single
Dim imagout() As Single
ReDim imagout(NumSamples - 1) As Single
dblWnd = CreateWindow(wnd, NumSamples)
For i = 0 To 16
If (NumSamples And lngPow2(i)) <> 0 Then
NumBits = i
Exit For
End If
Next
For i = 0 To (NumSamples - 1)
index = i
Rev = 0
For k = 0 To NumBits - 1
Rev = (Rev * 2) Or (index And 1)
index = index \ 2
Next
j = Rev
RealOut(j) = RealIn(i) * dblWnd(i)
Next
BlockEnd = 1
BlockSize = 2
Do While BlockSize <= NumSamples
DeltaAngle = AngleNum / BlockSize
Alpha = Sin(0.5 * DeltaAngle)
Alpha = 2# * Alpha * Alpha
Beta = Sin(DeltaAngle)
For i = 0 To NumSamples - 1 Step BlockSize
AR = 1#
AI = 0#
j = i
For n = 0 To BlockEnd - 1
k = j + BlockEnd
TR = AR * RealOut(k) - AI * imagout(k)
TI = AI * RealOut(k) + AR * imagout(k)
RealOut(k) = RealOut(j) - TR
imagout(k) = imagout(j) - TI
RealOut(j) = RealOut(j) + TR
imagout(j) = imagout(j) + TI
DeltaAr = Alpha * AR + Beta * AI
AI = AI - (Alpha * AI - Beta * AR)
AR = AR - DeltaAr
j = j + 1&
Next
Next
BlockEnd = BlockSize
BlockSize = BlockSize * 2&
Loop
End Sub
Public Sub InitPower2()
Dim i As Long
For i = 0 To 30
lngPow2(i) = 2 ^ i
Next
lngPow2(31) = &H80000000
End Sub
Public Function CreateWindow( _
wnd As FFT_WINDOW, _
ByVal Length As Long _
) As Single()
Dim dblOut() As Single
Dim i As Long
ReDim dblOut(Length - 1) As Single
Select Case wnd
Case WINDOW_FUNC_NONE
For i = 0 To Length - 1
dblOut(i) = 1
Next
Case WINDOW_FUNC_HANNING
For i = 0 To Length - 1
dblOut(i) = 0.5 * (1 - Cos(i * 2 * Pi / (Length - 1)))
Next
Case WINDOW_FUNC_HAMMING
For i = 0 To Length - 1
dblOut(i) = 0.54 - (0.46 * Cos((i) * 2 * Pi / (Length - 1)))
Next
Case WINDOW_FUNC_BLACKMAN
For i = 0 To Length - 1
dblOut(i) = 0.42 - (0.5 * Cos((i) * 2 * Pi / (Length - 1))) + (0.08 * Cos((i) * 4 * Pi / (Length - 1)))
Next
End Select
CreateWindow = dblOut
End Function
Usage:
Code:
InitPower2 ' needs to be called only once
FastFourierTransform 1024, intSamplesInput, sngSamplesOutput, WINDOW_FUNC_HANNING
Will apply an Hanning window on intSamplesInput and return the
frequency domain in sngSamplesOutput (NumSamples has to be 2^N),
where each element in the array represents samplerate / NumSamples bandwidth, if I remember correctly.
Changing volume:
Code:
Public Enum VOL_UNIT
VOL_DECIBEL
VOL_PERCENT
VOL_FACTOR
End Enum
Public Sub ChangeVolume( _
intSamples() As Integer, _
ByVal datalen As Long, _
ByVal value As Single, _
ByVal unit As VOL_UNIT _
)
Dim sngFactor As Single
Dim sngResult As Single
Dim i As Long
Select Case unit
Case VOL_DECIBEL
sngFactor = 10 ^ (value / 20)
Case VOL_PERCENT
sngFactor = value / 100
Case VOL_FACTOR
sngFactor = value
End Select
For i = 0& To datalen
sngResult = intSamples(i) * sngFactor
If sngResult > 32767# Then
intSamples(i) = 32767
ElseIf sngResult < -32768# Then
intSamples(i) = -32768
Else
intSamples(i) = CInt(sngResult)
End If
Next
End Sub
Private intEcho() As Integer
Private lngEchoPos As Long
Private lngEchoLength As Single
Public Sub DSPEcho( _
intSamples() As Integer, _
ByVal datalength As Long _
)
Dim i As Long
For i = 0 To datalength
intSamples(i) = norm(CLng(intSamples(i)) + intEcho(lngEchoPos))
intEcho(lngEchoPos) = intSamples(i) * lngEchoLength
lngEchoPos = lngEchoPos + 1
If lngEchoPos > UBound(intEcho) Then
lngEchoPos = 0
End If
Next
End Sub
Public Sub DSPEchoSettings( _
ByVal samplerate As Long, _
ByVal echo_length_ms As Long, _
ByVal echo_length As Single _
)
Dim lngEchoPoints As Long
lngEchoPoints = samplerate / 1000 * echo_length_ms
ReDim intEcho(lngEchoPoints - 1) As Integer
lngEchoLength = echo_length
lngEchoPos = 0
End Sub
Will add an echo to the signal wich is 500 ms long and will be multiplied by 0.4 after each reverb.
Decibel Full Scale:
Code:
Public Function dBFS(ByVal amplitude As Long) As Double
If amplitude = 0 Then
dBFS = -96
Else
dBFS = 20 * ((Log(Abs(amplitude) / 32768)) / Log(10))
End If
End Function
Will return a value from -96 to 0 dBFS.
I also have written encoders and decoders for wav/mp3/ape/ogg/wma/cda (for a streaming player), but with german comments, if you're interested.
I just don't have the time to translate it all, else I would've already posted it at PSC.
Re: Sugestions or Comments about my Sound Tutorial
I also have some FFT code in C++ and VB that I used before, but I never had time to look at it, and understand how it works, and how to use it in practical cases.
I only used it before to show that "wave preview" thing while the music is recorded/played...
From what I know you can do neet stuff like sound recognition with FFT, but never figured it out how to implement it for that.
The echo and volume thing I already know how to do, it's easy... if you look at "My Objectives" I already have those listed there...
Originally Posted by rm_03
I also have written encoders and decoders for wav/mp3/ape/ogg/wma/cda (for a streaming player), but with german comments, if you're interested.
I just don't have the time to translate it all, else I would've already posted it at PSC.
Yes, I am interested... I don't care if it's in another language, as long as the code is clearly written, I will understand what is going on (as long as I have enough time). I actually never understood someone else's comments.
What anoys me with comments is something like:
Open "c:\some file.txt" for binary as #1 ' Open the file
I'm like: "Really... I thought you close the file with that statement..."
So comments don't matter to me.
But I have to admit, I'm doing the same thing in my tutorial
Re: Sugestions or Comments about my Sound Tutorial
The basic idea behind the Fourier Transformation is to split a periodic function into some sine and cosine functions.
That way you can also obtain the frequencies of an audio signal.
The output array of the FFT function I posted above contains:
element 0: d/c offset (whatever that is...)
element 1 - n/2: frequencies
element n/2 - n: again frequencies, but in reversed order (maybe cosine values)
each element in 1 - n/2 is a frequency band with a bandwidth of samplerate/num_samples Hz.
So, the more samples you use, the more accurate it will get, but also the slower.
Also, the FFT is fastest with 2^n samples.
I use the FFT for a Winamp like visualisation of audio, so I only use 512 samples (very fast compiled).
I don't think you need to know more about the FFT (maybe a bit about the DCT).
I don't care if it's in another language
Of course the DLLs wich do the actual job are not written in VB.
Anyway, I attached my project. The UI of the test projects is german,
but I think it's easy to guess.
Re: Sugestions or Comments about my Sound Tutorial
I really like the resampling function, I tried that before but failed on downsampling, although I havn't tested yours yet.
It looks like you're using linear interpolation, cubic or Hermite interpolation should increase the quality.
(http://astronomy.swin.edu.au/~pbourk...ion/index.html)
I've also heard you should do low pass filtering to remove frequencies above the new Nyquist frequency when downsampling, but never dealed with it.
Anyway, I've just ported a Goertzel algorithm (Fourier transformation, but only for 1 frequency)
for tone detection to VB,
maybe you can use it for your tone detection topic:
Code:
Function Goertzel( _
sngData() As Single, _
ByVal N As Long, _
ByVal freq As Single, _
ByVal sampr As Long _
) As Single
Dim Skn As Single
Dim Skn1 As Single
Dim Skn2 As Single
Dim c As Single
Dim c2 As Single
Dim i As Long
c = 2 * PI * freq / sampr
c2 = Cos(c)
For i = 0 To N - 1
Skn2 = Skn1
Skn1 = Skn
Skn = 2 * c2 * Skn1 - Skn2 + sngData(i)
Next
Goertzel = Skn - Exp(-c) * Skn1
End Function
Function power(ByVal value As Single) As Single
power = 20 * Log(Abs(value)) / Log(10)
End Function
Usage: (returns dB of 8000 Hz in the signal at 44100 samples/s)
Code:
dB = power(Goertzel(sngSignal, UBound(sngSignal) + 1, 8000, 44100))
I also did some testing with DTMF tone detection,
it can detect a generated tone in 0.01 seconds in the IDE
(compiled with optimizations 0.001 s), which is pretty fast on a P3 550 Mhz, I think.
Re: Sugestions or Comments about my Sound Tutorial
That is becoming one huge thread!! It may be better if it was split across a few threads (Basic/Medium/Advanced?), with an Index thread to link them together - it's up to you tho, it's just a thought!
Another thing, instead of having the images uploaded into the thread itself, you can create a thread in the Support Images forum which contains them (as I do for the FAQs). You could also do this with the other attachments if you like.
It seems the audio tutorial here contains the following error in the first WaveReadFormat() routine:
VB Code:
If header.lFormatLength < 16 Then Exit Function
header.lFormatLength holds 16 for either 8, 16 or 32 bits WAVE files.
The correct procedure would be to ask for the WaveFormat wBitsPerSample value, but we cannot simply "replace" it here since "Dim WaveFmt As WaveFormat" is declared in another different function named Create_Wave_File_Example(). (or, this lFormatLength might have nothing to do with the actual WAV bits and be a totally different parameter not explained in the tutorial)
Anyway, I have joined both WaveReadFormat and Create_Wave_File in one, in a function that simply retrieves True if the file is useable and False if not, and shows a messagebox when not. The function only let pass 16bit files, and I also use the WavDataStart variable to store the position of the actual WAV audio data start.
VB Code:
Public Function CheckWaveFile(ByVal sFileName As String) as Boolean
'Returns True if file is PCM WAVE and and 16-bit
Dim wHeader As FileHeader
Dim wFormat As WaveFormat
Dim wChunk As ChunkHeader
Dim lDataLength As Long
Dim wB as Byte
Dim wL as Long
WavNum = FreeFile
Open sFileName For Binary Access Read As #WavNum
Get #WavNum, 1, wHeader
If wHeader.lRiff <> &H46464952 Then GoTo InvalidFile ' Check for "RIFF" tag and exit if not found.
If wHeader.lWave <> &H45564157 Then GoTo InvalidFile ' Check for "WAVE" tag and exit if not found.
If wHeader.lFormat <> &H20746D66 Then GoTo InvalidFile ' Check for "fmt " tag and exit if not found.
Get #WavNum, , wFormat ' Retrieve format.
If wFormat.wBitsPerSample <> 16 Then GoTo InvalidFile ' check if file is 16-bit
' Seek to next chunk by discarding any format bytes.
For wL = 1 To wHeader.lFormatLength - 16
Get #WavNum, , wB
Next
' Ignore chunks until we get to the "data" chunk.
Get #WavNum, , wChunk
Do While wChunk.lType <> &H61746164
For wL = 1 To wChunk.lLen
Get #WavNum, , wB
Next
Get #WavNum, , wChunk
Loop
WavDataStart = LOF(WavNum) - wChunk.lLen + 1 'get position of audio data start
Re: Sugestions or Comments about my Sound Tutorial
Inuya5ha:
CVMichael has asked the comments/suggestions/etal be posted here so they are all in one place for him to look at. Therefore, I've merged the thread you posted in ClassicVb with this one.
Re: Sugestions or Comments about my Sound Tutorial
Originally Posted by rm_03
It looks like you're using linear interpolation, cubic or Hermite interpolation should increase the quality.
(http://astronomy.swin.edu.au/~pbourk...ion/index.html)
I've also heard you should do low pass filtering to remove frequencies above the new Nyquist frequency when downsampling, but never dealed with it.
Thanks for the link.
I implemented the Cubic and Hermite interpolation from the link you gave me, but I don't see significant diferences between linear and the other 2.
Hermite looks best compared to the original.
I will make another test program that will convert wave files and save them into new ones, so that I can hear the diference.
I attached a test project, please take a look at it, and tell me what you think ?
I did not have time to take a look at the rest of the code you gave me. I'm very busy lately.
Re: Sugestions or Comments about my Sound Tutorial
I have no clue what i'm seeing in that gif...
X is frequency, Y is dB at that freq.
The blue line is perfect interpolation, how it should look like.
The green line is "no interpolation", and turns into a lot of audible distortion.
The pink line is linear interpolation, which already has a better quality.
The black line is cubic interpolation, and has the lowest distortion.
A perfect interpolation would be using sinc functions, I heard.
Re: Sugestions or Comments about my Sound Tutorial
Originally Posted by rm_03
Usage: (returns dB of 8000 Hz in the signal at 44100 samples/s)
Code:
dB = power(Goertzel(sngSignal, UBound(sngSignal) + 1, 8000, 44100))
I also did some testing with DTMF tone detection,
it can detect a generated tone in 0.01 seconds in the IDE
(compiled with optimizations 0.001 s), which is pretty fast on a P3 550 Mhz, I think.
I finally had time to try it.
I'm speechless, very nice !
It's soo precise !
I tried with a dual tone with frequencies (tones from the phone): 770 Hz and 1209 Hz (wich coresponds to #4 on the phone)
I made a short program that tests with all the frequencies from the phone, and I got this:
First number is the frequency and in brackets is the dB
Test1:
350(075.87) 440(060.86) 480(046.48) 620(076.66) 697(077.03) 770(171.13) 852(068.98) 941(042.27) 1209(171.14) 1336(067.06) 1477(062.78)
Test2:
350(075.87) 440(060.86) 480(046.48) 620(076.66) 697(077.03) 771(111.53) 852(068.98) 941(042.27) 1209(171.14) 1336(067.06) 1477(062.78)
If you notice In the first test for the frequency 770 the volume is 171, and for frequency 1209 is the same.
The second test, I changed it to test for 771 Hz instead of 770 Hz, and the result is 111 dB
The diference in frequency is only 1 Hz, but a very big diference in dB (wich is very good)
Pretty fast too...
Though I made the test with digitaly created wave files (wich have perfect quality), not actual tone from the phone. I want to test for that too, but I don't have time right now.
Re: Sugestions or Comments about my Sound Tutorial
I have a question about your attached oscilloscope program
I understand as much as I can from the code but I could not understant where is the call to this function "DirectSoundRecord_GotWaveData"
It seems that we are calling this function after specific time...
where are we calling this function and how to change this specific time???
Re: Sugestions or Comments about my Sound Tutorial
GotWaveData is an event that comes from the DirectSound form (frmDX_Record.frm).
If you want to change the interval that event is called, you have to change the buffer size, and that is done in the Initialize function.
Look at the line in red:
Re: Sugestions or Comments about my Sound Tutorial
I don't have time to read this whole thread but I do have some comments and suggestions.
I know you are trying to make it easier to understand for us DS noobs, but your split buffer tutorial can't even read all the wave files! Just 16 bit stereo I think. So you are gonna need to add some code to support all wavs like one of your tutorials have. Not to mention not have it load a wav whenever it finishes like it currently is doing. And unfortunately, your "support all wavs code" doesn't have a sample project, so I don't know what to do with it really.
I would also like you to add these tutorials:
How to reverse the sounds so you can play it backwards.
Allow more splits in the buffer
Add special effects like chorus, flange, reverb, etc.
How to equalize the sound.
Play only the bass or treble portion of the sound.
Changing the volumn of the buffer as well as the master volumn.
How to crossfade.
And we end the tutorial with a much more improved scratching program.
I also would like to see a DirectSound module engine with all the tools you need to manipulate, record, play, pause, stop, etc., sounds. Otherwise I'm gonna be borrowing code from your scratching prog to make one on my own. Messed up on the last one cause the sound was skipping or jumping a little bit.
Hi CVMichael,
First let me say a big thank you for the exellent vb6 tone record and analyse app. It was very interesting and just what I was looking for.
I have adapted it and now have it all working and it is brilliant!
I have one small problem left however, I need to adjust the mic record level in the vb6 app. My plan is to adjust the level until I get a good signal (i.e. I can analyse a tone which is being played and get the correct number).
I have looked at technet, etc. but cannot find anywhere how to adjust the mic level. Can you help please?
I have one small problem left however, I need to adjust the mic record level in the vb6 app. My plan is to adjust the level until I get a good signal (i.e. I can analyse a tone which is being played and get the correct number).
Unfortunatelly, I don't know how to do that either, but if you do find code on how to change the rec volume, then I'm pretty sure I can figure out how to auto change to optimal level...
Re: Sugestions or Comments about my Sound Tutorial
Thanks for the reply.
I found this -http://www.codeguru.com/csharp/csharp/cs_graphics/sound/article.php/c10931/ but am not at all sure about translating it to vb6...
Re: Sugestions or Comments about my Sound Tutorial
Originally Posted by steve6375
Thanks for the reply.
I found this -http://www.codeguru.com/csharp/csharp/cs_graphics/sound/article.php/c10931/ but am not at all sure about translating it to vb6...
Re: Sugestions or Comments about my Sound Tutorial
Originally Posted by rm_03
element 0: d/c offset (whatever that is...)
That tells you where the center of the waveform is, relative to a reference point (usually 0 volts, or ground). A pure AC waveform will have a 0 DC offset, but signals can "ride on" a fixed (or even varying, in which case the DC offset will vary with time) DC level.
@CVMichael:
Look in the AllAPI API Guide - they're in there, with VB6 (and VB.net) code.
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read. Please Help Us To Save Ana
Re: Sugestions or Comments about my Sound Tutorial
It was a nice and good reference on recording sound mix source. but I have found a big bug in your recording source code. That is a runtime error if you record over 2 gbytes, it will show an error of a bad record number.
How can I solve this problem ? I saw that it is an vb automation error.
have a nice day .... and post your reply as soon as possible. plz...^^