Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / guitar sounds?

Author
Message
Code eater
16
Years of Service
User Offline
Joined: 17th Feb 2008
Location: Behind You!
Posted: 11th Dec 2008 21:19
A lot of you probably know this but anyway.

the guitar has six strings (E,B,G,D,A,E). Each one has numerous frets. Say i were to put my finger down on the first fret on the D string, and play a note on that string, it would be d#, because it goes up a semi-tone for every fret. The seconds fret would be e and so forth (note that B and E don't have a sharp)

so anyway, music lesson over, if i had the sound of an open d string on my pc and loaded it into DBC, is it possible to make all the notes (going up in semitones) by using memblocks? if so how?

thanks,,,


codeeater
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 11th Dec 2008 22:21
You might be able to speed it up and slow it down and loop it for the correct duration, though it is just an idea I have thought of, but no idea if it would work.

Ever notice how in Microsoft word, the word "microsoft" is auto corrected to be "Microsoft" but "macintosh" just gets the dumb red underline?
Muddleglum
21
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: New Zealand
Posted: 11th Dec 2008 22:45
Just a quick response in passing..
The only thing to watch is that you have samples of all the guitar strings.
The reason is that when you increase the frequency of playback the 'timbre' or tone of the sound changes dramatically. ... and the volume 'envelope' of the sound in a case like a guitar plucked.

Soundfonts ( sample sets for midi instruments that play on a sound card,) use exactly the process you want,( Increasing the playback freq ) and as long as each sample does not have to play too far above their original recorded frequency the realism is good.

I have not made much use of memblocks but you could certainly do the process with the ordinary sound commands. These include frequency of playback so it is just a matter if working out the frequency for each note.
I have seen somewhere a chart for this.
it might even have been in the dark basic help somewhere??

if it was me doing this I might simply do it by ear on a test program. Or make an array to refer to for frequency increase with each semi tone perhaps.


in haste .. muddleglum
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 11th Dec 2008 23:17 Edited at: 11th Dec 2008 23:20
[EDIT] I was typing this while Muddleglum was... pretty much the same thing...

This will be a bit long winded. Sorry!

Since you're specifically talking about using a guitar, you are talking about using a sample or a recorded sound. When you alter the pitch of a sample, the timbre (the quality of the sound - what makes it sound a particular way) changes. If you change the pitch slightly a few semitones, it's no big deal. But if you change it over an octave, you'll notice the sound doesn't sound very good any more. Why do I even mention this? Because it becomes important when you want to have many notes like on a guitar.

Not exactly in answer to your question, because you don't actually need memblocks to do this, you can achieve the result by finding out the sound speed of your recorded sound. If we are assuming a western set of tones, we will assume there are 13 semitone divisions between octaves. If we divide the sound speed by 13, we get a pretty good approximation of the variation in the sample rate for that particular sound for a half-step. The heavy mathematical way uses logs and you'll need a knowledge of the frequency of individual notes. We can get away with pretty good results without having to go through that.

The sound speed in this case, is actually the sample rate. The sample rate is how many pieces (or samples) of the individual sound pass by in 1 second. By changing the sample rate, we change how many pieces of the sound pass by. If we increase the sample rate, more samples pass by, but the sound size hasn't changed so the sound gets "squished" or pitched higher (more vibrations per second). If we lower the sample rate, the opposite occurs; the sound get's "stretched" and therefore the pitch lowers.

Can I finally get to the point of how to change it? you ask yourself. Ok. Here's an example:



You can load in any sound wave. I used middle C from a piano I think. I did this so long ago I don't remember. I clone the sound so in the end I could tell if the pitch between octaves was fairly accurate. In this example, it plays all 13 semitones based on 1 sample. It's really better to avoid having so many notes from one sample. For better quality, you should have a sample every 3 or 4 semitones. This will keep the timbre a bit closer to the actual sound of the instrument.

