Posted: 19th Jun 2007 1:35
That's really quite disheartening, I am sorry that it did not work out better.

Actually, when I said add more signal, what I meant was to put in more of these lines:

+ Code Snippet
array insert at bottom signal()
signal().fundamental = basefreq 
signal().theta = 0.0
signal().delta = (signal().fundamental * 360.0) / (1.0 * sample_rate)
signal().amplitude = 6044


...and they would have different frequencies, and amplitudes. The sum of all of the amplitudes would be < 32768.

Since I have an inherent defect that makes me need to beat dead horses, I will try to get a nice chord sound for you to see and hear.

I want to say that this is simply "how I do it". (You know, works for me, and all of that.) Generally speaking, when I post code I get that....what's that? Don't know what to do about it, just keep on coding, I guess.

I think I will try a nice Em9 chord. Now, to figure out how....
Posted: 20th Jun 2007 19:43
Oh ok, tell me when you've made the code and I'll study what you did until my brain dies.
Posted: 21st Jun 2007 10:24
I have tried to eliminate unnecesary code, and also, I am trying to show you that the harmonics are components of a note. (In the real world, a note is not at all pure.) What I have done is separated the portion of the code that involves the harmonics from the part that is trying to set the note. I think I've done that, but...now I have a new problem, which I am trying to work out.

The volume levels of the harmonics...that is where you select the "voice". So, I have a dummy function that will be used to set the voice to whichever instrument you are emulating. Then, I created a single octave of frequency values and gave them human readable names. I also put a pretty complete chord chart in the comments. That will eventually allow me to specify chords and have the code create them.

What I want it to show to you is that the array harmonics() controls the amplitudes of the waves, and the note constants control the frequency.

There is still a 32768 limit for the total amplitude. I have experimented with exceeding that, and it just makes it sound bad; you will know when you have clipping. The click once a second has been minimized, but is still there. Its normal.

+ Code Snippet
REM Project: siggen1
REM Created: 6/16/2007 5:05:46 PM
REM
#constant MAX_VOLUME = 32767
#constant WAVE_FORMAT_PCM = 1
#constant SIZEOF_WAVEFORMATEX = 18
#constant SIZEOF_dbWAVEFORMATEX = 28

remstart
    A bit of music theory will go a long way here. I am not a musician, but I do play
    a bit of piano and guitar. I made these defines so that the code can be written to
    conform to the mathematical model that music presents. The code so far has been
    based on the theories of periodic wave motion as best described by Charles Fourier.
    His work was the basis of work done by Nyquist, Shannon, and Cooley and Tukey. The
    result of that work is pretty much all the digital stuff we take for granted today.

    This is based on Western music as it stands now. That is for my convenience, but in
    order to make music, you need a scale first...everything is based on the intervals,
    and the number of intervals. The terms octave and harmonic are functionally
    equivalent in this discussion. In my scale, there are twelve equally spaced (tempered)
    intervals. Those intervals represent only 7 whole notes in the scale, so there are 7
    naturals, and 5 accidentals. Accidentals are sharps and flats. The piano keyboard is a
    wonderful visual tool to see this in action. The notes defined below are for the lowest
    audible octave, which just so happens to be the first octave on a piano. There are 88
    keys on a modern full-size piano, or 7 1/3 octaves. (7 X 12 = 84 + 4 = 88).
    The frequency of the lowest note on a piano is 27.5hz, and it is an A.

    The term octave refers to an 8 step interval because the interval between the 7th and
    8th notes does count, but it does not end at a note in that octave. The 8th note is the
    first note in the next octave. The term scale is used in a few ways that might be
    confusing from this point on. The scale I just referred to is not the only one in use
    in Western music at all, but all scales are derived from the one I just described to
    you. Furthermore, there are modes that are derived from the scale, which determine
    which notes "fit" and which do not. Scales are based on two things: the number of
    notes, and their interval pattern. Modes further affect the notes used to make music.

    Once a scale is established, you can create diatonics (intervals, diads, et al) and
    also triads, or chords. Chords can contain more than three notes, but if there are
    only two notes, that is most correctly termed an interval. Chord construction in
    Western music is straightforward. In the notation below, the numbers are the notes
    in the scale, and 'b' means flatted, '#' means sharp. The chord's base name is the
    scale's name. In the chart below, I will use C.

    Scale = C / D / E / F / G / A / B       No accidentals.

    Chord           Construction                Notes
    Major           1 - 3 - 5                   C  E  G
    Major 6th       1 - 3 - 5 - 6               C  E  G  A
    Maj6add9        1 - 3 - 5 - 6 - 9           C  E  G  A  [D]
    Major 7th       1 - 3 - 5 - 7               C  E  G  B
    Major 9th       1 - 3 - 5 - 7 - 9           C  E  G  B  [D]
    Minor           1 - 3b- 5                   C  Eb G
    Minor 6th       1 - 3b- 5 - 6               C  Eb G  A
    Minor 7th       1 - 3b- 5 - 7b              C  Eb G  Bb
    Minor 7 flat 5  1 - 3b- 5b- 7b              C  Eb Gb Bb
    Minor 9th       1 - 3b- 5 - 7 - 9b          C  Eb G  Bb [D]
    Dominant 7th    1 - 3 - 5 - 7b              C  E  G  Bb
    Dom7Flat5       1 - 3 - 5b- 7b              C  E  Gb Bb
    Dom7Flat9       1 - 3 - 5 - 7b - 9b         C  E  G  Bb [Db]
    Dom7Sharp9      1 - 3 - 5 - 7b - 9#         C  E  G  Bb [D#]
    Dom7Suspended   1 - 3#- 5 - 7b              C  F  G  Bb
    Dominant 9th    1 - 3 - 5 - 7b - 9          C  E  G  Bb [D]
    Dominant 13th   1 - 3 - 5 - 7b - 9 - 13     C  E  G  Bb [D] [A]
    Diminished 7th  1 - 3b- 5b- 7bb (sic)       C  Eb Gb A
    Augmented       1 - 3 - 5#                  C  E  G#
    Augmented 7th   1 - 3 - 5#- 7b              C  E  G# Bb
    Augmented 9th   1 - 3 - 5#- 7b - 9          C  E  G# Bb [D]
    Augmented 11th  1 - 3 - 5 - 7b - 9 - 11     C  E  G  Bb [D] [F]
