Separate 4 channels one by one issue

New to XMOS and XCore? Get started here.
User avatar
infiniteimprobability
XCore Legend
Posts: 1126
Joined: Thu May 27, 2010 10:08 am
Contact:

Post by infiniteimprobability »

Where are these variables meant to be declared?
Yep - they are all unsigned, and declared locally in the dsp function Ie.

Code: Select all

unsigned underflow;
unsigned command;
unsigned value; 
underflow is a temp variable for grabbing the status of the buffer state from decouple
command is a temp variable for storing commands passed down from the host, and value..

Hope this fixes it - let us all know! We've done a lot of DSP processing in the USB audio chain and it works really well..


User avatar
millenliam
Member++
Posts: 23
Joined: Fri Feb 14, 2014 2:51 pm
Contact:

Post by millenliam »

Thanks!

Also, am I right in thinking that the call to my DSP function needs to go in the usb_audio_io() function in main.xc of the usb audio module? E.g:

Code: Select all

void usb_audio_io(chanend c_aud_in, chanend ?c_adc
#ifdef MIXER
, chanend c_mix_ctl
#endif
)
{
#ifdef MIXER
    chan c_mix_out;
#endif

    chan c_aud_out;

    par
    {

#ifdef MIXER
        /* Mixer cores(s) */
        {
            thread_speed();
            mixer(c_aud_in, c_mix_out, c_mix_ctl);
        }
#endif

        /*DSP core*/
        {
            set_thread_fast_mode_on();
            dsp (c_aud_in, c_audio_out);
        }

        /* Audio I/O Core (pars additional S/PDIF TX Core) */
        {
            thread_speed();
#ifdef MIXER
            audio(c_mix_out, null, null, c_adc);
#else
            audio(c_aud_out, null, null, c_adc);
#endif
        }
    }
}
I can't seem to find the matching code found in the "Adding DSP..." app note document within the USB audio code I've got - maybe because I'm using v6.5.0?

Thanks,
Liam.
User avatar
millenliam
Member++
Posts: 23
Joined: Fri Feb 14, 2014 2:51 pm
Contact:

Post by millenliam »

Also, would would I need to change exactly to get the DSP to be applied to the input, before being sent to the USB host, rather than on the output as demo'd here? I'm having a hard time figuring it out.

Thanks.
Bayanaa
Active Member
Posts: 33
Joined: Fri Feb 07, 2014 3:03 pm

Post by Bayanaa »

I tried lot of time to test dsp on dj kit by following Adding-DSP-to-the-USB-Audio-2.0-L1-Reference-Design(1.1).pdf. But it did not work at all.
(It compiled without no error, but cannot record signals from world. I used matlab to interact with dj kit. but matlab just say busy...and finally gives error:Error using AudioRecorder/step
PortAudio Error: Unanticipated host error)

If all you guys tested lot of dsp on it. Please recheck the .pdf and related .xc files.

then give us the feedback.

Thank you.
User avatar
infiniteimprobability
XCore Legend
Posts: 1126
Joined: Thu May 27, 2010 10:08 am
Contact:

Post by infiniteimprobability »

Hi All,

I really sorry this isn't working for you guys. I'd like to reassure you that adding DSP to XMOS USB audio is not only doable, but there are loads of products out there doing exactly that.

There has been a change to the channel protocol in version 6.5. of the reference design (to support passing sample resolution down to the ADC/DAC config code) which might have been an issue. The DSP function sits in between decouple/audio so needs to understand this protocol and pass it on correctly. This would only have been a problem if you were using the appnote code with 6.5.0 onwards..

I have taken the latest protocol (v6.5.0 onwards) and applied it to the DSP function. I have separated out dsp in and dsp out, which needed a double buffer on the input side. So you can see the DSP function copies from one buffer to the next. If you don't need either in or out DSP, just pass the samples_xxx_pre straight across and don't call the dsp function.

It needs a stereo in / out config with no SPDIF or MIDI (so there is a spare core for DSP).