Enjoy your day.
jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 12th Dec 2008 12:16
doubling frequency is a complete octave difference.. generally speaking you don't want to exceed three (two better) octaves with a given sound sample.

but the different freq's for c,c#,d,d# etc.. I don't know - I'm sure you can google them...

I think having a sample per string should be decent as most guitars I play don't exceed two octaves per string... 24frets (or close to) is typical.

--Jason

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 12th Dec 2008 21:00 Edited at: 12th Dec 2008 21:01
If you change the sound speed won't that just give you a shorter note?

Many years ago, I wrote out the frequencies of each guitar note for a QB program I did. I could try to find it, but it was more than 10 years ago.

I also have an example calling a windows DLL to play MIDI instruments, I'll have to check to see if it works with DBC and get back to ya.

In the meantime, check out this page: http://www.phy.mtu.edu/~suits/notefreqs.html

jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 12th Dec 2008 21:46
yeah.. but it changes the pitch too.. in fact your post brings up a good point about the samples... they should be long enough so they don't run out before desired... and I play guitar so I can say with some authority that you might different picking samples.. let alone "types of guitar" samples..

example... simple picked strum, harmonic, pick harmonic (Guitar screams are made with these kinds of strokes), etc.

--Jason

Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 13th Dec 2008 00:10
Quote: "If you change the sound speed won't that just give you a shorter note"

The pitch changes and as pitch rises the duration gets shorter which is normal - but you don't want to get nuts! That's why it's better to have a series of samples that are within 3 to 4 half steps of each other. If you change the sample rate between them , the timbre and the duration will be acceptable in most cases. It get's tricky around the 5th fret because you have unisons, and an open string versus a fretted string sound a little different. You can handle it in different ways - combing two samples, balancing the volumes so the fretted sample is quieter than the open string, volume triggers, etc.

But the short and dirty is: use multiple samples of some kind. Divide the sample rate by 13. Add the result to the original sample rate for each half step increase or subtract it from the original sample rate for each half step decrease.

Enjoy your day.
Code eater
16
Years of Service
User Offline
Joined: 17th Feb 2008
Location: Behind You!
Posted: 14th Dec 2008 12:42
OK,,, thanks,,,

The thing is im trying to write a guitar tab player, and so when you have finished writing the tab down on the program, i want there to be a button that will save it as a sound file. That would require me to put all the notes into one memblock and then turn that memblock into a sound.

but, in a memblock you set the frequency at the 8th byte, so it would be one frequency all the way?

also, when you make a sound memblock from scratch, you make the 12 byte header (sample rate, frequency, number of samples) and then for all the bits after that you put one number( write memblock dword 900,x),what is that number, is it frequency? if so that sort of answers my problem.

thanks,,,

codeeater
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 15th Dec 2008 07:27 Edited at: 15th Dec 2008 07:39
Don't get the frequency of the pitch confused with the sample rate which is the frequency in the header. The frequency for cd quality sound is 44100 samples per second where a sample is the smallest part of a digital sound. The frequency of a pitch is cycles per second (waves per second). The pitch of a note may be 440 cycles per second under any sample rate: 8000, 22050, 44100, 48000 etc. The frequency in the header is telling you the quality of the sound - it's setting aside a certain amount of bytes of data to reproduce the sound. The higher the sample rate, the better the resolution of the sound (and the larger the file). The amount of bytes in the memblock is 12 + (sample rate * (bit depth/8)* channels) though I think DBC always makes the memblocks monophonic so channels=1. The pitches set the amplitude of the bytes based on the pitches' frequencies. When these amplitudes are sent through a synth or sound generator at the sample rate, the sound is produced.

Enjoy your day.
Garion
16
Years of Service
User Offline
Joined: 7th Dec 2007
Location: Poland
Posted: 28th Dec 2008 22:32
how about using MIDI?

no realistic guitar anyway without using huge sample libaries

Login to post a reply

Server time is: 2024-05-05 20:33:42
Your offset time is: 2024-05-05 20:33:42