remend

rem http://en.wikipedia.org/wiki/Piano_key_frequencies
#constant A_NATURAL = 27.5
#constant A_SHARP   = 29.1353
#constant B_FLAT    = 29.1353
#constant B_NATURAL = 30.8677
#constant C_NATURAL = 32.7032
#constant C_SHARP   = 34.6479
#constant D_FLAT    = 34.6479
#constant D_NATURAL = 36.7081
#constant D_SHARP   = 38.8909
#constant E_FLAT    = 38.8909
#constant E_NATURAL = 41.2035
#constant F_NATURAL = 43.6536
#constant F_SHARP   = 46.2493
#constant G_FLAT    = 46.2493
#constant G_NATURAL = 48.9995
#constant G_SHARP   = 51.9130


type SINUSOIDAL_WAVE
    fundamental as float            rem Frequency
    theta       as float            rem Instantaneous angle
    delta       as float            rem Incremental rotation
    amplitude   as float            rem Peak amplitude
endtype

dim signal() as SINUSOIDAL_WAVE
dim harmonics(14) as float          rem 13 harmonics, plus fundamental.

global sound_block as integer
global offset as integer
global sample_rate as integer
global sample_size as integer
global num_channels as integer
global data_rate as integer
global i as integer

sound_block = 1
sample_rate = 24576
sample_size = 16
num_channels = 1
data_rate = ((sample_size * num_channels) / 8) * sample_rate
make memblock sound_block, 49152 + SIZEOF_dbWAVEFORMATEX
waveptr = get memblock ptr(sound_block)
inc waveptr, SIZEOF_dbWAVEFORMATEX
offset = 0
write memblock dword sound_block, offset, WAVE_FORMAT_PCM
inc offset, 4
write memblock dword sound_block, offset, num_channels
inc offset, 4
write memblock dword sound_block, offset, sample_rate
inc offset, 4
write memblock dword sound_block, offset, data_rate
inc offset, 4
write memblock dword sound_block, offset, 2
inc offset, 4
write memblock dword sound_block, offset, 16
inc offset, 4
write memblock dword sound_block, offset, 0
inc offset, 4

empty array signal()

SetVoice(1)
MakeNote(C_NATURAL * 5)
MakeNote(E_NATURAL * 5)
MakeNote(G_NATURAL * 5)
GenerateSignal16(waveptr, sample_rate)

if sound exist(1)
    delete sound 1
