Audio is playing too slow

Sub forums for various specialist XMOS applications. e.g. USB audio, motor control and robotics.
muntablues
Active Member
Posts: 34
Joined: Tue Dec 20, 2011 2:45 pm

Audio is playing too slow

Post by muntablues »

Hi there

I got my audio board for my custom Xmos Usb audio design (http://www.xcore.com/forum/viewtopic.php?f=21&t=2355) and I have a little problem. If I use 44100, 88200, .. kHz sample rate everything works fine, but if I switch to 48000, 9600, ... kHz the sound is playling too slow.

I have checked my frequency switch and I think it is working as it should. I get MCLK 22.5792MHz if I use 44100, 88200 and I get 24.576MHz if i switch to 48000khz.

I use more or less XMOS audio reference software (6.1.0) so I think it should be ok. I am using Windows with Eval driver 2.19

Has anyone an idea what is going wrong here?

Regards MB


User avatar
Ross
XCore Expert
Posts: 966
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

You have the MCLK define set appropriately? (512*48000)
muntablues
Active Member
Posts: 34
Joined: Tue Dec 20, 2011 2:45 pm

Post by muntablues »

Hi Ross

As I mentioned before, I use 6.1.0 from XMOS and I only changed from 4xIn and 4xOut to 8xOut. The rest is like in Usb Audio DJ example...

Maybe interesting: I use PCM5102 as DACs.

Thanks for help!

MB
User avatar
infiniteimprobability
XCore Legend
Posts: 1126
Joined: Thu May 27, 2010 10:08 am

Post by infiniteimprobability »

Hi - can you confirm your MCLK settings?

It's in customdefines.h:

Code: Select all

/* Master clock defines (in Hz) */
#define MCLK_441          (512*44100)   /* 44.1, 88.2 etc */
#define MCLK_48           (512*48000)   /* 48, 96 etc */

Also, can you confirm your channel count - is it 8out AND 4in, or just 8 out?
muntablues
Active Member
Posts: 34
Joined: Tue Dec 20, 2011 2:45 pm

Post by muntablues »

Yes, they still exist exactly as you posted...
User avatar
infiniteimprobability
XCore Legend
Posts: 1126
Joined: Thu May 27, 2010 10:08 am

Post by infiniteimprobability »

Thanks, that's clear - but please can you confirm your channel count?

Is it 8out AND 4in, or just 8 out? The original statement can be read two ways..

The reason for the question is I'm trying to understand how loaded up the audio core is.
muntablues
Active Member
Posts: 34
Joined: Tue Dec 20, 2011 2:45 pm

Post by muntablues »

Sorry missed that question...

8x out, no inputs.
User avatar
infiniteimprobability
XCore Legend
Posts: 1126
Joined: Thu May 27, 2010 10:08 am

Post by infiniteimprobability »

8 Ch out is no sweat for this code, so I tested it out.

Result = works for me. I repurposed the ADC0 and ADC1 as DAC2 and DAC3 to get 8ch out (bit naughty as I'm driving out against the ADC) but it worked OK. I get 8ch of audio across all sample rates. Here's my customdefines.h (note hacked way of adding the ADC pins as ch5-8 output - not neat)

By the way - We recommend you update to at least 6.2.1 of the ref design. There are some big updates in there to make the ref design more compatible with newer USB host controller chipsets. Lots of new goodies too like DSD support (see changelog for full details), and now support for tools version 13.

Any particular reason you are using this older version?
You do not have the required permissions to view the files attached to this post.
muntablues
Active Member
Posts: 34
Joined: Tue Dec 20, 2011 2:45 pm

Post by muntablues »

Thanks for your answer.

First I will switch to 6.2.1 (I didn't notice, that there is a new version) and give it a try.

I looked into your header file and it lookes more or less like mine.

So I will inform you after my try...

MB
muntablues
Active Member
Posts: 34
Joined: Tue Dec 20, 2011 2:45 pm

Post by muntablues »

OK I have switched to 6.2.1 and Studio 13.0.2 but the result is the same, even if I configure it as stereo device.

These are my changes. But if it is working fine with your HW, I think there is something wrong with mine. But I think it should be quite the same...

customdefines.h

Code: Select all

/**
 * @file       customdefines.h
 * @brief      Defines relating to device configuration and customisation.
 *             For L1 USB Audio Reference Design
 * @author     Ross Owen, XMOS Limited
 */
#ifndef _CUSTOMDEFINES_H_
#define _CUSTOMDEFINES_H_


/*
 * Device configuration option defines.  Build can be customised but changing and adding defines here
 *
 * Note, we check if they are already defined in Makefile
 */

/* Enable/Disable MIDI - Default is MIDI off */
#ifndef MIDI
#define MIDI 		0
#endif

/* Enable/Disable SPDIF output - Default is S/PDIF on */
#ifndef SPDIF
#define SPDIF		1
#endif

/* Audio class version to run in - Default is 2.0 */
#ifndef AUDIO_CLASS
#define AUDIO_CLASS (2)
#endif

/* Enable/disable fall back to Audio Class 1.0 when connected to FS hub. */
#ifndef AUDIO_CLASS_FALLBACK
#define AUDIO_CLASS_FALLBACK 1
#endif

/* Defines relating to channel count and channel arrangement (Set to 0 for disable) */
//:audio_defs
/* Number of USB streaming channels - Default is 4 in 4 out */
#ifndef NUM_USB_CHAN_IN
#define NUM_USB_CHAN_IN   (0)         /* Device to Host */
#endif
#ifndef NUM_USB_CHAN_OUT
#define NUM_USB_CHAN_OUT  (2)         /* Host to Device */
#endif

/* Number of IS2 chans to DAC..*/
#ifndef I2S_CHANS_DAC
#define I2S_CHANS_DAC     (2)
#endif

/* Number of I2S chans from ADC */
#ifndef I2S_CHANS_ADC
#define I2S_CHANS_ADC     (0)
#endif

/* Run the CODEC as slave, Xcore as master
 * Changing this define will cause CODECs to setup appropriately and XCore to be I2S slave
 */
#define CODEC_MASTER      0

/* Enable DFU interface, Note, requires a driver for Windows */
#define DFU             1

#define MIDI_SHIFT_TX   7


/* Master clock defines (in Hz) */
#define MCLK_441          (512*44100)   /* 44.1, 88.2 etc */
#define MCLK_48           (512*48000)   /* 48, 96 etc */

/* Maximum frequency device runs at */
#ifndef MAX_FREQ
#define MAX_FREQ                    (192000)
#endif

/* Index of SPDIF TX channel (duplicated DAC channels 1/2) */
#define SPDIF_TX_INDEX              (0)

/* Default frequency device reports as running at */
/* Audio Class 1.0 friendly freq */
#define DEFAULT_FREQ                (48000)
//:
/***** Defines relating to USB descriptors etc *****/
//:usb_defs
#define VENDOR_ID   (0x20B1) /* XMOS VID */
#define PID_AUDIO_2 (0x0008) /* SKC_SU1 USB Audio Reference Design PID */
#define PID_AUDIO_1 (0x0009) /* SKC_SU1 Audio Reference Design PID */
//:

/* Enable/Disable example HID code */
#define HID_CONTROLS       0

/* Enable/Disable SU1 ADC */
#define SU1_ADC_ENABLE     0

/* Enable ADC based *EXAMPLE* volume control */
#define ADC_VOL_CONTROL    0

/* Define to use custom flash part not in tools by default
 * Device is M25P40 */
#define DFU_FLASH_DEVICE \
{    \
    1, \
    256,                    /* page size */\
    1024,                   /* num pages */\
    3,                      /* address size */\
    8,                      /* log2 clock divider */\
    0x9f,                   /* SPI_RDID */\
    0,                      /* id dummy bytes */\
    3,                      /* id size in bytes */ \
    0x202013,               /* device id */\
    0xD8,                   /* SPI_SE */\
    0,                      /* full sector erase */\
    0x06,                   /* SPI_WREN */\
    0x04,                   /* SPI_WRDI */\
    PROT_TYPE_SR,           /* SR protection */\
    {{0x0c,0x0},{0,0}},     /* no values */\
    0x02,                   /* SPI_PP */\
    0x0b,                   /* SPI_READFAST */\
    1,                      /* 1 read dummy byte */\
    SECTOR_LAYOUT_REGULAR,  /* sane sectors */\
    {32768,{0,{0}}},        /* regular sector size */\
    0x05,                   /* SPI_RDSR */\
    0x01,                   /* no SPI_WRSR */\
    0x01,                   /* SPI_WIP_BIT_MASK */\
}

#endif
xp_skc_su1.xn

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<Network xmlns="http://www.xmos.com"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://www.xmos.com http://www.xmos.com">

  <Declarations>
    <Declaration>tileref tile[1]</Declaration>
    <Declaration>tileref usb_tile</Declaration>
  </Declarations>

  <Packages>
    <Package Id="P1" Type="XS1-SU01A-FB96">
      <Nodes>
        
        <Node Id="0" Type="XS1-L1A" InPackageId="0" Oscillator="24MHz" SystemFrequency="500MHz" ReferenceFrequency="100MHz">
          <Boot>
            <Source Location="SPI:bootFlash"/>
          </Boot>
          <Core Number="0" Reference="tile[0]">
            <Port Location="XS1_PORT_1A"  Name="PORT_SPI_MISO"/>
            <Port Location="XS1_PORT_1B"  Name="PORT_SPI_SS"/>
            <Port Location="XS1_PORT_1C"  Name="PORT_SPI_CLK"/>
            <Port Location="XS1_PORT_1D"  Name="PORT_SPI_MOSI"/>
            <Port Location="XS1_PORT_1A"  Name="PORT_I2S_BCLK"/>
            <Port Location="XS1_PORT_1B"  Name="PORT_SPDIF_OUT"/>
            <Port Location="XS1_PORT_1C"  Name="PORT_I2S_DAC1"/>
            <Port Location="XS1_PORT_1D"  Name="PORT_I2S_DAC3"/>
            <Port Location="XS1_PORT_1E"  Name="PORT_MCLK_IN"/>
            <Port Location="XS1_PORT_1F"  Name="PORT_MIDI_IN"/>
            <Port Location="XS1_PORT_1G"  Name="PORT_I2S_DAC2"/>
            <Port Location="XS1_PORT_1I"  Name="PORT_I2S_LRCLK"/>
            <Port Location="XS1_PORT_1L"  Name="PORT_I2S_DAC0"/>
            <Port Location="XS1_PORT_8D"  Name="PORT_MIDI_OUT"/>
            <Port Location="XS1_PORT_16B"  Name="PORT_MCLK_COUNT"/>
          </Core>
        </Node>
        <Node Id="1" InPackageId="1" Type="periph:XS1-SU" Reference="usb_tile" Oscillator="24MHz">
            <Service Proto="xs1_su_adc_service(chanend c_adc)">
                <Chanend Identifier="c_adc" end="2" remote="5"/>
            </Service>
        </Node> 
      </Nodes>
      <Links>
        <Link Encoding="5wire">
          <LinkEndpoint NodeId="0" Link="XLH" Delays="52clk,52clk"/>
          <LinkEndpoint NodeId="1" Link="XLC" Delays="1clk,1clk"/>
        </Link>
      


        <!--XSCOPE -->
        <Link Encoding="2wire" Delays="4,4" Flags="SOD">
        <LinkEndpoint NodeId="0" Link="X0LD"/>
        <LinkEndpoint RoutingId="0x8000" Chanend="1"/>
        </Link>
        
        </Links>
    </Package>
  </Packages>

  <ExternalDevices>
    <Device NodeId="0" Core="0" Class="SPIFlash" Name="bootFlash" Type="M25P40">
      <Attribute Name="PORT_SPI_MISO" Value="PORT_SPI_MISO"/>
      <Attribute Name="PORT_SPI_SS"   Value="PORT_SPI_SS"/>
      <Attribute Name="PORT_SPI_CLK"  Value="PORT_SPI_CLK"/>
      <Attribute Name="PORT_SPI_MOSI" Value="PORT_SPI_MOSI"/>
    </Device>
  </ExternalDevices>

  <JTAGChain>
    <JTAGDevice NodeId="0"/>
    <JTAGDevice NodeId="1"/>
  </JTAGChain>

</Network>