Help with USB Sound on the RPI5 #661
Replies: 8 comments 6 replies
-
|
You cannot write floats directly to a sound device. I think about to support this, but it's not available yet. That's why you must convert the samples to shorts for example by looping over the float array: PS. Please post such questions about using Circle in the "Q&A" section, "Development" is dedicated to the further development of the project. |
Beta Was this translation helpful? Give feedback.
-
|
The develop branch has been updated to support writing floats directly to a sound device. With this now it looks like that: |
Beta Was this translation helpful? Give feedback.
-
|
Thank you.
Wm. Jenkinson
…________________________________
From: Rene Stange ***@***.***>
Sent: Friday, April 03, 2026 09:15
To: rsta2/circle ***@***.***>
Cc: wmjenkinson ***@***.***>; Author ***@***.***>
Subject: Re: [rsta2/circle] Help with USB Sound on the RPI5 (Discussion #661)
The develop branch has been updated to support writing floats directly to a sound device. With this now it looks like that:
CUSBSoundBaseDevice sound (SAMPLE_RATE);
// or: CHDMISoundBaseDevice (&m_Interrupt, SAMPLE_RATE);
sound.AllocateQueue (500); // queue size in milliseconds
sound.SetWriteFormat (SoundFormatFloat32, 2); // 2 channels
sound.Start ();
while (1)
{
plm_samples_t samples;
GetSamples (&samples); // to be provided by yourself
bool sent = false;
while (!sent)
{
unsigned queue_space_avail =
sound.GetQueueSizeFrames () - sound.GetQueueFramesAvail ();
if (queue_space_avail >= samples.count) // queue ready to receive the samples?
{
sound.Write (samples.interleaved, samples.count * 2 * sizeof (float));
done = true;
}
// CScheduler::Get ()->Yield ();
}
}
—
Reply to this email directly, view it on GitHub<#661?email_source=notifications&email_token=AGP3C4YZSKDANJSYUNPJRU34T5XJ3A5CNFSNUABIM5UWIORPF5TWS5BNNB2WEL2ENFZWG5LTONUW63SDN5WW2ZLOOQXTCNRUGM2TENZTUZZGKYLTN5XKMYLVORUG64VFMV3GK3TUVRTG633UMVZF6Y3MNFRWW#discussioncomment-16435273>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AGP3C4YH2JQNEBXYKWYCDHD4T5XJ3AVCNFSM6AAAAACXG2LRA2VHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTMNBTGUZDOMY>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
|
Can I ask one last question my friend? I have video frames at 25 fps and 1152 audio samples a frame. What is my Sample Rate? 28,200 or 48000?
Kind Regards,
Wm. Jenkinson
…________________________________
From: Rene Stange ***@***.***>
Sent: Tuesday, April 07, 2026 18:14
To: rsta2/circle ***@***.***>
Cc: wmjenkinson ***@***.***>; Author ***@***.***>
Subject: Re: [rsta2/circle] Help with USB Sound on the RPI5 (Discussion #661)
You are welcome.
—
Reply to this email directly, view it on GitHub<#661 (reply in thread)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AGP3C46VBBTH33XXXH62MHD4UUZNZAVCNFSM6AAAAACXG2LRA2VHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTMNBXHEZDSNQ>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
|
Hello RSTA2,
I have the Sound working sort of. I can hear the sound but its distorted a little, Would that be because the MPG file has a sample rate of 44.1K instead of 48K?
Regards,
Wm.
…________________________________
From: Rene Stange ***@***.***>
Sent: 09 April 2026 20:01
To: rsta2/circle ***@***.***>
Cc: wmjenkinson ***@***.***>; Author ***@***.***>
Subject: Re: [rsta2/circle] Help with USB Sound on the RPI5 (Discussion #661)
The first one? What system is it?
—
Reply to this email directly, view it on GitHub<#661 (reply in thread)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AGP3C425KNBPMI4O4WD4ZB34U7XPHAVCNFSM6AAAAACXG2LRA2VHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTMNJQG42TANI>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
|
The Sound seems slowed down. I'd have thought that the miss-match would speed it up. One last question! Could you show me how to write two interleaved streams?
Thank you so much for your help and patience.
Kind Regards,
Wm. Jenkinson
…________________________________
From: Rene Stange ***@***.***>
Sent: Friday, April 10, 2026 09:15
To: rsta2/circle ***@***.***>
Cc: wmjenkinson ***@***.***>; Author ***@***.***>
Subject: Re: [rsta2/circle] Help with USB Sound on the RPI5 (Discussion #661)
Normally not, it only plays with a wrong speed ;). Have you enabled the system option REALTIME in Config.mk?
DEFINE += -DREALTIME
Does this happen with CHDMISoundBaseDevice too?
—
Reply to this email directly, view it on GitHub<#661 (reply in thread)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AGP3C4ZTAISVBMH6UNRFFY34VCUR3AVCNFSM6AAAAACXG2LRA2VHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTMNJRGM3DMOI>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
|
Rsta2, where is the download for the develop branch? Post Script: The audio is mono and I'm hoping the distortion clears up with SoundFormatFloat32.
Regards,
Wm. Jenkinson
…________________________________
From: Rene Stange ***@***.***>
Sent: Friday, April 03, 2026 09:15
To: rsta2/circle ***@***.***>
Cc: wmjenkinson ***@***.***>; Author ***@***.***>
Subject: Re: [rsta2/circle] Help with USB Sound on the RPI5 (Discussion #661)
The develop branch has been updated to support writing floats directly to a sound device. With this now it looks like that:
CUSBSoundBaseDevice sound (SAMPLE_RATE);
// or: CHDMISoundBaseDevice (&m_Interrupt, SAMPLE_RATE);
sound.AllocateQueue (500); // queue size in milliseconds
sound.SetWriteFormat (SoundFormatFloat32, 2); // 2 channels
sound.Start ();
while (1)
{
plm_samples_t samples;
GetSamples (&samples); // to be provided by yourself
bool sent = false;
while (!sent)
{
unsigned queue_space_avail =
sound.GetQueueSizeFrames () - sound.GetQueueFramesAvail ();
if (queue_space_avail >= samples.count) // queue ready to receive the samples?
{
sound.Write (samples.interleaved, samples.count * 2 * sizeof (float));
done = true;
}
// CScheduler::Get ()->Yield ();
}
}
—
Reply to this email directly, view it on GitHub<#661?email_source=notifications&email_token=AGP3C4YZSKDANJSYUNPJRU34T5XJ3A5CNFSNUABIM5UWIORPF5TWS5BNNB2WEL2ENFZWG5LTONUW63SDN5WW2ZLOOQXTCNRUGM2TENZTUZZGKYLTN5XKMYLVORUG64VFMV3GK3TUVRTG633UMVZF6Y3MNFRWW#discussioncomment-16435273>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AGP3C4YH2JQNEBXYKWYCDHD4T5XJ3AVCNFSM6AAAAACXG2LRA2VHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTMNBTGUZDOMY>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
|
I have the sound working. The problem appears to be that the mpg decoder I'm using requires more cpu resources. Is the default speed for the RPI5 at it highest in the Circle Framework?
Wm.
…________________________________
From: Rene Stange ***@***.***>
Sent: Saturday, April 11, 2026 09:19
To: rsta2/circle ***@***.***>
Cc: wmjenkinson ***@***.***>; Author ***@***.***>
Subject: Re: [rsta2/circle] Help with USB Sound on the RPI5 (Discussion #661)
If you use git, you can get the develop branch with git checkout develop, otherwise the download is here<https://github.com/rsta2/circle/archive/refs/heads/develop.zip>.
For Mono you have to set:
sound.SetWriteFormat (SoundFormatFloat32, 1); // Mono
For SoundFormatFloat32 all samples must be in the range [-1.0 .. 1.0].
—
Reply to this email directly, view it on GitHub<#661 (reply in thread)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AGP3C4ZFYVPKPEOBHVL4EQL4VH5ZXAVCNFSM6AAAAACXG2LRA2VHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTMNJSGU3DQNQ>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
RSTA, could you show me a quick USB Audio example that I can use to pass the following array of Audio Data, USB Sound or HDMI:
`typedef struct {
} plm_samples_t;`
Beta Was this translation helpful? Give feedback.
All reactions