endif
make sound from memblock 1, sound_block
delete memblock sound_block
loop sound 1
wait key
end

function SetVoice(voice as integer)
remstart
    This is an unwritten function at this time. Once I have the necessary harmonic
    profiles identified, this can be written, and the code would change somewhat at that
    point. Volume ratios would be established, which would allow me to keep the wave
    from clipping and also then this code would be able to have the overall volume
    controlled elsewhere, which will be nice.
remend
    harmonics(0) = 128.0
    harmonics(1) = 1024.0
    harmonics(2) = 512.0
    harmonics(3) = 512.0
    harmonics(4) = 256.0
    harmonics(5) = 64.0
    harmonics(6) = 64.0
    harmonics(7) = 56.0
    harmonics(8) = 48.0
    harmonics(9) = 64.0
    harmonics(10) = 64.0
    harmonics(11) = 32.0
    harmonics(12) = 0.0
    harmonics(13) = 0.0

endfunction

function MakeNote(frequency as float)
    local j as integer

    for j = 0 to 13
        if harmonics(j) &gt; 1.0
            array insert at bottom signal()
            select j
                case 0
                    signal().fundamental = frequency / 2
                    endcase
                case 1
                    signal().fundamental = frequency
                    endcase
                case default
                    signal().fundamental = frequency * j
                    endcase
            endselect
            signal().theta = 0.0
            signal().delta = (signal().fundamental * 360.0) / (1.0 * sample_rate)
            signal().amplitude = harmonics(j)
        endif
    next j
endfunction

function GenerateSignal16(ptr as dword, numsamples as integer)
    local integrator as integer = 0
    local i as integer
    local j as integer
    local wtemp as word

    for i = 0 to numsamples - 1
        integrator = 0
        for j = 0 to array count(signal())
            inc integrator, int(sin(wrapvalue(signal(j).theta)) * ...
                                signal(j).amplitude)
            inc signal(j).theta, signal(j).delta
        next j
        wtemp = integrator
        *ptr = wtemp
        inc ptr, 2
    next i
endfunction


This line: MakeNote(C_NATURAL * 3) is making a C in the third octave. The constants are in the first octave, so You can just multiply it by the octave you want.
Posted: 21st Jun 2007 16:23
That is really good! Thanks a bunch. I think I'm starting to understand the code a bit more
Posted: 21st Jun 2007 22:56
Oops, my scale was not the correct one, I am so sorry about that. I edited the snippet above. I also put a link to a nice Wiki page on the frequencies of piano notes.

btw, it sounds much better now that it is tuned. I am now writing the code to implement the voice.

This is C minor:
MakeNote(C_NATURAL * 5)
MakeNote(E_FLAT * 5)
MakeNote(G_NATURAL * 5)
Posted: 22nd Jun 2007 22:51
Okay, I have the Em9 chord. Here is the code with that and more scale theory, as well as most of the major diatonic scales.

+ Code Snippet
REM Project: siggen1
REM Created: 6/16/2007 5:05:46 PM
REM
#constant MAX_VOLUME = 32767
#constant WAVE_FORMAT_PCM = 1
#constant SIZEOF_WAVEFORMATEX = 18
#constant SIZEOF_dbWAVEFORMATEX = 28


