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

Thread: Output I2S Question

  1. #1

    Output I2S Question

    Currently I am working on a looper project...I am using the teensy 4 with a PCM5102 DAC, 4 line LCD display and SD reader...Two nanos are used to read buttons and control leds.
    I have modified play_Sd_Raw.cpp and . h and added settable start position, pause ,loop function and loop lenght..I have also modified output_i2s.cpp to allow speed change by adding
    void AudioOutputI2S::playSpeed(int32_t sampleSpeed){
    	int32_t fs = sampleSpeed;
    	// PLL between 27*24 = 648MHz und 54*24=1296MHz
    	int n1 = 4; //SAI prescaler 4 => (n1*n2) = multiple of 4
    	int n2 = 1 + (24000000 * 27) / (fs * 256 * n1);
    	// clear SAI1_CLK register locations
    		   | CCM_CSCMR1_SAI1_CLK_SEL(2); // &0x03 // (0,1,2): PLL3PFD0, PLL5, PLL4
    		   | CCM_CS1CDR_SAI1_CLK_PRED(n1-1) // &0x07
    		   | CCM_CS1CDR_SAI1_CLK_PODF(n2-1); // &0x3f
    I am now ready to start the next phase..Am I right in amusing this sets the DMA timer...If so, are the left and right channel both controlled by the same DMA channel..

    My goal was to add other stored loops that could be called by MIDI while the main loop plays but I see that this would also affect the speed of all loops..Short of
    separating the left and right channels, I will have to rethink the variable speed on the main loop..Thanks for any advice...

  2. #2
    I just realized I should have stated this is a block of code copied from output_i2s.cpp, void AudioOutputI2S::config_i2s()...

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Maybe look at the wavetable object. It supports changing the pitch by interpolating between samples, and playing an initial "attack" sound followed by looping the rest of the sound clip. But the sounds need to be stored in memory. It doesn't support reading from a SD card. However, it is very efficient, so you can have many of them running simultaneously (each scaling the sound clips to different pitch) for polyphonic playback of tunes.

  4. #4
    Thank you for the reply...My original idea was to look at modifying ganular to capture samples from the main SD file and store in memory then access the different samples using midi while the main SD file loops..I guess one option to change the speed of each playback would be to set the DMA rate faster and use a timer to control the update..Haven't played with timers on the teensy much...Kinda of a crazy project and not real sure what the end results will be, but I'm having fun and learning a

Posting Permissions

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