3 Replies Latest reply on Jan 11, 2009 7:05 PM by the chuck

    Oscillators in PixelBender

    the chuck Level 1
      Hurray, with the help of int-e from #math on irc.freenode.net, I got pixelBender to behave like an Oscillator:

        • 1. Re: Oscillators in PixelBender
          the chuck Level 1
          I'm running into trouble with my next filter. I want to do mixing. I know people have posted snippets for how to mix stereo audio byteArrays, but not mono channels.

          What i'm doing currently is using one filter to generate my sawtooth wave and return a mono-channel byteArray. It works great(using Tinic's disassembler/assembler to hack it). Now, as part of my basic testing, I want to pass in this SingleChannel byteArray into a PB filter, and return a two-channel byteArray, that is written to the AudioBuffer. Basically, a 1:1 input:output ratio.

          trace ("p0 length: ",p0.length); //a single channel of audio, filled with 2048 floats, or 8192 bytes.

          sawMixer.data.v0.input = p0;
          sawMixer.data.v0.width = p0.length/4;
          sawMixer.data.v0.height = 1;

          var mixJob:ShaderJob = new ShaderJob(sawMixer, e.data, p0.length/4, 2);
          mixJob.start(true);

          Here is the PixelBender code:

          {
          input image1 v0;
          output float3 dst;

          void
          evaluatePixel()
          {
          dst.r = sampleNearest(v0, outCoord());
          dst.g = sampleNearest(v0, outCoord());
          }
          }

          The hope is that it will basically copy p0's single channel into the two audio channels. However, it does not. Can anyone explain why not?

          Once p0 is generated, I can go e.data.writeBytes(p0) and get nice clean playback, with no stopping. So, p0 IS a valid byteArray of audio sample data. I don't understand why this is failing.

          thanks.
          • 2. Re: Oscillators in PixelBender
            the chuck Level 1
            http://matkat.tringali.org/misc/VisualFUN/Sawtooth/Sawtooth.html

            Sliders 1-6 control the volume of each voice!!!

            awesome.

            Round-trip for calculating all 6 voices? 5ms
            • 3. Oscillators in PixelBender
              the chuck Level 1
              Added in the ability to control panning per voice:

              http://matkat.tringali.org/misc/VisualFUN/Sawtooth/Sawtooth.html

              I had to write the PixelBender kernal from scratch, using Tinic's disassembler/assembler.

              roundtrip calc time for all 6 voices is still only 4-6ms!!!