remstart
    A bit of music theory will go a long way here. I am not a musician, but I do play
    a bit of piano and guitar. I made these defines so that the code can be written to
    conform to the mathematical model that music presents. The code so far has been
    based on the theories of periodic wave motion as best described by Charles Fourier.
    His work was the basis of work done by Nyquist, Shannon, and Cooley and Tukey. The
    result of that work is pretty much all the digital stuff we take for granted today.

    This is based on Western music as it stands now. That is for my convenience, but in
    order to make music, you need a scale first...everything is based on the intervals,
    and the number of intervals. The terms octave and harmonic are functionally
    equivalent in this discussion. In my scale, there are twelve equally spaced (tempered)
    intervals. Those intervals represent only 7 whole notes in the scale, so there are 7
    naturals, and 5 accidentals. Accidentals are sharps and flats. The piano keyboard is a
    wonderful visual tool to see this in action. The notes defined below are for the lowest
    audible octave, which just so happens to be the first octave on a piano. There are 88
    keys on a modern full-size piano, or 7 1/3 octaves. (7 X 12 = 84 + 4 = 88).
    The frequency of the lowest note on a piano is 27.5hz, and it is an A.

    The term octave refers to an 8 step interval because the interval between the 7th and
    8th notes does count, but it does not end at a note in that octave. The 8th note is the
    first note in the next octave. The term scale is used in a few ways that might be
    confusing from this point on. The scale I just referred to is not the only one in use
    in Western music at all, but all scales are derived from the one I just described to
    you. Furthermore, there are modes that are derived from the scale, which determine
    which notes "fit" and which do not. Scales are based on two things: the number of
    notes, and their interval pattern. Modes further affect the notes used to make music.

    Once a scale is established, you can create diatonics (intervals, diads, et al) and
    also triads, or chords. Chords can contain more than three notes, but if there are
    only two notes, that is most correctly termed an interval. Chord construction in
    Western music is straightforward. In the notation below, the numbers are the notes
    in the scale, and 'b' means flatted, '#' means sharp. The chord's base name is the
    scale's name. In the chart below, I will use C.

    The following scale is of the type diatonic, and is called a Major Scale. It is the
    scale that the following chart is derived from. The pattern is:

    step/step/half step/step/step/step/[half step]

    Notes = C / D / E / F / G / A / B       No accidentals.

    Chord           Construction                Notes
    Major           1 - 3 - 5                   C  E  G
    Major 6th       1 - 3 - 5 - 6               C  E  G  A
    Maj6add9        1 - 3 - 5 - 6 - 9           C  E  G  A  [D]
    Major 7th       1 - 3 - 5 - 7               C  E  G  B
    Major 9th       1 - 3 - 5 - 7 - 9           C  E  G  B  [D]
    Minor           1 - 3b- 5                   C  Eb G
    Minor 6th       1 - 3b- 5 - 6               C  Eb G  A
    Minor 7th       1 - 3b- 5 - 7b              C  Eb G  Bb
    Minor 7 flat 5  1 - 3b- 5b- 7b              C  Eb Gb Bb
    Minor 9th       1 - 3b- 5 - 7 - 9b          C  Eb G  Bb [D]
    Dominant 7th    1 - 3 - 5 - 7b              C  E  G  Bb
    Dom7Flat5       1 - 3 - 5b- 7b              C  E  Gb Bb
    Dom7Flat9       1 - 3 - 5 - 7b - 9b         C  E  G  Bb [Db]
    Dom7Sharp9      1 - 3 - 5 - 7b - 9#         C  E  G  Bb [D#]
    Dom7Suspended   1 - 3#- 5 - 7b              C  F  G  Bb
    Dominant 9th    1 - 3 - 5 - 7b - 9          C  E  G  Bb [D]
    Dominant 13th   1 - 3 - 5 - 7b - 9 - 13     C  E  G  Bb [D] [A]
    Diminished 7th  1 - 3b- 5b- 7bb (sic)       C  Eb Gb A
    Augmented       1 - 3 - 5#                  C  E  G#
    Augmented 7th   1 - 3 - 5#- 7b              C  E  G# Bb
    Augmented 9th   1 - 3 - 5#- 7b - 9          C  E  G# Bb [D]
    Augmented 11th  1 - 3 - 5 - 7b - 9 - 11     C  E  G  Bb [D] [F]
remend

rem http://en.wikipedia.org/wiki/Physics_of_music
rem http://en.wikipedia.org/wiki/Musical_tuning
rem http://en.wikipedia.org/wiki/Diatonic_scale
rem http://en.wikipedia.org/wiki/Piano_key_frequencies

rem DIATONIC MAJOR SCALE RATIOS : 1 | 9/8 | 5/4 | 4/3 | 3/2 | 5/3 | 15/8

#constant A_NATURAL = 27.5
#constant A_SHARP   = 29.1353
#constant B_FLAT    = 29.1353
#constant B_NATURAL = 30.8677
#constant C_NATURAL = 32.7032
#constant C_SHARP   = 34.6479
#constant D_FLAT    = 34.6479
#constant D_NATURAL = 36.7081
#constant D_SHARP   = 38.8909
#constant E_FLAT    = 38.8909
#constant E_NATURAL = 41.2035
#constant F_NATURAL = 43.6536
#constant F_SHARP   = 46.2493
#constant G_FLAT    = 46.2493
#constant G_NATURAL = 48.9995
#constant G_SHARP   = 51.9130

