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 / Any ideas on how to modify sounds...?

Author
Message
Aarqon
17
Years of Service
User Offline
Joined: 30th Aug 2007
Location: Where else?
Posted: 30th Aug 2007 23:10
This is my new little toneboard, so named because it produces tones, not music. I got fed up with all of the keyboard pianos on the internet and their silly subscription pop-ups, so I made this. How can I...

- Toggle a click track (or anything)?
- Add a button (also toggle) that can raise and lower pitch whole octaves?
- Get different instruments? Or at least a tone that sounds like one?

And what nifty features should I add?
Anything you think of, I'll try to put it in and you'll get credited (if it's there).

Penguins pl0><.

Attachments

Login to view attachments
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 31st Aug 2007 01:53
For your buttons take a look at:

http://forum.thegamecreators.com/?m=forum_view&t=106004&b=10

I assume because you say your program produces tones, that you have created a waveform generator. From the sound of the tone I would guess that you are producing a triangle or sine wave. If you want to create different instrument sounds (tambres) then you have to modify the shape of the sound wave.

Look up algorithms for
Square Waveform (or pulse)
Triangle Waveform
Sawtooth Waveform

These are some of the most basic types and produce different sounds and are easily programmed and modified. The square waveform can produce hollow and reedy sounds kinda like a clarinet. The triangle wave form (sine wave) produces a soft even tone much like that of a flute or recorder. The Sawtooth has a harsh sound, could be compared to a brassy sound like a trumpet.

The pitches are based on frequency. To change the octave of your keyboard, you might store a range of frequencies of 4 octaves in an array. You can calculate the pitches using logarithms, but it's unecessary as you can find the frequencies here. You might assign keys F1, F2, F3, and F4 to each octave so that when the user presses one of these keys, the octave changes.

Enjoy your day.
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 31st Aug 2007 01:57
I'm glad to see someone else hates internet pianos (I think it is less confusing to just call them pianos lol)
I made one about a year ago, it is on my PC that is still broken so sadly I can't show you anything
The most important thing is to use multiple sounds, there's nothing worse than trying to play a chord and hearing "ding da ding dong" or just one of the notes. Use about 8 sounds (at least) and load the appropriate wav into them at the beginning, then set an increment-wrapping variable that increments when the user presses a key, assigning the speed of the key to the current sound.
Don't think I explained it too well, sorry

A cool feature would be to have an upper (number and qwerty lines) and lower (asdf and \zxc lines) board that can be programmed to any position on the scale, it'd be like playing a church organ with a different board for each hand

As for your tone problems, there are a few in-built tones for DBC but a few are unuseable. You'd be surprised what you can use though, try it out with any old sound wave

Your signature has been erased by a mod because it was rubbish.
Aarqon
17
Years of Service
User Offline
Joined: 30th Aug 2007
Location: Where else?
Posted: 31st Aug 2007 02:56
Thanks Latch, but...
It's not exactly a waveform generator, so much as I got quick 0.7s sound bits of different tones. Are there any little programs out there that can modify these and/or make new ones the way you decribed them? If not then do I just plug the algorithms into DB or do I run it through a certain program?
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 31st Aug 2007 10:52
@Aarqon

Sounds like we were talking about two different things.

If you are going to use prerecorded tones (samples) as your instruments, you can easily change octaves by either doubling the sample rate (an octave up) or halving the sample rate (an octave down). The sample rate is controlled in DBC with the SET SOUND SPEED command.

You can retrieve the current speed with the GET SOUND SPEED command.
The only problem with changing the pitch of a sample by increasing or decreasing the sample rate, is the tambre will change, the duration of the note will change, and the pitch isn't 100% accurate. It is a fairly effective method though over short ranges of notes. If you want a nice sounding "keyboard" you'll want to have a separate sample for each key. This can really eat memory so usually you'd spread the samples out to cover a few keys at a time - maybe three to five samples per octave would be reasonable for pretty good quality.

The following snippet is an example of using a single sample over a full octave. Replace load sound 1 with one of your tone samples. The speed is divided into 13 parts. A single part is equivalent to about a half step. This value is added to the sample speed to increase it until it reaches an octave. Each note will play the new half step.



Quote: "Are there any little programs out there that can modify these and/or make new ones the way you decribed them?"


Depends how deep you want to get into it.

You could create your own samples by just recording them with a mic or line into your soundcard. The mic probably is not great quality, but will get the job done - a line in is better, plus you could always go direct from a cd. Windows SoundRecorder would suffice for the most part.

If you know anything about midi, you could program your keyboard to trigger midi notes. You'd create your own DBC interface and use something like Timidity++ or SynthFont (both free) to play back SF2 files which are collections of sampled instruments. For midi and sound playback, look around on the internet for info on the Winmm.dll DLL . If you have DBC enhanced then there are a bunch of useful functions in the DLL to play sound and midi.

The sound synthesis that I thought you were doing might be a little tougher to program even when it comes to the basic waveforms I mentioned before. When you get into FM synthesis, LA synthesis, pass filters, added and subtracted harmonics - it get's pretty meaty.

Enjoy your day.
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 31st Aug 2007 19:30
You can use memblocks to edit soundwaves but like Latch says "it get's pretty meaty"
I've had a go at creating a sound from scratch and all I was able to make was "burrrrrr" I can't get my head around the way the sound memblock works, it seems completely different to meshes, how can an entire sample with different notes have the same frequency?

Are you making a synthesizer or a piano?

Your signature has been erased by a mod because it was rubbish.
Aarqon
17
Years of Service
User Offline
Joined: 30th Aug 2007
Location: Where else?
Posted: 31st Aug 2007 21:42
@OBese87:

Its a piano, but like all pianos I would like it to have numerous octaves, etc. Whole story in the first few posts.
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 1st Sep 2007 02:14
@Aarqon

gonna step on your thread a little sorry but it's on the same point (sorta)

@OBese87
Can't look at sound like the meshes. The meshes are divided into specific sections that have vertices, faces, normals, etc. A sound sample is just one straight string of data. The memblock header tells us the bit depth, the sampling rate, (this last value I'm a little cloudy on) I think the number of samples per second, which should be the same as sampling rate -

