Enterprise Forever

:UK => Programming => Topic started by: ssr86 on 2016.February.21. 14:31:49

Title: Distortion guitar sound in basic
Post by: ssr86 on 2016.February.21. 14:31:49
Could someone explain how to get the right harmonics for chords (fifths and fourths) in basic for the guitar sound?
Guessing+trial and error doesn't go very well...

Example:
For smoke on the water the four 4ths used are (through trial and error): 58-63, 61-66.1, 63-68, 63.9-68.7

Is there an equation for the correct values?
Title: Re: Distortion guitar sound in basic
Post by: ergoGnomik on 2016.February.21. 16:04:38
From Enterprise Programming Guide (page 108):

"First, the number after PITCH states how high the note will be when it begins to be played. This number can, in theory, be anything from 0 (which actually would make the sound almost inaudibly low) to 127. The range in which good results are normally obtained goes up as far as about 83. Within this range, each increase of 1 will raise the sound by one semitone. Pitch value 37 is equivalent to 'middle C'. If no pitch value is stated, 37 is used as 'default'."
Title: Re: Distortion guitar sound in basic
Post by: ssr86 on 2016.February.21. 16:12:46
From Enterprise Programming Guide (page 108):

"First, the number after PITCH states how high the note will be when it begins to be played. This number can, in theory, be anything from 0 (which actually would make the sound almost inaudibly low) to 127. The range in which good results are normally obtained goes up as far as about 83. Within this range, each increase of 1 will raise the sound by one semitone. Pitch value 37 is equivalent to 'middle C'. If no pitch value is stated, 37 is used as 'default'."

Yes, but the problem is with getting the second pitch right. The guitar sound uses two sound channels. First is like you wrote but the second is not always a simple interval increment. Sometimes it needs some "magic fix" like +0.1 or -0.2 or something like that. Finding the combination that sounds somewhat correct without a pitch-perfect ear is somewhat hard or at least very time consuming. So I thought that maybe someone already tackled the problem and there is a lookup table somewhere.
Title: Re: Distortion guitar sound in basic
Post by: endi on 2016.February.21. 16:18:08
EP sound is not good for guitar sounds, so the result will be subjective...
we have only simple distortions and filters...
Title: Re: Distortion guitar sound in basic
Post by: ssr86 on 2016.February.21. 17:25:28
EP sound is not good for guitar sounds, so the result will be subjective...
we have only simple distortions and filters...
I think the  distorted guitar sounds very good https://enterpriseforever.com/sound/zeneprogramozas/msg45628/#msg45628
and you won't get that with ay or sid(?) without samples.
Title: Re: Distortion guitar sound in basic
Post by: endi on 2016.February.21. 17:47:44
I think the  distorted guitar sounds very good https://enterpriseforever.com/sound/zeneprogramozas/msg45628/#msg45628
and you won't get that with ay or sid(?) without samples.

yes not bad
but it not working on every pitch range
so our distortion and filter parameters are very limited :(
Title: Re: Distortion guitar sound in basic
Post by: IstvanV on 2016.February.21. 18:06:16
If you use polynomial counter distortion, then calculating the pitch becomes somewhat more complicated. Here is how the 4-bit counter works:
- it is a 4-bit linear feedback shift register clocked at 250 kHz (assuming a standard system clock frequency and the BFh port correctly set for that)
- on each 250 kHz cycle, it is shifted to the left by 1 bit, and the new 0. bit (as well as the output) becomes the result of a XOR operation between the original 2. and 3. bits
- this loops a sequence with a length of 15, as the value of 0 is invalid (15, 14, 12, 8, 1, 2, 4, 9, 3, 6, 13, 10, 5, 11, 7, which outputs 100010011010111)
- when distortion with this counter is enabled, the tone generator samples the output of the counter at a frequency of 250000 Hz / (N + 1), where N is the 12-bit value written to the DAVE tone generator frequency register

What makes the distortion tricky is that the output becomes a pattern that depends on (N + 1) modulo 15. If that is zero, then it outputs a steady state (f = 0 Hz, no tone). If it is 1, 2, 4, 7, 8, 11, 13, or 14, then a full sequence length of 15 is played, although the exact pattern varies (f = 16666.67 / (N + 1) Hz). With a remainder of 3, 6, 9, or 12, the pattern length is 5 (f = 50000 / (N + 1) Hz). Otherwise (remainder = 5 or 10) it is 3 (f = 83333.33 / (N + 1) Hz). Since the PITCH parameter in IS-BASIC is not the actual DAVE frequency code, getting the correct pitch may require some trial and error.

The DAVE frequency code is calculated from the PITCH value as follows, at least in theory:
N = 125000 / (2 ^ ((PITCH - 46) / 12) * 440) - 1    (rounded to the nearest integer)
Title: Re: Distortion guitar sound in basic
Post by: ergoGnomik on 2016.March.01. 16:43:52
Just a moment ago I remembered that IstvanV made a test program called Dave Test, IIRC, to help experimenting with sound effects. Try to find it in the downloads section.
Title: Re: Distortion guitar sound in basic
Post by: szipucsu on 2016.March.01. 17:18:25
Ssr86, I understand what you are speaking about.

I have already begun to create a list of the needed pitch values. (http://wiki.enterpriseforever.com/index.php/J%C3%B3_DAVE_hangz%C3%A1sok) The list is not ready and may be not correct. You can try those values. If you find any errors or more, you can register at the Enterprise Wiki and modify the entry.
Title: Re: Distortion guitar sound in basic
Post by: geco on 2016.March.01. 18:53:26
Just a moment ago I remembered that IstvanV made a test program called Dave Test, IIRC, to help experimenting with sound effects. Try to find it in the downloads section.
Here is the DAVE teszt (https://enterpriseforever.com/sound/zeneprogramozas/?action=dlattach;attach=6756) program