Part_1_03_Playing_Music does not work

DOY38

Well-known member
Hello,
After after modifying the wiring of the TEENSY card and the AUDIO card I have an example that works 'Guitar'. But now when I try with the 'Part_1_03_Playing_Music example' (workshop_t4-5.pdf) I don't hear any music. Do you know for what reasons ?
Thank you for your answer
 
Do you have the SDTEST2.WAV file in the root directory of the SD card? And is the SD card in the appropriate slot as selected in the code?

Pete
 
I think it was my first issue with the teensy examples,the monitor was showing sd playing the song but no sound at all,
then i rewrite the
Code:
playSdWav1.play("SDTEST2.WAV");
in low case
Code:
playSdWav1.play("sdtest2.WAV");
may be you can give a try...

Think at this time i had many sd libraries and old ones,must be conflicting with the way the files were written in upper case.
Now i've only the teensy sd library,and another one i backup away,to use it only with pico,that's all.
 
I think it was my first issue with the teensy examples,the monitor was showing sd playing the song but no sound at all,
then i rewrite the
Code:
playSdWav1.play("SDTEST2.WAV");
in low case
Code:
playSdWav1.play("sdtest2.WAV");
may be you can give a try...

Think at this time i had many sd libraries and old ones,must be conflicting with the way the files were written in upper case.
Now i've only the teensy sd library,and another one i backup away,to use it only with pico,that's all.
Thank you, but I think I have a little problem with my connectors, there is a little play and it does not make contact between the 2 cards very well. I will redo the wiring properly.
 
As a point of information SD and SdFat are using FAT32 and EXFAT in which the filenames are not case sensitive. However on Linux based machines which are case sensitive this can cause "File Not Found" problems during compilation. Say you have a header file "file.h" on your storage media and in your sketch you include it as "FILE.h", this would cause a "File not Found" error during compile time in Linux but not windows based machines. I think it is good practice to be consistent with file naming. All upper case or all lower case file names in sketches and on storage media...
 
Do you know where I can find the CODEC configuration ? I assume it's on these lines of codes :
Code:
AudioConnection          patchCord1(playSdWav1, 0, i2s1, 0);
AudioConnection          patchCord2(playSdWav1, 1, i2s1, 1);
but where are the source codes to view the code ? I can find something in this path : C:\Users\....\AppData\Local\Arduino15\packages\teensy\hardware\avr\1.59.0\libraries\Audio. But that's not entirely correct
 
Source code is in the Audio library and core library, specifically AudioStream.cpp and AudioStream.h.

Do you know where I can find the CODEC configuration ?

The SGTL5000 codec chip is configured by source code in the Audio library, specifically control_sgtl5000.cpp.

Maybe you really meant to asking something more substantial? But I can not fully understand your question because it lacks context info, so the only answer I can give is these links to the specific source code files.

If this doesn't really meet your needs, please consider writing more about the context and rationale of your question, so I and others here on this forum can understand your needs. We're all much better at helping when we can fully understand the reason of your questions.
 
Source code is in the Audio library and core library, specifically AudioStream.cpp and AudioStream.h.



The SGTL5000 codec chip is configured by source code in the Audio library, specifically control_sgtl5000.cpp.

Maybe you really meant to asking something more substantial? But I can not fully understand your question because it lacks context info, so the only answer I can give is these links to the specific source code files.

If this doesn't really meet your needs, please consider writing more about the context and rationale of your question, so I and others here on this forum can understand your needs. We're all much better at helping when we can fully understand the reason of your questions.
Just to see how it works with CODEC (out of curiosity). The library control_sgtl5000.cpp isn't really what I'm looking for. When you use the for example this configuration
1729164226160.png

This generates the code automatically but how can we see a summary of the configuration in the internal registers of the CODEC ? For example the CHIP_ANA_POWER register, what is its value for a specific configuration ?
 
Have you looked at the code (and comments) in control_sgtl5000.h/cpp ? That's where the SGTL5000 is configured. If you understand the datasheet and the code in that driver, it should all make sense.
 
It's been 10 years since I wrote that control_sgtl5000.cpp code (or 8 years if you count the edits in 2016). I don't recall every SGTL5000 detail. If you want to look at the specific config used, you really will just need to read that code and probably also the SGTL5000 datasheet. The code really is not very complex. Or you could add a small amount of code to read the registers and print the results, which might be the quickest way if you just want to know the actual values used.
 
