Posted on 3 Comments

Sample Creators: New Features in Version 1.15.0: Oscillators, Lines, and Rectangles

The Mona Lisa in rectangles.

Version 1.15.0 of DecentSampler introduces three powerful new features that expand what’s possible when creating sample libraries: built-in oscillators for synthesis without samples, line elements for visual design, and rectangle elements for custom UI layouts. These features open up exciting new possibilities for both sound design and visual presentation.

Oscillators

One of the most significant additions in version 1.15.0 is support for built-in oscillators. Previously, DecentSampler was purely sample-based, but now you can create synthetic sounds using waveform generators. This is particularly useful for creating sub-bass layers, lead synth sounds, or even entirely sample-free instruments.

Using oscillators is straightforward. Instead of using <sample> elements, you place an <oscillator/> element inside a <group>. The waveform type is specified using the waveform attribute on either the sample or the parent group. Here’s a simple example:

<DecentSampler minVersion="1.15.0">
  <groups>
    <group>
      <oscillator waveform="sine"/>
    </group>
  </groups>
</DecentSampler>
Code language: HTML, XML (xml)

The available waveform types are:

  • sine – Pure sine wave with no harmonics, ideal for sub-bass
  • saw – Sawtooth wave with rich harmonics, great for bright sounds
  • square – Square wave with odd harmonics, useful for hollow tones
  • triangle – Triangle wave with fewer harmonics, produces mellower tones
  • noise (or white_noise) – White noise generator, useful for percussion and textures

You can combine oscillators with regular samples for layering effects. For example, you might add a sine wave sub-bass underneath acoustic piano samples to add depth and weight to the low end.

Here’s a more complete example showing how to create a simple synth with waveform selection:

<DecentSampler minVersion="1.15.0">
  <ui>
    <tab>
      <menu x="10" y="10" width="150" height="30" value="1">
        <option name="Sine">
          <binding type="general" level="group" position="0" 
                   parameter="OSCILLATOR_WAVEFORM" 
                   translation="fixed_value" translationValue="sine"/>
        </option>
        <option name="Saw">
          <binding type="general" level="group" position="0" 
                   parameter="OSCILLATOR_WAVEFORM" 
                   translation="fixed_value" translationValue="saw"/>
        </option>
        <option name="Square">
          <binding type="general" level="group" position="0" 
                   parameter="OSCILLATOR_WAVEFORM" 
                   translation="fixed_value" translationValue="square"/>
        </option>
        <option name="Triangle">
          <binding type="general" level="group" position="0" 
                   parameter="OSCILLATOR_WAVEFORM" 
                   translation="fixed_value" translationValue="triangle"/>
        </option>
      </menu>
    </tab>
    <keyboard/>
  </ui>
  <groups>
    <group waveform="saw" volume="0.5" attack="0.01" decay="0.3" 
           sustain="0.7" release="0.5">
      <oscillator/>
    </group>
  </groups>
</DecentSampler>
Code language: HTML, XML (xml)

An example of using oscillators can be found in the DecentSampler Sample Library Examples repository here.

Rectangle Elements

Rectangle elements allow you to create custom backgrounds, panels, borders, and decorative elements in your UI. They support fill colors, border colors, and border thickness, giving you fine control over the visual design of your presets.

Adding a rectangle to your UI is simple:

<rectangle x="10" y="20" width="200" height="100" 
           fillColor="#FF3366FF" 
           borderColor="#FF000000" 
           borderThickness="2" />
Code language: HTML, XML (xml)

Colors use the 8-character hex format #AARRGGBB (alpha, red, green, blue), so #FF3366FF is fully opaque blue with a touch of green.

What makes rectangles particularly powerful is that they support bindings. You can dynamically control their position, size, and visibility using knobs, buttons, or other controls. Here’s an example that uses a knob to control a rectangle’s width:

<ui>
  <tab>
    <labeled-knob x="10" y="10" width="90" label="Width" 
                  type="float" minValue="10" maxValue="400" value="100">
      <binding type="control" level="ui" position="1" parameter="WIDTH" 
               translation="linear" translationOutputMin="10" translationOutputMax="400"/>
    </labeled-knob>
    <rectangle x="10" y="100" width="100" height="50" 
               fillColor="#FF0066FF" 
               borderColor="#FF000000" 
               borderThickness="2" />
  </tab>
  <keyboard/>
</ui>
Code language: HTML, XML (xml)

The binding parameters available for rectangles are:

  • X – X position in pixels
  • Y – Y position in pixels
  • WIDTH – Width in pixels
  • HEIGHT – Height in pixels
  • VISIBLE – Visibility (true/false)

These dynamic capabilities open up possibilities for creating animated UI elements, progress bars, visualizations, and more.

Line Elements