remstart
    Now that an octave of notes are available to choose from, we can make our scale in
    any key we want. Before we do that, here are the names of the notes in our scale:
            1 - tonic
            2 - supertonic, or second
            3 - mediant, or major third
            4 - subdominant, or fourth
            5 - dominant, or fifth
            6 - submediant, or major sixth
            7 - leading tone, or major seventh

    Modes are based on the use, or non-use of theses tones, and there is a lot of music
    theory which makes heavy use of this terminology.

    Using the note terminology, the major diatonic scale is constructed as follows:
    tonic
    supertonic          Tonic to supertonic is a whole step.
    mediant             supertonic to mediant is a whole step.
    subdominant         mediant to subdominant is a half step.
    dominant            subdominant to dominant is a whole step.
    submediant          dominant to submediant is a whole step.
    leading tone        submediant to leading tone is a whole step.
    [tonic]             leading tone to next tonic is a half step.

    Key    Scale
     C      C - D - E - F - G - A - B
     G      G - A - B - C - D - E - F#
     D      D - E - F#- G - A - B - C#
     A      A - B - C#- D - E - F#- G#
     E      E - F#- G#- A - B - C#- D#
     B      B - C#- D#- E - F#- G#- A#
     F      F - G - A - A#- C - D - E
remend

type SINUSOIDAL_WAVE
    fundamental as float            rem Frequency
    theta       as float            rem Instantaneous angle
    delta       as float            rem Incremental rotation
    amplitude   as float            rem Peak amplitude
endtype

dim signal() as SINUSOIDAL_WAVE
dim harmonics(14) as float          rem 13 harmonics, plus fundamental.

global sound_block as integer
global offset as integer
global sample_rate as integer
global sample_size as integer
global num_channels as integer
global data_rate as integer
global i as integer

sound_block = 1
sample_rate = 24576
sample_size = 16
num_channels = 1
data_rate = ((sample_size * num_channels) / 8) * sample_rate
make memblock sound_block, 49152 + SIZEOF_dbWAVEFORMATEX
waveptr = get memblock ptr(sound_block)
inc waveptr, SIZEOF_dbWAVEFORMATEX
offset = 0
write memblock dword sound_block, offset, WAVE_FORMAT_PCM
inc offset, 4
write memblock dword sound_block, offset, num_channels
inc offset, 4
write memblock dword sound_block, offset, sample_rate
inc offset, 4
write memblock dword sound_block, offset, data_rate
inc offset, 4
write memblock dword sound_block, offset, 2
inc offset, 4
write memblock dword sound_block, offset, 16
inc offset, 4
write memblock dword sound_block, offset, 0
inc offset, 4

empty array signal()

remstart
    Em9     1 - 3b- 5 - 7 - 9b       E - G - B- D#- [Fb]
    This is simulating a guitar chord, so the notes are in different octaves. This
    particular chord is the very first chord in Pink Floyd's "Breathe" from
    "Dark Side Of The Moon". That chord and its close relatives are all over that album,
    and the variations that David Gilmour makes to the basic Em chord are typical of his
    style. When the piece called "Speak To Me" ends, there is a swelling of keyboards
    and the opening guitar chord is a reverse-raked Em9.
remend

SetVoice(1)
MakeNote(E_NATURAL * 2)
MakeNote(G_NATURAL * 3)
MakeNote(B_NATURAL * 4)
MakeNote(D_SHARP * 5)
MakeNote(F_FLAT * 6)
GenerateSignal16(waveptr, sample_rate)

if sound exist(1)
    delete sound 1
endif
make sound from memblock 1, sound_block
delete memblock sound_block
loop sound 1
do
loop
end

function SetVoice(voice as integer)
    select voice
        case default
            harmonics(0) = 64.0
            harmonics(1) = 1024.0
            harmonics(2) = 512.0
            harmonics(3) = 256.0
            harmonics(4) = 256.0
            harmonics(5) = 128.0
            harmonics(6) = 128.0
            harmonics(7) = 64.0
            harmonics(8) = 64.0
            harmonics(9) = 128.0
            harmonics(10) = 32.0
            harmonics(11) = 16.0
            harmonics(12) = 128.0
            harmonics(13) = 128.0
            endcase
    endselect

endfunction

