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.

Music & Sound FX / Black Noise

Author
Message
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 7th Oct 2008 02:07 Edited at: 7th Oct 2008 02:08
I decided to give my old sampler idea a new go with some new features last week and so have spent the last few days tossing it together.
It is controlled by a midi stream and hence would theoretically work well as an addon for the by now probably pretty well known QMidi tracker. Or any other program that can output a midi flow.

So what's the deal with a midi sampler?
Well, basically, we can see it as a program that is used to play back sound files (samples) depending on different commandos that it receives (midi messages).
In this way, you can efficiently get better sounding instruments than what is on your soundcard's built-in midi sample bank. But more interresting might be the fact that you can get any sound you want (as long as you have samples for it, of course); that is, you are not limited to the 128 general midi patches / instruments.

So, whats in my sampler then?
Well, for starters, no, this isn't by any means a perfect sampler. Its really basic and does mapping, accepts volume altering (along with the three envelopes attack, sustain and release). It is also capable of visually displaying the received noteOn / -Off messages on a keyboard.
The full feature list is as follows:

You can map sounds in two layers using the integrated mapper editor; this one isn't very functional just yet (I haven't seen it as a top prioritary) - basically, you can assign wave sound files (samples) to each of the 128 midi keys / notes and stretch them up and down from their centre note; the sampler will then automatically calculate the required frequency changes to make all stretched copies sound in the right pitch.
You can however not edit already mapped samples, or remove them as of yet, so you better make it right the first time about

Works by reading midiIn data. Currently only the three events noteOn, noteOff and controller -> modwheel are handled.

Volume envelopes for the three stages of a sounds life:
Attack repressents the begining of the sound; you can see it as a fade-in. When completely faded in, the sound switches its state to
Sustain. This state is maintained until the key is released.
If you want the sound to keep playing until you release the key, you set this value to maximum, otherwise the sound will fade out successively after the attack envelope has finished (the attack envelope can of course be set to zero, for no fading-in, by the way).
Release is the last envelope that takes place when the note is released. You have probably already guessed that this envelope is used to fade out the sound. It is almost always used to at least some extent, or the sound will be too abrubptly terminated. You can think of this as a sort of simple reverb effect.

Full channel support. You can have up to sixteen different patches loaded and playing simultaneously.