Line elements complement rectangles by allowing you to draw lines for dividers, borders, connectors, or decorative elements. Lines are defined by their start and end points:

<line x1="10" y1="20" x2="200" y2="20" 
      lineColor="#FF000000" 
      lineThickness="2" />
Code language: HTML, XML (xml)

Like rectangles, lines also support dynamic control through bindings. You can create interactive visual elements by binding their endpoints to controls:

<ui>
  <tab>
    <labeled-knob x="10" y="10" width="90" label="End X" 
                  type="float" minValue="0" maxValue="400" value="200">
      <binding type="control" level="ui" position="1" parameter="X2" 
               translation="linear" translationOutputMin="0" translationOutputMax="400"/>
    </labeled-knob>
    <line x1="50" y1="100" x2="200" y2="100" 
          lineColor="#FFFF0000" 
          lineThickness="3" />
  </tab>
  <keyboard/>
</ui>
Code language: HTML, XML (xml)

The binding parameters for lines are:

  • X1 – Start X position in pixels
  • Y1 – Start Y position in pixels
  • X2 – End X position in pixels
  • Y2 – End Y position in pixels
  • VISIBLE – Visibility (true/false)

Together, rectangles and lines give you a complete toolkit for creating sophisticated custom UIs. You can build complex layouts, create visual feedback systems, or even make artistic designs entirely from geometric shapes.

Examples of using rectangles and lines can be found in the DecentSampler Sample Library Examples repository here. The examples include demonstrations of static layouts, dynamic binding controls, and even an artistic rendering of the Mona Lisa created entirely with rectangles!

Getting Started

To use any of these new features, make sure your preset specifies minVersion="1.15.0":

<DecentSampler minVersion="1.15.0">
  <em><!-- Your preset content --></em>
</DecentSampler>
Code language: HTML, XML (xml)

All of these features are documented in the DecentSampler Developer’s Guide, and complete working examples are available in the DecentSampler Sample Library Examples repository.

Definitely let me know if you run into any issues with these new features. They represent a significant expansion of DecentSampler’s capabilities, and I would love to hear your feedback and see what creative uses you come up with.

All the best,
Dave

3 thoughts on “Sample Creators: New Features in Version 1.15.0: Oscillators, Lines, and Rectangles

  1. That’s great! 👏

    Sorry to ask right here but what do you think about MTS-ESP support?

    1. I haven’t looked into what’s required, but it seems to me that there’s enough call for it that I should give it a shot.

      1. Some starting points are:
        – Include the client code that wraps cross-platform dynamic library calls and some state management (and falls back to 12edo when there are problems with connection): https://github.com/ODDSound/MTS-ESP/tree/main?tab=readme-ov-file#client
        – Other stuff’s written there and in the client .h source but one point is you can look up a note’s frequency just on a note-on and use it throughout, or you can implement a more fluid but demanding mode when the frequency is adjusted on the go, reflecting realtime tuning changes. There’s no notification about changes, but looking up frequencies is cheap, it amounts to an array access. So because DS already can change the pitch of a playing note (because of pitchbend wheel and note glides), this might end up not that complicated to support as well: use newer frequency values as often as you’re already doing currently, with all the frequency smoothing that’s already implemented.
        – I don’t remember about other samplers but despite non-sampling synths usually implement the second option as is, here in case it’s too CPU-greedy (I have no idea if it could be for some reason) there might be use for a toggle between the simpler note-on retuning and continuous retuning, as some users would like to use the second despite. Naturally, placed in the tuning menu, I think for those who’ll end up using it it’ll be discovreable (I would check there if I forget).
        – Since several months now, MTS-ESP now provides information about period of the tuning and its span in MIDI notes, so in case there are octave transpose features in DS, I guess it’ll be neat to make them use the provided period (if it’s not provided by a source or user’s libMTS is old, client code safely defaults it to the octave).
        – As always feel free to visit SurgeXT Discord, baconpaul and Andreya in particular may provide some details about something I’ve not considered. And I tried my hand at writing a Luajit rewrite of the client code though I don’t know what useful insight I could provide based on that.

        Also unrelated to this and related to the post (I didn’t remember right away): have you noticed there’s a missing spot among square, triangle and sawtooth waveforms? Both square and triangle are odd harmonics only, and both square and sawtooth are 6 dB per octave falloff, whereas triangle is 12 dB. We can also see that triangle is just square integrated. So if we integrate the saw, we get a wave of parabola segments that some call “semisine” (because it looks like rectified sine) but actually it’s this waveform with 12 dB per oct falloff and all harmonics. Of course one can just slap a LP filter onto the regular sawtooth oscillator but it may be interesting to add in the future as another primitive? Semisine sound is very usable to mix in because it’s less harsh than sawtooth so I bet library creators would make use of it!

Leave a Reply

Your email address will not be published. Required fields are marked *