It's been 10 years since I wrote that control_sgtl5000.cpp code (or 8 years if you count the edits in 2016). I don't recall every SGTL5000 detail. If you want to look at the specific config used, you really will just need to read that code and probably also the SGTL5000 datasheet. The code really is not very complex. Or you could add a small amount of code to read the registers and print the results, which might be the quickest way if you just want to know the actual values used.
I understand, after me, If I'm not mistaken via the Arduino interface, you cannot enter DEBUG mode to directly view the registers without writing any code.
 
Have you looked at the code (and comments) in control_sgtl5000.h/cpp ? That's where the SGTL5000 is configured. If you understand the datasheet and the code in that driver, it should all make sense.
The problem is not reading the code but where is the 'AudioConnection' class and 'patchCord1' to configure the CODEC ? I didn't see it in control_sgtl5000.cpp.

How the 'Audio System Design Tool' interface generates the code and uses the control_sgtl5000.cpp file. to configure
the CODEC according to an operating mode ?
 
control_sgtl5000.cpp and .h define the AudioControlSGTL5000 class, which is the only thing that interacts directly with the SGTL5000 registers to set it up. How it is configured depends on the code you write (or you find in the examples - I strongly recommend you try those out unmodified, to get an idea of the minimal code needed).

The AudioConnection class is defined in cores, as Paul said in post #7. It has absolutely nothing to do with how your chosen codec is configured, it is used solely to define the route audio data takes through your design. In your example in post #8, you're routing two audio streams from an AudioPlaySdWav to an AudioOutputI2S. Neither of those objects has any idea what codec you're using, either, and thus don't have any influence on how it's configured.
 
control_sgtl5000.cpp and .h define the AudioControlSGTL5000 class, which is the only thing that interacts directly with the SGTL5000 registers to set it up. How it is configured depends on the code you write (or you find in the examples - I strongly recommend you try those out unmodified, to get an idea of the minimal code needed).

The AudioConnection class is defined in cores, as Paul said in post #7. It has absolutely nothing to do with how your chosen codec is configured, it is used solely to define the route audio data takes through your design. In your example in post #8, you're routing two audio streams from an AudioPlaySdWav to an AudioOutputI2S. Neither of those objects has any idea what codec you're using, either, and thus don't have any influence on how it's configured.
Thank you, sorry I hadn't seen this information, there was a lot of information and I didn't see. I'm going to look in the cores
 
AudioConnection moves data between the software components which run on Teensy. It has nothing to do with configuring the codec chip.

Data flows to and from the codec chip by the I2S input and output features. AudioConnection moves data between those and other software. But AudioConnection does not do anything with the codec. That is the function of the I2S input and output, which interface with AudioConnection.

This stuff about AudioConnection and I2S are the actual streaming digital audio data.

The codec chip also has a separate low-speed communication channel just for configuration. That is I2C protocol.

Even though I2C and I2S look similar, both 3 characters starting with "I2" and different by only 1 letter, they are in fact completely different communication. I2S is used for continuous flow of digital audio data. I2C is used for occasional bursts of data at much lower speeds.

Maybe you already knew this? But I still don't understand why you are asking these questions, and without knowing why and without understanding what you really want, these questions don't make a lot of sense and seem like maybe you're asking because of a misunderstanding. But with specific narrowly focused questions lacking context to understand their rationale, very specific answers even if technically correct probably don't clear up misunderstanding.... so trying to explain in this message how continuous digital audio data flow (AudioConnection) and low-speed occasional configuration (codec registers like CHIP_ANA_POWER) are completely different things. Each has its own purpose as part of the whole functioning system.
 
AudioConnection moves data between the software components which run on Teensy. It has nothing to do with configuring the codec chip.

Data flows to and from the codec chip by the I2S input and output features. AudioConnection moves data between those and other software. But AudioConnection does not do anything with the codec. That is the function of the I2S input and output, which interface with AudioConnection.

This stuff about AudioConnection and I2S are the actual streaming digital audio data.

The codec chip also has a separate low-speed communication channel just for configuration. That is I2C protocol.

Even though I2C and I2S look similar, both 3 characters starting with "I2" and different by only 1 letter, they are in fact completely different communication. I2S is used for continuous flow of digital audio data. I2C is used for occasional bursts of data at much lower speeds.