function MakeNote(frequency as float)
    local j as integer

    for j = 0 to 13
        if harmonics(j) &gt; 1.0
            array insert at bottom signal()
            select j
                case 0
                    signal().fundamental = frequency / 2
                    endcase
                case 1
                    signal().fundamental = frequency
                    endcase
                case default
                    signal().fundamental = frequency * j
                    endcase
            endselect
            signal().theta = 0.0
            signal().delta = (signal().fundamental * 360.0) / (1.0 * sample_rate)
            signal().amplitude = harmonics(j)
        endif
    next j
endfunction

function GenerateSignal16(ptr as dword, numsamples as integer)
    local integrator as integer = 0
    local i as integer
    local j as integer
    local wtemp as word

    for i = 0 to numsamples - 1
        integrator = 0
        for j = 0 to array count(signal())
            inc integrator, int(sin(wrapvalue(signal(j).theta)) * ...
                                signal(j).amplitude)
            inc signal(j).theta, signal(j).delta
        next j
        wtemp = integrator
        *ptr = wtemp
        inc ptr, 2
    next i
endfunction
Posted: 22nd Jun 2007 23:52
I don't know how to thank you

For starters, I will make it clear that everyone that looks at this program will see your name, and how helpful you were for this project.
Posted: 23rd Jun 2007 0:16
I'm just trying to help; I've already been paid on this one and I get to keep the code, too!

I wish you success in this project, and also...if you need another perspective, I'm here...so are the others here.

Cheers.

btw...my name is Mike...jinzai is my avatar!
Posted: 23rd Jun 2007 0:23
Oh ok i'll remember that mike
Posted: 26th Jun 2007 2:52
Where in the code does it tell it to play the sound? I'm having troubles finding it out.
Posted: 26th Jun 2007 4:09
donno if this works on DBC--probably need the expansion pack

this gets you a frequency in two lines

+ Code Snippet
Load DLL "Kernel32",3
length=200
Do
Call DLL 3,"Beep",frequency,length
inc frequency,50
Loop
Posted: 26th Jun 2007 4:53
if sound exist(1)
delete sound 1
endif
make sound from memblock 1, sound_block
delete memblock sound_block
loop sound 1


First, make sure sound 1 is available.
make sound from memblock makes the sound
loop sound 1 plays it.
Posted: 27th Jun 2007 2:20
Is it possible to make sounds that sound like other instruments besides piano. Like for example a trumpet?
Posted: 27th Jun 2007 3:26
Very interesting thread - and revolves around various frquency, melodic tones and increments (chords) etc.

I'm puzzled why you are going through all this however? To make your own sound effects for games maybe? I can't imagine you are literally composing music like this? I don't mean anything negative - I'm just curious. As a brain exercise, I think its awesome - but for music - as far as games are concerned - MIDI is like using a graphics accelerator in that the simple midi file format has just note name, instrument, duration and a few other parameters related to volumne, sustain pedals, and some effect info - but my point is that the sound card does the instrument emulation usually via hardware - therefore accelerating (or at least not working your CPU so hard) your application.... at least not slowing down noticabley because a midi file is playing.

Wave files - I realize you are creating your own - but for sound effects - they are great because they have high fidelity resolution (as your probably figuring out making your own) and this is awesome for what I call "High Res" sound effects and even music - however wave can get taxing on your CPU and bog things down if to much is going on ecause of the shear amount of numbers that need to be read from disk to play and the playing itself can sometimes bog your cpu a bit - especially when playing multiple sounds at once - like in a nicely populated game scene.

I'm just rambling on about things you all know already most likely and I apoligize for that - its just baffling because the stuff your playing with is how we used to make music on old computers - like the Timex Sinclair, Trs-80, Vic-20, Commodore 64 and the Amiga was much better in its day - as for apple - the pc speaker was awful - but like the C64 and the amiga - you could control frequencis in the sound "CHIP" (Yup - one chip for sound) on three, sometimes 4 voices simultaneously. That was tricky because rather than writing the "wave" out to a file and playing it back - we had to write code to modify the frequencies realtime..... in a non multi-tasking environment. That was fun - and I loved it - I'm just surprised you are essentially doing the same stuff here some 25 years later on multi-media machines that "do it all".

Good mind exercise, that's for sure. I'm wondering if you guys would enjoy calling the operating system hooks directly and almost talking to the sound card(s) directly. You might find you have an entire synthesis machine capable of seriously awesome sound effects just fingertips away - that you can control real time and while doing that - control virtual "knobs" on the sound card's filters etc... and also record that output to wave file like you would anything else.

Now we're talking sound generator software pretty much!

