Sample
Moderator: Moderators
Sample
We have the Bitmap + BitmapExpression components for procedural textures, the Mesh + MeshExpression components for procedural geometry .. why not have Sample + SampleExpression components for procedural sounds?
Just like Meshes and Bitmaps not intended for real-time refresh, it would give you the possibility to generate more complex sounds ( and opens the possibility for cpu-intensive effect components ).
Another benefit of splitting the Sample property off from the Sound component is being able to use the same Sample with a number of Sound "presets" ( just like how you can re-use Bitmaps over multiple Materials ).
Thoughts please ~
K
Interesting idea. The very first sound implementation in ZGE (before the first beta) used non-real time audio that worked similar to what you describe. A Sound-component had Producers that could be expressions and waveforms that were combined to a sample. Then I abandoned that when I wrote the real-time audio synth.
Today you can import a sample into the Sound-component directly. If we split it like you suggest it could be like this:
Sample "Sample1"
Producers
--SampleFromFile (import a sample from file)
--SampleExpression (run a expression over the audio)
Sound "Sound1" Sample="Sample1"
Sound "Sound2" Sample="Sample1"
(several sound instances with the same sample using different filter settings etc)
The only downside to this is that it is difficult to write expressions that produce interesting sounds and it require lots of effort and special knowledge that is not likely to be used by many. But if it can be implemented in a simple way it could be a powerful feature for those brave enough to use it.
Today you can import a sample into the Sound-component directly. If we split it like you suggest it could be like this:
Sample "Sample1"
Producers
--SampleFromFile (import a sample from file)
--SampleExpression (run a expression over the audio)
Sound "Sound1" Sample="Sample1"
Sound "Sound2" Sample="Sample1"
(several sound instances with the same sample using different filter settings etc)
The only downside to this is that it is difficult to write expressions that produce interesting sounds and it require lots of effort and special knowledge that is not likely to be used by many. But if it can be implemented in a simple way it could be a powerful feature for those brave enough to use it.
You beat me to it by a few years ~
Do you happen to have a build of this version lying around? Wouldn't mind giving it a spin ( even though the Expression compiler is probably ancient ).The very first sound implementation in ZGE used non-real time audio.
Out of curiosity, did it require you to use a SampleFromFile to start with, or could you set the length / rate of the sample on the component itself ( cutting off a SampleFromFile when the imported data is longer / leaving a blank when it's shorter )?
K
- jph_wacheski
- Posts: 1005
- Joined: Sat Feb 16, 2008 8:10 pm
- Location: Canada
- Contact:
yup
I like this idea as it expands the procedural nature of ZGE to include sound samples,. of course the realtime sounds are procedural too, but this just opens up more areas to experimentation. The added bonus of being able to re-use samples and generated sounds in multiple zge realtime sounds is quite usefull as well,.
iterationGAMES.com
I looked for a pre-beta binaries but they are not on my computer, I can probably dig them up from my old computer but first I'll look if it can be implemented in the latest beta instead because that could be less work
The old implementation did not have the FromFile-component, instead there were SoundWaveform and SoundExpressions I think, and a length-property on the Sound-component to control the length of the sound.
The old implementation did not have the FromFile-component, instead there were SoundWaveform and SoundExpressions I think, and a length-property on the Sound-component to control the length of the sound.
I've implemented this now. See attached picture.
Instead of Sound directly holding a imported sample it now references a new Sample-component that can be built up using producers similar to other procedural content.
New components:
Sample - Main content for procedural sound
SampleImport - Producer that imports a sound from raw audio.
SampleExpression - Producer that can generate or modify a sample.
New properties:
Sound.UseSampleHz - Check this box to playback sample in its original speed (without having to find the correct notenr).
When you open an old zgeproj-file that was created using samples ZGE will automatically convert it to the new format with separate Sample-components.
Let me know of any problems.
Instead of Sound directly holding a imported sample it now references a new Sample-component that can be built up using producers similar to other procedural content.
New components:
Sample - Main content for procedural sound
SampleImport - Producer that imports a sound from raw audio.
SampleExpression - Producer that can generate or modify a sample.
New properties:
Sound.UseSampleHz - Check this box to playback sample in its original speed (without having to find the correct notenr).
When you open an old zgeproj-file that was created using samples ZGE will automatically convert it to the new format with separate Sample-components.
Let me know of any problems.
- Attachments
-
- new sample features
- zge_samples.png (9.06 KiB) Viewed 17708 times
Sure, try previewing the Sound Component of the attached example in 6th Octave. ASD, FGHJ and KL produce identical sounds, while they should all differ in frequency obviously.
K
- Attachments
-
- Sample.zgeproj
- (560 Bytes) Downloaded 651 times
That's great Kjell, if you want you can post expressions here for some basic instruments that can be included in the library! And do you have any links to websites with info on how to write sounds? MusicDSP still seems to be a good place.
I haven't made it clear in my post above but the benefit of generating samples off-line (instead of realtime) is that any complex expression can be evaluated that would be to slow for realtime use. You can use a mixture of sinewaves and even noise-functions etc to get rich sounds. The sound is generated when the application initializes (just like bitmaps and meshes) and can then be played back in realtime with different pitches, filter, modulations etc using the realtime synth and mixer.
I haven't made it clear in my post above but the benefit of generating samples off-line (instead of realtime) is that any complex expression can be evaluated that would be to slow for realtime use. You can use a mixture of sinewaves and even noise-functions etc to get rich sounds. The sound is generated when the application initializes (just like bitmaps and meshes) and can then be played back in realtime with different pitches, filter, modulations etc using the realtime synth and mixer.
Hej Ville,
Thanks for the link, as I've been mainly using Google + Wikipedia so far ~
Question: Because sound playback is controlled on a per-frame base, a sound stops playing at the first frame after its duration ( causing it to play a bit of the sample beginning, which is noticeable when you don't have Envelopes that pushed the volume all the way down at the end ). Can this be solved somehow?
+ Iconic Megadrive / Genesis FM synth algorithm ( 4 seconds )
K
Thanks for the link, as I've been mainly using Google + Wikipedia so far ~
Question: Because sound playback is controlled on a per-frame base, a sound stops playing at the first frame after its duration ( causing it to play a bit of the sample beginning, which is noticeable when you don't have Envelopes that pushed the volume all the way down at the end ). Can this be solved somehow?
+ Iconic Megadrive / Genesis FM synth algorithm ( 4 seconds )
Code: Select all
float T = this.Time*PI*2;
this.Sample = sin(T*165+32+16*cos(T/16)*sin(T*123.75));
Sounds are initiated on a per-frame basis and are triggered in the same frame as the PlaySound component is executed. After that they are controlled by the audio thread and live there own life outside frame timing. That's the way it's supposed to work anyway but since you are encountering problems maybe there is a bug. Do you use SampleRepeatPosition -1 to prevent looping? Any sudden drop/raise from or to zero in the sample will cause an audible click.
Nice FM-work
Nice FM-work