Maybe you already knew this? But I still don't understand why you are asking these questions, and without knowing why and without understanding what you really want, these questions don't make a lot of sense and seem like maybe you're asking because of a misunderstanding. But with specific narrowly focused questions lacking context to understand their rationale, very specific answers even if technically correct probably don't clear up misunderstanding.... so trying to explain in this message how continuous digital audio data flow (AudioConnection) and low-speed occasional configuration (codec registers like CHIP_ANA_POWER) are completely different things. Each has its own purpose as part of the whole functioning system.
Thank you for this information about the AudioConnection, I didn't know what this function was for. What I'm looking for is CODEC configuration only. I have a PJRC audio card (with a µP STM32) but I am not getting the expected results and I am wondering if my configuration is correct. This is why I bought the TEENSY 4.0 card with the audio card to compare the CODEC configuration since I have 2 audio cards from PJRC. But I see that it is not as simple to visualize the CODEC configuration. But I have this code, can someone tell me if my configuration is correct for this mode of operation ?
1729370465264.png

Code:
void SGTL5000_init(void){

    write(CHIP_ANA_POWER_ADD, 0x0622);                              // VDDD is externally driven with 1.8V+
                                                                                          // LINEREG_D_POWERUP=1
    write(CHIP_LINREG_CTRL_ADD, 0x006C);                             // VDDA & VDDIO both over 3.1V
    write(CHIP_REF_CTRL_ADD, 0x01FE);                                   // VAG=1.575, normal ramp, -50% bias current

    //---------------- Route LINEIN\ADC\I2S_OUT---------------------
    // write(CHIP_ANA_CTRL_ADD, 0x0116);                              // enable zero cross detectors, LINEIN input
    write (CHIP_ANA_CTRL_ADD,  CHIP_ANA_CTRL_ADD | (1<<2));

    write(CHIP_SSS_CTRL_ADD, 0x0000);                                   // ADC to I2S_OUT, DAP_SELECT=0
    write(CHIP_DIG_POWER_ADD, 0x0053);                               // power up ADC and I2S_OUT, DAP_POWERUP=1
                                                                                          // I2S_IN=1

    write(CHIP_CLK_CTRL_ADD, 0x0004);                                  // 256*Fs, 44.1 kHz
    write(CHIP_I2S_CTRL_ADD, 0x0130);                                   // Slave Mode, 16bit, I2S format, 32FS


    //---------------- Enable DAP block ---------------------
    // NOTE : DAP will be in a pass-through mode if none of DAP
    // sub-blocks are enabled
    DAP_CONTROL.data = read(DAP_CONTROL_ADD);
    DAP_CONTROL.DAP_EN = 0;
    write (DAP_CONTROL_ADD,DAP_CONTROL.data);               // bit 0

    //---------------- Input Volume Control---------------------
    // Configure ADC left and right analog volume to desired default.
    // Example shows volume of 0dB
    write(CHIP_ANA_ADC_CTRL_ADD, 0x0000);
}
 
Sorry, I can only answer regarding usage with Teensy. You certainly can write entirely new code to use SGTL5000 with other boards, but I can't put the time into helping you write and troubleshoot non-Teensy code. The code is open source and can probably give you a good head start compared with starting from scratch (probably the reason you bought PJRC's audio shield). But it's been about 10 years since I wrote this code on Teensy, so the reality today is those details of configuring SGTL5000 simply aren't fresh in my mind. Best I can tell you is the code used on Teensy is very mature, used by many people. But you'll need to answer your own questions (or at least I can put time into answering questions) regarding porting to other microcontrollers.
 
Sorry, I can only answer regarding usage with Teensy. You certainly can write entirely new code to use SGTL5000 with other boards, but I can't put the time into helping you write and troubleshoot non-Teensy code. The code is open source and can probably give you a good head start compared with starting from scratch (probably the reason you bought PJRC's audio shield). But it's been about 10 years since I wrote this code on Teensy, so the reality today is those details of configuring SGTL5000 simply aren't fresh in my mind. Best I can tell you is the code used on Teensy is very mature, used by many people. But you'll need to answer your own questions (or at least I can put time into answering questions) regarding porting to other microcontrollers.
I understand your position. THANKS
 
Back
Top