Anyhow, I can confirm It all works fine and I was able to put a 2us DSP input and 2us DSP output function in line at 192KHz with audio streaming OK. (actually if you look at the code, it's a simple attenuate, with blocking wait but it effectively tests operation by consuming 2us worth of processor cycles).

So please give this a go and let us know if it works - To make it easy, I have just attached the files I changed from a clean ref design. I tested it on the MFA board. Don't forget, you absolutely need v6.5.0 of the ref design, which you can download from your account page on xmos.com
Attachments
dsp.zip
DSP example
(6.43 KiB) Downloaded 326 times
dsp.zip
DSP example
(6.43 KiB) Downloaded 326 times
Bayanaa
Active Member
Posts: 33
Joined: Fri Feb 07, 2014 3:03 pm

Post by Bayanaa »

Thank you infiniteimprobability.

I searched on internet

cannot find following:
SET_STREAM_FORMAT_OUT:
SET_STREAM_FORMAT_IN:

but SET_SAMPLE_FREQ is clockcmds.h

also dj kit source code does not have commands.h. I found it from internet but above two parameters does not exist in it.
User avatar
infiniteimprobability
XCore Legend
Posts: 1126
Joined: Thu May 27, 2010 10:08 am
Contact:

Post by infiniteimprobability »

I searched on internet

cannot find following:
SET_STREAM_FORMAT_OUT:
SET_STREAM_FORMAT_IN:
I would not expect to find it on the internet - we provide the source code for USB audio 2.0 free of charge (and royalty free), but we ask that you register first (there are many man years of IP development which we give away in exchange). We then enable a download link in your xmos.com account page so you can download it privately.
but SET_SAMPLE_FREQ is clockcmds.h

also dj kit source code does not have commands.h. I found it from internet but above two parameters does not exist in it.
What version are you running? (look in changelog.rst). All the include files should be there OK in the ref design..
If you are registered OK, then when you go to:

http://www.xmos.com/products/reference-designs/dj then click on documentation/downloads and you should see v 6.6.0 of the ref design available for download. It's always a good idea to be running the latest version when you are at the beginning of project.
Bayanaa
Active Member
Posts: 33
Joined: Fri Feb 07, 2014 3:03 pm

Post by Bayanaa »

I already registered long time ago.
I downloaded and compiled v6.6.0.
when in Makefile module_usb_device is included it gives lots of error...
So I removed it and then compiled error again...

Creating app_usb_aud_skc_su1_2ioxs.xe
ERROR: Unsupported section type 1610612736 in section 2
xmake[1]: *** [bin/2ioxs/app_usb_aud_skc_su1_2ioxs.xe] Error 1
xmake: *** [bin/2ioxs/app_usb_aud_skc_su1_2ioxs.xe] Error 2
User avatar
infiniteimprobability
XCore Legend
Posts: 1126
Joined: Thu May 27, 2010 10:08 am
Contact:

Post by infiniteimprobability »

module_usb_device is core to this reference design so is needed to make this work.

Which tools version are you using? (v6.3.0 onwards is built under tools 13.x)

Just one comment which others may find useful - all of the reference designs come down in the same package. They are all based on the same core USB Audio codebase. Each of them are customised with local files (includes, hwconfig.xc etc.) in the app_usb_aud_xxxx applications.

So there is no such thing as the DJ ref design, MFA ref design etc. They are all part of the same package. You just make the app you are interested in.
Bayanaa
Active Member
Posts: 33
Joined: Fri Feb 07, 2014 3:03 pm

Post by Bayanaa »

Which tools version are you using? (v6.3.0 onwards is built under tools 13.x)
I am using 12.2.0 build 7741

should I use 13 to work latest packages?

usb_device module source code has something wrong. As I know xc does not support pointers. But here is something ::::
usb_device.h:61: error: parse error before '*' token
C:/Users/gg/Downloads/USB-Audio-2.0-Device-Reference-Design-Software(6.6.0)/sc_usb_device/module_usb_device/src/usb_device.xc:90: error: parse error before '*' token
C:/Users/gg/Downloads/USB-Audio-2.0-Device-Reference-Design-Software(6.6.0)/sc_usb_device/module_usb_device/src/usb_device.xc: In function `USB_StandardRequests':
C:/Users/gg/Downloads/USB-Audio-2.0-Device-Reference-Design-Software(6.6.0)/sc_usb_device/module_usb_device/src/usb_device.xc:101: error: `sp' undeclared (first use in this function)
C:/Users/gg/Downloads/USB-Audio-2.0-Device-Reference-Design-Software(6.6.0)/sc_usb_device/module_usb_device/src/usb_device.xc:101: error: (Each undeclared identifier is reported only once
C:/Users/gg/Downloads/USB-Audio-2.0-Device-Reference-Design-Software(6.6.0)/sc_usb_device/module_usb_device/src/usb_device.xc:101: error: for each function it appears in.)
C:/Users/gg/Downloads/USB-Audio-2.0-Device-Reference-Design-Software(6.6.0)/sc_usb_device/module_usb_device/src/usb_device.xc:109: error: switch quantity not an integer
C:/Users/gg/Downloads/USB-Audio-2.0-Device-Reference-Design-Software(6.6.0)/sc_usb_device/module_usb_device/src/usb_device.xc:130: error: `ep_in' undeclared (first use in this function)
C:/Users/gg/Downloads/USB-Audio-2.0-Device-Reference-Design-Software(6.6.0)/sc_usb_device/module_usb_device/src/usb_device.xc:198: error: switch quantity not an integer
C:/Users/gg/Downloads/USB-Audio-2.0-Device-Reference-Design-Software(6.6.0)/sc_usb_device/module_usb_device/src/usb_device.xc:210: error: `ep_out' undeclared (first use in this function)
C:/Users/gg/Downloads/USB-Audio-2.0-Device-Reference-Design-Software(6.6.0)/sc_usb_device/module_usb_device/src/usb_device.xc:222: error: switch quantity not an integer
C:/Users/gg/Downloads/USB-Audio-2.0-Device-Reference-Design-Software(6.6.0)/sc_usb_device/module_usb_device/src/usb_device.xc:231: error: `cfgDesc_hs' undeclared (first use in this function)
C:/Users/gg/Downloads/USB-Audio-2.0-Device-Reference-Design-Software(6.6.0)/sc_usb_device/module_usb_device/src/usb_device.xc:253: error: switch quantity not an integer
C:/Users/gg/Downloads/USB-Audio-2.0-Device-Reference-Design-Software(6.6.0)/sc_usb_device/module_usb_device/src/usb_device.xc:261: error: `usbBusSpeed' undeclared (first use in this function)
C:/Users/gg/Downloads/USB-Audio-2.0-Device-Reference-Design-Software(6.6.0)/sc_usb_device/module_usb_device/src/usb_device.xc:261: error: `devDescLength_fs' undeclared (first use in this function)
C:/Users/gg/Downloads/USB-Audio-2.0-Device-Reference-Design-Software(6.6.0)/sc_usb_device/module_usb_device/src/usb_device.xc:264: error: `devDesc_fs' undeclared (first use in this function)
C:/Users/gg/Downloads/USB-Audio-2.0-Device-Reference-Design-Software(6.6.0)/sc_usb_device/module_usb_device/src/usb_device.xc:266: error: `devDescLength_hs' undeclared (first use in this function)
C:/Users/gg/Downloads/USB-Audio-2.0-Device-Reference-Design-Software(6.6.0)/sc_usb_device/module_usb_device/src/usb_device.xc:270: error: `devDesc_hs' undeclared (first use in this function)
C:/Users/gg/Downloads/USB-Audio-2.0-Device-Reference-Design-Software(6.6.0)/sc_usb_device/module_usb_device/src/usb_device.xc:282: error: `cfgDescLength_fs' undeclared (first use in this function)
C:/Users/gg/Downloads/USB-Audio-2.0-Device-Reference-Design-Software(6.6.0)/sc_usb_device/module_usb_device/src/usb_device.xc:285: error: `cfgDesc_fs' undeclared (first use in this function)
C:/Users/gg/Downloads/USB-Audio-2.0-Device-Reference-Design-Software(6.6.0)/sc_usb_device/module_usb_device/src/usb_device.xc:288: error: `cfgDescLength_hs' undeclared (first use in this function)
C:/Users/gg/Downloads/USB-Audio-2.0-Device-Reference-Design-Software(6.6.0)/sc_usb_device/module_usb_device/src/usb_device.xc:378: error: `strDescsLength' undeclared (first use in this function)
C:/Users/gg/Downloads/USB-Audio-2.0-Device-Reference-Design-Software(6.6.0)/sc_usb_device/module_usb_device/src/usb_device.xc:381: error: `unsafe' undeclared (first use in this function)
C:/Users/gg/Downloads/USB-Audio-2.0-Device-Reference-Design-Software(6.6.0)/sc_usb_device/module_usb_device/src/usb_device.xc:381: error: parse error before '{' token
C:/Users/gg/Downloads/USB-Audio-2.0-Device-Reference-Design-Software(6.6.0)/sc_usb_device/module_usb_device/src/usb_device.xc:382: error: parse error before '*' token
C:/Users/gg/Downloads/USB-Audio-2.0-Device-Reference-Design-Software(6.6.0)/sc_usb_device/module_usb_device/src/usb_device.xc:394: error: `strDescs' undeclared (first use in this function)
C:/Users/gg/Downloads/USB-Audio-2.0-Device-Reference-Design-Software(6.6.0)/sc_usb_device/module_usb_device/src/usb_device.xc:435: error: switch quantity not an integer
C:/Users/gg/Downloads/USB-Audio-2.0-Device-Reference-Design-Software(6.6.0)/sc_usb_device/module_usb_device/src/usb_device.xc:480: error: switch quantity not an integer
C:/Users/gg/Downloads/USB-Audio-2.0-Device-Reference-Design-Software(6.6.0)/sc_usb_device/module_usb_device/src/usb_device.xc:515: error: switch quantity not an integer
C:/Users/gg/Downloads/USB-Audio-2.0-Device-Reference-Design-Software(6.6.0)/sc_usb_device/module_usb_device/src/usb_device.xc:559: error: switch quantity not an integer
xmake[1]: *** [.build_1xoxs/m_usb_device/src/usb_device.xc.o] Error 1
xmake: *** [bin/1xoxs/app_usb_aud_skc_su1_1xoxs.xe] Error 2
Post Reply