Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 10 of 10

Thread: Teensy Wavetable Synthesis example

  1. #1
    Senior Member
    Join Date
    Apr 2014
    Posts
    281

    Teensy Wavetable Synthesis example

    I was trying out the simple wavetable synthesis sketch in the audio examples of Arduino 1.8.7 / teensyduino 1.44.
    I dont actually have the audio board etc hooked up to a teensy at the moment so edited it down to a basic sketch and run it on a bare teensy 3.2.
    It works and plays the sound file without distortion, but there is vibrato or tremlo etc on the sound. Are there parameters I can change to have no vibrato just a constant tone or is the vibrato in the original audio data. I see the data is uint32_t, is this just audio samples or is it mixed with other meta data.???
    The only parameters I can see is amp and freq..??

    Code:
    /* Play a flute sound wavetable
       Requires Teensy 3.2 or higher.
    */
    
    
    #include <Audio.h>
    #include <Wire.h>
    
    #include "Flute_100kbyte_samples.h"
    
    AudioSynthWavetable wavetable;
    AudioOutputAnalog dac1;
    AudioConnection patchCord1(wavetable, 0, dac1, 0);
      
    void setup() { 
    
       AudioMemory(20);
         
       wavetable.setInstrument(Flute_100kbyte);
       wavetable.amplitude(0.5);
       wavetable.playFrequency(330);
       delay(2000);
    }
    
    void loop() {
      
          wavetable.setFrequency(440);
          
          delay(1000);
          wavetable.setFrequency(660);
     
          delay(1000);
          wavetable.setFrequency(880);
         delay(2000);
        }

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    18,359
    Quote Originally Posted by Teenfor3 View Post
    or is the vibrato in the original audio data.
    Confirmed, that particular flute sample has a fair amount of vibrato baked into the original sound sample.

    An earlier version had a better flute sample, but it was over 200 kbytes. We could really use some better & smaller samples for all the examples....

  3. #3
    Senior Member
    Join Date
    Apr 2014
    Posts
    281
    Thanks for reply, so with the vibrato in the original sound font data, it is not able to be edited by changing parameters..??
    The .cpp file contains 3 tables of uint32_t data and 3 data structs describing the data values..??? not sure what the proper terms are.
    Can none of the parameter values be changed.? The data array doesn't look like a simple array of samples, or is it?
    If I had a soundfont file that contained a sine wave of constant amplitude, it would sound similar to a flute with no vibrato, could I play it in teensy and add a small amount of vibrato??

  4. #4
    Senior Member
    Join Date
    Apr 2014
    Posts
    281
    I am using the windows soundfiledecoder.exe dated 2017 found on github.....

    https://github.com/TeensyAudio/Wavetable-Synthesis

    If I upload the earlier example wavetable sketch to teensy 3.2 it works.

    I then took the trumpet samples .cpp and .h files from the midisynthlarge example, changed the names of things etc in my basic sketch and it works.

    I then took a small soundfile jr_analog.sf2 from the soundfomts folder in the https://github.com/TeensyAudio/Wavetable-Synthesis download and ran the soundfiledecoder.exe on it and got the samples jranalog.cpp and .h files OK but when I tried it in the boxpipe1 sketch it wouldn't compile......basically cannot find things due to paths etc declared differently also the data structure reads different...I think..?

    Is this what is meant by.... "The Audio library wavetable data format was changed slightly after 1.44-beta2, but otherwise 1.44 is identical to 1.44-beta2." ... and do I need a newer version of the soundfiledecoder.exe...??? .....from the announcements 1.44 released page

    wavesTdac.zip

  5. #5
    Senior Member
    Join Date
    Apr 2014
    Posts
    281
    I installed Teensyduino 1.44 beta2 with Arduino 1.8.7 and it works but I need to edit some text in the .cpp and .h files

    decoder outputs for .cpp file ..... const sample_data humbp3_samples[1] = {

    need to change it to this ...... const AudioSynthWavetable::sample_data humbp3_samples[1] = {



    also ..... for the .h file from the decoder outputs .......

    #pragma once
    #include <AudioStream.h>
    #include <AudioSynthWavetable.h>


    extern const sample_data humbp3_samples[1];
    const uint8_t humbp3_ranges[] = {127, };

    const instrument_data humbp3 = {1, humbp3_ranges, humbp3_samples };

    extern const uint32_t sample_0_humbp3_hump3[13184];



    need to change it to this.......

    #pragma once
    // #include <AudioStream.h>
    // #include <AudioSynthWavetable.h>
    #include <Audio.h>

    extern const AudioSynthWavetable::sample_data humbp3_samples[1];
    const uint8_t humbp3_ranges[] = {127, };

    const AudioSynthWavetable::instrument_data humbp3 = {1, humbp3_ranges, humbp3_samples };

    extern const uint32_t sample_0_humbp3_hump3[13184];


    The names used in the 1.44 beta2 data structure seems to be same and from the decoder.OK.

    When I was trying 1.44 release I was also getting errors about data not existing etc.....


    I did notice for the Flute_100kbyte_samples in the midisynthLarge example this line was ....

    uint16_t(UINT16_MAX * WAVETABLE_DECIBEL_SHIFT(0)), // INITIAL_ATTENUATION_SCALAR

    and from the decoder it reads .... uint16_t(UINT16_MAX * DECIBEL_SHIFT(-0/100.0)), //INITIAL_ATTENUATION_SCALAR

    and there may be other name changes......


    ....... is there another windows sf2decoder.exe for 1.44 release version......?


    PS .... I forgot to mention scince using 1.8.7 and 1.44 I have a javaw.exe process that hogs 97% cpu time and about 140 MB of memory while the Arduino IDE is open and verifying or compiling/uploading. The cpu time and memory doesnt clear until I close the IDE after uploading. It still hogs it when teensy is unplugged after upload, I have to clode the IDE each time
    Last edited by Teenfor3; 09-29-2018 at 07:18 PM. Reason: Forgot to add item to message

  6. #6
    Senior Member
    Join Date
    Apr 2014
    Posts
    281
    Got the wavetables sketches working on 1.8.7 / 1.44 OK with the new PJRC SoundfontDecoder but still have the problem with the javaw.exe hogging cpu and memory until the IDE is closed each time after compiling and uploading sketches.... have any others this problem or is it my PC setup....I am still on XP....??

  7. #7
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    1,905
    Quote Originally Posted by Teenfor3 View Post
    have any others this problem or is it my PC setup....I am still on XP....??
    XP is not longer supported, neither by Microsoft nor by PJRC, neither by anyone else. Running a PC under XP connected to the internet does not only put your own system to danger, but everybody. XP is known for being easily taken over from outside and to send spam and distribute viruses in the background without the user being aware of that.

  8. #8
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    4,543
    Quote Originally Posted by Teenfor3 View Post
    Got the wavetables sketches working on 1.8.7 / 1.44 OK with the new PJRC SoundfontDecoder but still have the problem with the javaw.exe hogging cpu and memory until the IDE is closed each time after compiling and uploading sketches.... have any others this problem or is it my PC setup....I am still on XP....??
    I have the same problem with 1.87 / 1.44 Win10 Pro. It's more a Java or Arduino problem than a Windows problem, I think.

  9. #9
    Senior Member
    Join Date
    Apr 2014
    Posts
    281
    Even with the java hogging it all seems to work, just have to close the IDE each time to clear it.......on a side issue.....Yes XP....needs upgraded....I was considering upgrading to an all in one pc but they only have Headphone socket for audio....is that OK for Linein type connections or will I need some sort of audio box plugged into USB etc to give me Line, Lineout and mic input.....or better just buy a desktop.

  10. #10
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    18,359
    I did test the software on Windows XP earlier this year when working on the Ports menu stuff. I even put a couple timer-based workarounds in the code for a XP bug where WM_DEVICECHANGE messages aren't reliably delivered.

    But Java is another matter. Arduino has a complete copy of the Java JRE included in its java folder. So even if you have a newer or older versions of Java installed on your machine, Arduino will use the Java runtime from its own java folder. If you just delete that folder (or rename or move it) then Arduino should use your system's Java JRE. Or you could make a copy and put it in that java folder.

    Going back to an older version like 8u161 or 8u144 or 8u121 might solve these problems? Or it might introduce other ones, since the IDE was built and tested using only the newer version (Arduino 1.8.7 uses Java 8u171). Still, you can probably go back some distance in versions and have everything work, maybe even get lucky to find a version of Java that works well on XP and can run the newest Arduino.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •