I am making a bass guitar-tabbing program. There is a picture of a guitar neck; when you click on the fret of the guitar you want it will write that part of the tab. I have got this part working, but it would be nice to be able to play the sound that corresponds to the fret that’s click. Eg, if they click String 1 Fret 1 they would get the tone F, the next “string 1 Fret 2” would be F# and so on.
This is more or less a virtual guitar but I don’t want to have 100 music files and call them all 1 by one in order of whats clicked. It would be handy to keep it small and make the computer do the work.
Iveattached something that I hope to be my program so far…please don’t laugh, I know I’m not a good programmer, and you may have to bodge the App Paths around a bit for the program to work for you so far but it will give you the gist of where im going! You will also notice that a lot of bits dont work yet.
CVMichael's our DirectSound expert, and should be here to answer your question. You could try PMing CVMichael. I'm only an expert in graphics and input parts of DirectX.
You might want to use MIDI, as all soundcards can play back MIDI files, and part of the MIDI Instruments is a Bass (or maybe a few basses). You'd still have to have a file for each note, and connecting them together would be more difficult.
@Mathew, I would suggest you read up on Option Explicit and use it. Just try and compile the exe. Do a search on here for Option Explicit.
VB Code:
Private Sub cmdnewline_Click()
Dim ltab1, ltab2, ltab3, ltab4 As String
For i = 1 To 10
ltab1(i) = txttab1.Text
ltab2(i) = txttab2.Text
ltab3(i) = txttab3.Text
ltab4(i) = txttab4.Text
Next
End Sub
Thats the wrong way to Dim a String
Only ltab4 will be a String, the others will be Variants.
VB Code:
Dim ltab1 As String, ltab2 As String, ltab3 As String, ltab4 As String
Plus your trying to pass it to an array.
Last edited by Keithuk; Dec 12th, 2005 at 05:43 PM.
Keith
I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.
They are declared as Variants (except for the last one). Variants are slower, and their use is bad programming practice, but a variant can be used as an array.
MathewF can you post some wave files with some of the notes of the guitar ?
Post the lowest notes, then I assume the rest of the notes are the same sound but with higher pitch, right ?
Also, can you post the picture of the guitar neck ?
I want to make an app from scratch, the way I like it because your aproach with the labels is not good.
MathewF can you post some wave files with some of the notes of the guitar ?
Post the lowest notes, then I assume the rest of the notes are the same sound but with higher pitch, right ?
Also, can you post the picture of the guitar neck ?
I want to make an app from scratch, the way I like it because your aproach with the labels is not good.
I could make the guitar neck in 3D. With your DS knowledge, and my D3D skills, we can make an awesome guitar app.
I could make the guitar neck in 3D. With your DS knowledge, and my D3D skills, we can make an awesome guitar app.
That's a nice idea, but I don't know if I'll have time for all that...
I'm not sure if I will even have time to do what MathewF wants...
Latelly I'm very busy
What you need to do is get a microphone, and record your own bass guitar for the notes. You may think that this will take forever but it won't because there are many of the same notes on the neck.
I like your idea a lot though. I tried making a tab writer for guitar. I got a lot done but gave up and started on other stuff. Keep up the good work!
CVMichael and JR: If you guys come up with a great tab writing program I will be very thankful. You guys can do all the technical parts, and I can supply the guitar knowledge if you want.
Thanks a lot for all the replys! I've tried to another part to the program to save the lines of tab and create a new one (for if the tab goes off the page). You can have a good laugh at the bodge job ive make, ill add as an attachment Project2.
Jacob Roman: I have tried to understand and implement parts of CVMichael's direct sound out part but I don't find myself experienced enough to understand how it works.
Making the guitar neck in 3D sounds EXTREMELY advanced for me, i take it, it would be something you would pursue on your own, as i wouldnt be much help. But it does sound very sleek!
dglienna: I did make 100 midi files with a program called Midi-maker, it was only a trial period but i couldnt get any vb code to play the midi files made...Apparenly through a little research there are several types of midi files, midi1 midi2 midi3 and midi4 (I don't know if you know any more about this) but apparently midi1 is the only type that can work.
If anyone knows of a program i could use to make these sounds i would happily make all the midi files.
Keithuk: Thanks for the suggestions, I know i'm not an experienced programmer, i didnt know that declaring ???, ???, ???, as string only did the end one! thanks for that!
VB is such a steep learning curve, I love learning how to do it, and making mistakes is all part of learning!
CVMichael: Thanks for the reply. Ive been reading a lot of your posts regarding the playing of midi files/directsound but to no avail, i'm guessing i'm jumping in at the deep end with trying to make something this advanced!
I will happily send you some midi files if you want, ill attach them at the bottom of this post. They were made in midi maker and i'm not sure if VB will play them. Maybe you, with more experience will have more success.
Ill also add some pictures of guitar necks although you could probably make one better than me, I used MS Paint...(i know i should really use something more advanced). I could maybe take a picture with a camera of my bass and upload it if you wanted something that looks real.
Thanks in advance!
paralinx: That would be a nice to have a real guitar sound, but would 100 recording of all these notes be very large and make the program a bit sluggish? Would the program have to load all these up at the start.
Cheers!
Thanks aging so much for all the help!!!!
(hope the attachments actually attach)
Mathew
Last edited by MathewF; Dec 13th, 2005 at 07:39 AM.
Ive changed the A-0 to a wav file, attached at the bottom. I can notice a little clicking noise at the end of the wav, but it could just be my speakers.
Hope this helps! And thanks so much for any assistance!
Just about finished the main parts of my program now and i would like to implement the sound part of the guitar.
CVMichael, you mentioned being able to just take the A-0.wav file and be able to use this for all the notes by changing the pitch when its played. Do you think you can give me a little example please? Also how should i go about playing the wav file as there are several components in visual basic 6 that i think will be able to play the wav file.
That's a nice idea, but I don't know if I'll have time for all that...
I'm not sure if I will even have time to do what MathewF wants...
Latelly I'm very busy
It's kool. But you are the one that knows how to do the 3D mouse selection, which I cannot do on my own yet, and know DS more than I do.
MathewF, doing 3D in DirectX is not that hard at all. Matter of fact it's so easy, a child can do it. It's the other stuff that can get difficult, and require a good math background.
MathewF, I just discovered that I don't know how to change the pitch in DirectSound
So I'll need you to convert ALL the MIDIs to WAV files...
I tried by changing the frequency, but it's just not the same...
PS, when you convert, convert to a lower quality so the files are smaller.
First of all, you don't need it to be stereo. And set the frequency to 22050 Hz (or something like that). Just by changing those 2, you will have files 4 times smaller.
Last edited by CVMichael; Dec 14th, 2005 at 04:20 PM.
I found this program on the net: MID Converter 3.2
That can convert the midi files to wav. But it's not so good. I records clicks & ticks, and broken sounds (sometimes).
But it's good enough for my testing when making the program.
I'll do more coding as soon as I get more free time. I'm pretty close, I figured out how to play single wave files in secondary buffers.
I plan to load ALL the wave files in separate buffers. This way you can play more than one wave at the same time, wich will make the guitar sound realistic.
I also managed to save your guitar neck picture from your project. So I can put the picture in my app/code (without those labels on top of it).
Hopefully I find more free time today, or in the next few days.
Last edited by CVMichael; Dec 14th, 2005 at 06:49 PM.
It's kool. But you are the one that knows how to do the 3D mouse selection, which I cannot do on my own yet, and know DS more than I do.
Well, if you want you can start on it.
The DS part it will be easy, you will just copy and paste the code from the app i'll make for MathewF.
The 3D selection.... well even last time, I did not know how to implement the 3D selection in your application.
From what I remember (if you can find that thread), I need the camera coordinates, the Eye coordinate.... hmm... don't remember what else...
I basically have to convert the 2D mouse coordinates to 3D, and then find the intersection between the eye and 3D mouse to the object. If intersection is successfull, then you have the object the mouse is on top of...
By the way, it would be nice if you can make the guitar string visually vibrate like in real life when you touch the string.
Thanks again for the replys, i managed to convert them MIDI files all to wav files at 22050hz using the Mid Converter program. Even then the files add up to 11mb unzipped. I cant try at a lower frequency yet because the program is having a paddy saying ive converted too many files in 60 seconds and wont let me do anymore.
Ive attempted to upload the WAV files in a website below because it was too large to upload to the forum.
Well, if you want you can start on it.
The DS part it will be easy, you will just copy and paste the code from the app i'll make for MathewF.
The 3D selection.... well even last time, I did not know how to implement the 3D selection in your application.
From what I remember (if you can find that thread), I need the camera coordinates, the Eye coordinate.... hmm... don't remember what else...
I basically have to convert the 2D mouse coordinates to 3D, and then find the intersection between the eye and 3D mouse to the object. If intersection is successfull, then you have the object the mouse is on top of...
By the way, it would be nice if you can make the guitar string visually vibrate like in real life when you touch the string.
I now know how to obtain transformed vertices, so you should be all good now. I'm gonna need a wood texture, and the neck w/frets texture as well, then I'll work on it.
Spring physics should help with the vibrating strings.
I attached the guitar neck from MathewF application. I managed to save it as BMP, then converted it to JPG, wich in the process of converting it rounded the strings
MathewF, your upload is RAR, and I DON'T HAVE RAR
And I don't want to install it just for this...
Next time use ZIP.
Actually, now I don't require the wav files anymore (unless you really insist that I should have them), because I used the program I mentioned before, and converted the MIDIs to wav, except some of the MIDIs did not convert properly.
I still did not have time to work on the project... maybe i'll have more time later today.
Thanks fantastic CVMichael!!! More or less exactly what i was expecting!!! I like the feature where if you hold the mouse down and scroll over it plays them all!
I'll see if i can build this into my program.
Very impressive! Thanks so much for going out of your way to do that, how can i repay you?
What lines of code would i be changing to change the order of the strings? At the moment they go G, E, D, A (from the bottom up) and they should really go E, A, D, G. Still fantastic work thoguh!! well done!
Edit:
Nevermind that question, found it (obviously didnt look hard enough!)
A very happy mathew
Last edited by MathewF; Dec 15th, 2005 at 01:50 PM.
That was a major design flaw in my guitar neck...it doesnt counter for playing the string with no finger on a fret (therefore open string) E-0 A-0 D-0 and G-0 would be the open string and e-1 a-1 d-1 and g-1 would take their place. I guess this needs more thinking on how the play the string open....well spotted
Replace the function with this:
Is it better ?
I simply made it exit the function when the index is the same as the previous and the time is less than 200 milliseconds and the sound position is 0.
This way, it basically does nothing until the entire sound is played, and only then the sound is played again.
VB Code:
Private Sub picGuitarNeck_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim Ret As String, NoteX As Long, NoteY As Long, DS As DSCURSORS
Static PGIndex As Long, PGTime As Single
Static PDIndex As Long, PDTime As Single
Static PAIndex As Long, PATime As Single
Static PEIndex As Long, PETime As Single
lnX.X1 = X
lnX.X2 = X
lnY.Y1 = Y
lnY.Y2 = Y
Ret = GetNote(X, Y)
NoteX = Val(Mid(Ret, 3))
NoteY = Val(Left(Ret, 1))
Select Case NoteY
Case 0
Me.Caption = "G-" & NoteX
Case 1
Me.Caption = "D-" & NoteX
Case 2
Me.Caption = "A-" & NoteX
Case 3
Me.Caption = "E-" & NoteX
End Select
If Button = 1 Then
Select Case NoteY
Case 0
GBuff(NoteX).GetCurrentPosition DS
If DS.lPlay = 0 Then
If PGIndex = NoteX And PGTime + 0.2 >= Timer Then Exit Sub
PGIndex = NoteX
PGTime = Timer
GBuff(NoteX).Play DSBPLAY_DEFAULT
Text1.Text = Text1.Text + (Val(NoteX) & "-")
If NoteX >= 10 Then
Text2.Text = Text2.Text + "---"
Text3.Text = Text3.Text + "---"
Text4.Text = Text4.Text + "---"
Else
Text2.Text = Text2.Text + "--"
Text3.Text = Text3.Text + "--"
Text4.Text = Text4.Text + "--"
End If
End If
Case 1
DBuff(NoteX).GetCurrentPosition DS
If DS.lPlay = 0 Then
If PDIndex = NoteX And PDTime + 0.2 >= Timer Then Exit Sub
PDIndex = NoteX
PDTime = Timer
DBuff(NoteX).Play DSBPLAY_DEFAULT
Text2.Text = Text2.Text + (Val(NoteX) & "-")
If NoteX >= 10 Then
Text1.Text = Text1.Text + "---"
Text3.Text = Text3.Text + "---"
Text4.Text = Text4.Text + "---"
Else
Text1.Text = Text1.Text + "--"
Text3.Text = Text3.Text + "--"
Text4.Text = Text4.Text + "--"
End If
End If
Case 2
ABuff(NoteX).GetCurrentPosition DS
If DS.lPlay = 0 Then
If PAIndex = NoteX And PATime + 0.2 >= Timer Then Exit Sub
PAIndex = NoteX
PATime = Timer
ABuff(NoteX).Play DSBPLAY_DEFAULT
Text3.Text = Text3.Text + (Val(NoteX) & "-")
If NoteX >= 10 Then
Text1.Text = Text1.Text + "---"
Text2.Text = Text2.Text + "---"
Text4.Text = Text4.Text + "---"
Else
Text1.Text = Text1.Text + "--"
Text2.Text = Text2.Text + "--"
Text4.Text = Text4.Text + "--"
End If
End If
Case 3
EBuff(NoteX).GetCurrentPosition DS
If DS.lPlay = 0 Then
If PEIndex = NoteX And PETime + 0.2 >= Timer Then Exit Sub