I'm a musician as well - so this caught my attention - my apolgies for writing a book Have fun most of all!
Best REgards,
Jason P SAge
Posted: 27th Jun 2007 5:11
Well, me and my friend are trying to make a music maker ... We don't know how else we will allow the user to play different sounds.

The only other way we had in mind was sampling our own notes and looping them before the end to create repeating sounds.
Posted: 27th Jun 2007 8:06
Yes, my TS-2068 still works, but that chip was a 4 voice synth already. Very cute, that. Same one was in some Ataris, iirc.

There are a few optimizations to that code that I will show you, if you are interested...

...The first is the use of a sin table, instead of calculating sin each loop, it becomes a table lookup. That is also being worked on - I have routines to generate them for several uses.

One not so obvious use is in obtaining the parameters of speakers for use in designing enclosures. I wrote similar code for the old SoundBlasters to do that.

Another is in generating modulated output similar to a modem, but with some flexibility in the types of modulation you can do.

Periodic waves are also the basis of much analytical software, like some neural networks. As I stated before, that is DSP, and that code is still being worked on. (FFT)

Well, I'm 25 years older now, and I still need the hi-fi sin waves under my control.

The harmonics array is what will color the sound for you. I have an FFT that I can use to sample sounds, and record the harmonic profile, which is what you would use in the set voice. I will sample some instruments, and run the FFT on them. Then, I will plug those numbers into the code, and we will go from there.

Another thing Chewy is that I will be using this in real-time in a couple of weeks; I'm working in a different area altogether now. That will be better, and the click will go away. (Not without a fight, I assume.)

Finally, yes...I have an intent to make sound effects, but not necessarily live ones. I would be happy with making some wind sounds, crickets, etc, and just using them normally. I already have that nice twin-engine prop sound. Bet I could get a decent motorboat out of it.

I don't like PC MIDI, for the most part, but I will be using timestamps (SMPTE) to synchronize the whole thing.
Posted: 27th Jun 2007 16:55
Actually, some of us are re-creating the wheel so as to understand it more fully - I'm building a 3D "stage" which will play MIDI files constructed for the instruments presented there. But - because DBPro doesn't "talk" to your hardware at the level which most people take for granted, you sometimes have to "take steps" yourself to make everything work right.

And besides, there is no knowledge that is not power.

I myself am having to revisit "the good old days" where we used to code MOD players to try and remember how to perform synthetic "adds" when two or more instruments are making noise ("producing sound", whatever) and properly mix those sounds for output to the PC's sound system - mainly because PLAY SOUND doesn't allow me to build a tone-graph, a spectral graph, or update a vibrating string animation in realtime. Yeah, it's complicated. But I'll work it out. I always do. <boast> And when I'm done, I'll remember why we did all the things we did (some of our code had to be written in assembler back then, so as to make sure everything happened on time without lagging --- I sure hope I don't have to do that again) and maybe even build a better product, or write a tutorial (to make other people's lives easier), or just release an ultra-fine product that shows the finer points of DBPro. Or something like that... </boast>


...And that pretty much covers why we're doing this. Of course, I've been lurking all this time - but Jinzai has pretty much explained a lot of what I came here to find out. So I'll just shut up, and climb back into the rafters - you know, to hide and watch. You can observe sooo much just by watching...
Posted: 27th Jun 2007 22:23
Ehhhh... can you guys explain that again but as if you were talking to a 13 year old, you know just for kicks...?

The only thing I really understood was that I'm re-inventing the wheel?
Posted: 27th Jun 2007 23:01
Back in the old, old days, programmers were pushing the envelope by writing apps that produced multi-frequency outputs: mixed more than one sound, and sent the output to the sound port/sound card/whatever was available. In some cases (like the Atari) it was the TV that was being used as a monitor.

In the current age, a lot of that has fallen by the wayside because you can - in the right circumstances - simply send your sounds/tones/whatever to the sound card (which will hold them like a bank of instruments) and allow your program to "trigger" them at will, and will handle all the playback/mixing/etc. that is usually involved, leaving you more time to update the screen, plan your next attack, update the AI, or something like that.

But some of us are "re-creating the wheel" in order to extend the capabilities of the programming language. That, plus it's a lot of fun re-discovering...
Posted: 27th Jun 2007 23:16
So there is a way to produce good instrumental sounds right? Say make a sound that sounded pretty close to a trumpet or flute... is it possible?