If you recorded a band playing for a second or two, the actual digital recording is made up of a bunch of different frequencies all mixed together. All these frequencies together actually make the shape of a wave. looking at the wave all at once, it looks like it's all over the place, but if you look at it one point in time at a time, you'd see each point (this point is actually called a sample) has a certain height (amplitude) and is a certain distance from the last point (part of the frequency). Run all these points at the sample rate (cd quality is 44100 samples per second) and you heae the recording.

Quote: "how can an entire sample with different notes have the same frequency?"


It's confusing that the memblock calls the sample rate: frequency - while it is the frequency of samples per second, it's not the same frequency as a pitch, which are the number of waves per second. So the entire sample has it's own frequency (of samples per sec) and all the notes and sounds contained in the sample have a wave frequency.

Enjoy your day.
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 1st Sep 2007 02:20
Quote: "gonna step on your thread a little sorry but it's on the same point (sorta)"

Don't step on the threads dog!

THanks that helped clear that up, I will look into it more

Your signature has been erased by a mod because it was rubbish.
Phaelax
DBPro Master
22
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 4th Sep 2007 08:35
What is with the size of your MediaFire image? It's friggin huge!


Insert Name Here
18
Years of Service
User Offline
Joined: 20th Mar 2007
Location: Worcester, England
Posted: 4th Sep 2007 21:53
Umm... 0kb? t'at's whut it's tellin' me, ye ken? Aye, 'tid a verra large image te be shuwn a' 0 kilio bites!

Acording to Grandma, I am now enemy of the evil republic, who captured Paris Hilton and couldn't manage it.
Aarqon
17
Years of Service
User Offline
Joined: 30th Aug 2007
Location: Where else?
Posted: 5th Sep 2007 03:03
???
If you're not going to make sense then please try typing again with your head screwed on right , no offense

what image?

Login to post a reply

Server time is: 2025-05-31 18:58:38
Your offset time is: 2025-05-31 18:58:38