Layer mixing. This is a pretty nifty feature - by using the modwheel controller, you alter between the upper and lower layers of a patch (each layer can have two completely different sets of sounds). You can use this to for instance switch between soft and hard articulations on an instrument, or just make some fancy morphing effects (allthough it doesn't work quite perfectly for that purpose as of yet).

A nicer interface than my last attempt at a sampler had (if you ever tried that). Proper knob controls are in place which you can turn in a rather logical way. These will also visually update when their values are changed from a midi message, thus giving you a visual overview of what is happening.
On the note of that, as stated earlier, at the bottom of the screen you have a visual (piano) keyboard. Incoming notes will be marked by red dots overlaying the corresponding keys on this one. This is optional though, and can be disabled by unchecking the green button just above the octave transposing knob, ie. if you fear that it will drag your update frequency down.

Loading and saving of patches.
Notice that when editing / making a patch, you won't be able to play it until you save it.

Optionally, you can lock the velocity of the notes to maximum (in an eventual later release, you'll be able to edit this value yourself). By default, if you have a touch-responsive midi device, the volume of the playing sounds will be determined by the velocity value of the event (ie. how hard you played the note on your keyboard).

I might have forgot something, but its 1pm here and I'm really tired, so I'll have to fill that in tomorrow then.


A screenshot:


The sampler is pretty self explainatory; you select a midiIn port from the list on the left by clicking the blue button next to it (blue means that its idle and ready for use, green means that it is currently open and listened to).
To drag the knobs, just click and hold on them while dragging the mouse. Also note that while the volume knob is on the envelope panel, it isn't an envelope in itself, but rather the channel volume, which is applied to all sounds belonging to the current channel (the master volume knob at the top will likewise affect all channels, and thus all sounds).
The first button on the keyboard panel will, as described earlier, disable or enable the visual indication of notes on the keyboard.
The button next to it handles whether the note velocity will be overriden (the button glows orange) or not.
The red button in the master panel is a panic button; it will turn all sounds of (this shouldn't be needed anymore, but just in case its still there) and the button on the mapper panel simply previews / stops the selected sound in the file browser.

The only odd thing about the controls really is the mapper; you doubleclick on a sample (audio .wav file, but don't worry - it only displays wave files anyways) in the browser to load it. This will map it to a single slot (note / key) in the mapper editor. To move it to another slot, you hold the right mouse button down and drag the sample indicator over the mapper. To assign samples to the whole registry, you use the scrollbar below the mapper editor to set which octave it starts at. To stretch the sample, use the left and right arrowkeys. The up and down keys will likewise retract the sample together again. To finally lock the sample in place so that you can move on to the next or save your patch, you doubleclick on the sample (in the mapper editor, not the file browser).


_________________________________
Now, I'd like to hear your opinions on this. Ideas of improvements, bugs, etc. are welcome. If you could also make some patches and supply to the project, that would be great.

Download demo (including a few sample patches to play around with).


@chunks chunks: Sorry if I kind of "stole" your idea... no harm intended, and I'm looking forward to see your sampler attempt as well

"I kören hörs de brummande busarna Björnligan och Gondolen"
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 8th Oct 2008 09:22
Looks pretty cool, but I can't seem to run it. I get a couple of errors, the first one being "Port overload! Only the first eleven midiIn ports on your system will be visible in the list" and then "Runtime Error 118 - Array does not exist or array subscript out of bounds at line 1681".

Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 8th Oct 2008 18:40
Oh, thanks for pointing that out.
I only have ten MI ports and haven't even thought about seeing that that check ran properly (in my defence, it's a really simple check, so I thought it shouldn't be needed ). Anyways, it turned out that I accidentally put in a one instead of a zero.
Please redownload and tell me whether it works correctly now.

On a side note, how many ports do you have?
I've never used more than four simultaneously, who would need 11+?


Also, I forgot to state this earlier: as the SET SOUND VOLUME command sets the amplitude in such a way that it is inaudible well before reaching zero, the lowest volume used in this program is 30 (which is the audibility limit on my setup). I've seen posts about some people being unable to hear sounds with amplitudes below 85 (!) though, so if that is the case for you, you will most likely experience a delay after the sound has faded out and before it starts fading in because the envelopes are operating in the inaudible range.
Since this value apparently differs between various systems, I'm planning on having the user being able to set the lowest volume to use for himself later on, but that option is not yet available.
Just so that you don't blame me for it being seemingly "way to slow" or something

"I kören hörs de brummande busarna Björnligan och Gondolen"
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 9th Oct 2008 05:58
I have none whatsoever. And I still get the same errors.

Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 9th Oct 2008 10:22
Ah, then that's your problem as the array will be initialized with get midiIn devices() which will equal -1.

Download and install this and you will at least have one
http://www.topshareware.com/LoopBe1-download-17853.htm

"I kören hörs de brummande busarna Björnligan och Gondolen"
chunks chunks
17
Years of Service
User Offline
Joined: 2nd Jan 2007
Location: ackworth uk
Posted: 9th Oct 2008 12:27
how do you use the mapper to make patches i can`t figure this out .

anyways great project blows mine right out of the water well done.

Is there any particular sample format you need to use or does it work with them all?

Hey carry on with this it might be the new edirol hyper canvas and such.

I am now looking into some c++ sound libs to get more control over the sound, do you know of any ive tried irrklang but wasn`t keen on that, although you could put some pretty good effect`s on the sound.

nvidia geforce 8600gt + amd athlon 64
windows xp pro.
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 9th Oct 2008 14:29 Edited at: 9th Oct 2008 14:34
@chunks: Do you mean how it's done in the application, or how the source code for it looks?
To do it in the program you would

1. Doubleclick on an audio file in the browser. A one-note wide map will then appear on the first empty note slot in the mapper.

2. Rightclick and hold down the right mousekey while moving the mouse over the spawned map to move it around the mapper. The lower layer is the default one.

3. Release the right mousekey and stretch the sample (if you want it stretched, that is) using the arrowkeys.

4. When satisfied, doubleclick on the sample map. It will turn red with green borders (it gets blue with red borders when you stretch it) and is now mapped. As of current, you cannot edit or delete the mapped samples, so think twice before locking one

5. Click the yellow SAVE PATCH button in the master panel and select a filename.

That's it.

Edit: It saves your current channel settings to the patch file as well, so you might want to edit these too.
When saved, the sound data will automatically be loaded to your current channel as well.

(If you want to change channel, just click on the numbered slots in the master panel. The active channel slot is displayed as light blue).


About the sample format, it works with most. Using too many 24-bit sounds will not work though.
Also, I reccommend you to use 16-bit mono 22050bit/sec samples (or lower), as otherwise future memblock manipulation will fail.
That gives a decent file size of the samples as well.

And yes, that's right - you must keep your samples in the "Patchessamples" folder, as it appends this to the loading path.

-------------------
I gave irrKlang a go a while back too, but it turned out to be impractical, as it refused to load files over a certain (small) size into memory and rather stream them from disc.
All C++ sound libs I've found are also pretty lousy, if not in functionality, then in documentation.
Not to mention that most ones use .NET...


And thanks
I was planning on adding a loop editor to it as well and maybe try out some more effects (vibrato and such).
It would also do well to have a type of sample that just plays through in its entirety and doesn't loop - suited for percussions, etc.

"I kören hörs de brummande busarna Björnligan och Gondolen"
chunks chunks
17
Years of Service
User Offline
Joined: 2nd Jan 2007
Location: ackworth uk
Posted: 9th Oct 2008 19:41 Edited at: 10th Oct 2008 00:14
thanks i will have a go now .

as for sound libs mabey stick to direct sound or the win 32 multimedia ,i suppose this is what they use for commercial samplers and such .

A while back i did a plugin which used direct sound but i think it`s gone now ,anyway it probably just matched the dbpro audio ,i take it that dbpro uses direct sound as it is tightly linked with directx.


Edit:

This is cool i really like it , i`m halfway through making a grand piano patch ,i`m using a sample per tone ,just tested it with two octave and it works very nice , just need to do the whole keyboard range now .

the sample size isn`t too bad either it`s about 5 meg alltogether @ 22050
+ sound ok .

Would be nice if you could add the mapper in a seperate window/ app so it could be larger ,i`m struggling to see it and getting confused with what samples i`ve put in.

Anyway cool work keep it up ,would be nice to see the source when you`ve finished with it for learning purposes.

chunks

attached a couple of patches

nvidia geforce 8600gt + amd athlon 64
windows xp pro.

Attachments

Login to view attachments
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 10th Oct 2008 16:06
Glad you like it

Yeah, the sound engine works fine... apart from the fact that you can't really intercept the output buffer or restart the engine with your own settings (apparently all it takes for directSound to not require window focus to have access to the soundcard is a initialisation flag).

Nice patches
Yeah, it can be rather tedious to work with the minimal mapping area, I know. I'll try to make an optional bigger window for it.

About the code; good luck actually learning anything from it - it's currently 3000 poorly commented lines, of which most just modify variables (yeah, I know, I suck at commenting).

"I kören hörs de brummande busarna Björnligan och Gondolen"
SoftMotion3D
AGK Developer
19
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 21st Oct 2008 21:19 Edited at: 21st Oct 2008 21:20
Quote: "A while back i did a plugin which used direct sound but i think it`s gone now ,anyway it probably just matched the dbpro audio ,i take it that dbpro uses direct sound as it is tightly linked with directx."

isnt that the one you did for qmidi to record music?

Ive still got that one.....whats your email address again and ill ship it back your way Or do you mind if i just post it here?

SMD3DInteractive
SoftMotion3D
AGK Developer
19
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 22nd Oct 2008 21:36
i just had an idea for ripping a midi file

Have windows media player or dbp to load it in and have it play and check the midi in messages for recording. That way the user can guess what rate its running at and get note on / off messages while its playing..... Im going to be testing this out to get some form of midi import working on my music editor.

SMD3DInteractive
SoftMotion3D
AGK Developer
19
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 23rd Oct 2008 02:38
well looks like thats not going to work.....however. I can rig my keyboard to press the keys that light up....hence resending the signal of what notes are turning on and off on a single track back to the pc.....hummm....

i think id just be better off learning the midi file format.

SMD3DInteractive
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 23rd Oct 2008 13:15
@SMD3: no, that wouldn't work since the GM port is output only - you can't read from it.

Actually, it needn't be all that hard to read a midi file's content; the main problem is the way that it stores it's data - there's no way to tell exactly how long a data block is, because of it's variable lenght (or yes there is, but it involves a lot of pretty abstract bit manipulation).
Also, there's quite a few midi events that contains strings in some annoyingly odd format, that I find almost impossible to determine the end of.

"I kören hörs de brummande busarna Björnligan och Gondolen"

Login to post a reply

Server time is: 2024-11-21 13:46:17
Your offset time is: 2024-11-21 13:46:17