You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Document PCM byte layout as its own subsection, de-duplicated across the player and source roles #90
This issue had two parts. Part 1 is withdrawn after the comment from @maximmaxim345. Only the PCM documentation stays.
Problem
The spec gives the PCM byte layout in one sentence. The sentence is easy to miss.
The same sentence occurs in two files, roles/player/v1.md and roles/source/v1.md:
PCM Encoding Convention: For the pcm codec, samples are encoded as little-endian signed integers (two's complement). 24-bit samples are packed as 3 bytes per sample.
The Codec framing text below it is also in the two files. It gives the rules for pcm, flac and opus, and a note about codec_header. Only the message name is different: stream/start or client_stream/start.
Change
Move the two blocks into one new section. The section gives the PCM byte layout and the codec framing rules.
Then the player role and the source role refer to this section. Each role gives only its own format message.
Add an example for 16-bit and for 24-bit. Then a reader can examine an implementation against the example. Do not add a 32-bit example, because the spec gives only 16 and 24 as values for bit_depth.
Reason
The file sendspin-go has no code for 24-bit samples. The current text is easy to miss, thus the error is difficult to find.
The change also removes a duplicate requirement. Today the team must keep two files in agreement.
Part 1: withdrawn
Part 1 asked for a default codec order. The spec already says that supported_formats is in order of preference. Thus the client selects the order.
The user can also select PCM in the client settings. A SHOULD for Opus is then incorrect. A SHOULD that a correct implementation must ignore has no function.
If an SDK sends PCM first with no user setting, correct the default in that SDK.
Clients SHOULD list supported_formats in descending preference,
with compressed codecs (opus, flac) listed before pcm unless
the client has a specific reason to prefer uncompressed (e.g. a
battery-powered device avoiding CPU-heavy decoding).
sendspin-js advertises [pcm, opus, flac] (PCM first), which means
servers will choose uncompressed over Opus by default and waste
bandwidth. sendspin-cpp's conformance harness uses opus, flac, pcm
which is the more defensible default.
Should we add this to the spec though? We already define that supported_formats is in preference order, so the implementation needs to choose what is preferred and what not.
AFAIK all implementation that support compressed codecs already prefer them over PCM by default (sendspin-js is no exception).
But in case the user configured PCM in the clients settings, that will be prefered instead of course.
@maximmaxim345 you're right, and sorry for the slow reply. Dropping item 1.
supported_formats is already defined as being in descending preference order, so the choice of what to prefer is the client's to make — and the case you name is the decisive one: if the user has configured PCM in the client's settings, the spec telling them to advertise Opus first would be wrong. A SHOULD that a conformant implementation is expected to violate whenever the user expresses a preference isn't a useful SHOULD. If sendspin-js genuinely defaults to PCM-first with no user configuration behind it, that's an SDK default worth fixing there rather than a spec gap.
Item 2 still stands, with a bit more justification than it had in May. The PCM byte-layout convention is currently a single bolded line, and it now appears twice — verbatim — in both roles/player/v1.md and roles/source/v1.md:
PCM Encoding Convention: For the pcm codec, samples are encoded as little-endian signed integers (two's complement). 24-bit samples are packed as 3 bytes per sample.
The same is true of the "Codec framing" block below it, which is also duplicated across the two roles. So extracting this into one shared subsection removes a duplicated normative paragraph as well as making the convention findable — which fits the current simplification pass. Worked examples for 16- and 24-bit would make the 24-bit packing auditable by inspection; sendspin-go has no explicit 24-bit path, and the bug is latent precisely because the rule is so easy to skim past. (32-bit isn't worth an example — bit_depth is only exemplified as 16 and 24 in the spec.)
Retitling this issue to just the PCM item unless you'd rather keep item 1 open for discussion.
changed the title [-]Codec and format negotiation: default codec order, PCM byte-layout docs[/-][+]Document PCM byte layout as its own subsection, de-duplicated across the player and source roles[/+]on Aug 18, 2026
The spec gives the PCM byte layout in one sentence. The sentence is easy to miss.
I don't think this is a valid argument. You could use this argument for just about everything in this specification.
And, implementations (should) prefer using flac instead of 24-bit PCM.
The file sendspin-go has no code for 24-bit samples. The current text is easy to miss, thus the error is difficult to find.
I really don't think that this is the reason for go not implementing 24-bit audio. The benefit over 16-bit is (in almost all cases) imperceptible.
Move the two blocks into one new section. The section gives the PCM byte layout and the codec framing rules.
Then the player role and the source role refer to this section. Each role gives only its own format message.
I deliberately duplicated this section so reading the Markdown file of each role is as self contained as possible.
This way, one implementing just the visualizer and metadata role don't have to read this section about PCM encoding.
You are correct on all three points, and I am closing this issue.
The duplication is the decisive point. I did not know that you duplicated the section deliberately. A reader of the visualizer role or the metadata role must not read the PCM rules. A shared section removes that property, thus my proposal makes the role files worse, not better.
Your other two points are also correct. "The sentence is easy to miss" is an argument against every sentence in the spec, thus it proves too much. And 24-bit PCM is not the reason for the gap in sendspin-go, because FLAC is the better choice for that audio.
One suggestion that comes out of this. The rule about self-contained role files is not in CONTRIBUTING.md. I proposed the opposite because I could not see the rule. Issue #153 adds it.
Activity
maximmaxim345 commentedon Jun 30, 2026
Should we add this to the spec though? We already define that
supported_formatsis in preference order, so the implementation needs to choose what is preferred and what not.AFAIK all implementation that support compressed codecs already prefer them over PCM by default (
sendspin-jsis no exception).But in case the user configured
PCMin the clients settings, that will be prefered instead of course.balloob commentedon Aug 18, 2026
@maximmaxim345 you're right, and sorry for the slow reply. Dropping item 1.
supported_formatsis already defined as being in descending preference order, so the choice of what to prefer is the client's to make — and the case you name is the decisive one: if the user has configured PCM in the client's settings, the spec telling them to advertise Opus first would be wrong. A SHOULD that a conformant implementation is expected to violate whenever the user expresses a preference isn't a useful SHOULD. Ifsendspin-jsgenuinely defaults to PCM-first with no user configuration behind it, that's an SDK default worth fixing there rather than a spec gap.Item 2 still stands, with a bit more justification than it had in May. The PCM byte-layout convention is currently a single bolded line, and it now appears twice — verbatim — in both
roles/player/v1.mdandroles/source/v1.md:The same is true of the "Codec framing" block below it, which is also duplicated across the two roles. So extracting this into one shared subsection removes a duplicated normative paragraph as well as making the convention findable — which fits the current simplification pass. Worked examples for 16- and 24-bit would make the 24-bit packing auditable by inspection;
sendspin-gohas no explicit 24-bit path, and the bug is latent precisely because the rule is so easy to skim past. (32-bit isn't worth an example —bit_depthis only exemplified as 16 and 24 in the spec.)Retitling this issue to just the PCM item unless you'd rather keep item 1 open for discussion.
Generated by Claude Code
[-]Codec and format negotiation: default codec order, PCM byte-layout docs[/-][+]Document PCM byte layout as its own subsection, de-duplicated across the player and source roles[/+]maximmaxim345 commentedon Aug 18, 2026
I don't think this is a valid argument. You could use this argument for just about everything in this specification.
And, implementations (should) prefer using flac instead of 24-bit PCM.
I really don't think that this is the reason for go not implementing 24-bit audio. The benefit over 16-bit is (in almost all cases) imperceptible.
I deliberately duplicated this section so reading the Markdown file of each role is as self contained as possible.
This way, one implementing just the visualizer and metadata role don't have to read this section about PCM encoding.
balloob commentedon Aug 18, 2026
You are correct on all three points, and I am closing this issue.
The duplication is the decisive point. I did not know that you duplicated the section deliberately. A reader of the visualizer role or the metadata role must not read the PCM rules. A shared section removes that property, thus my proposal makes the role files worse, not better.
Your other two points are also correct. "The sentence is easy to miss" is an argument against every sentence in the spec, thus it proves too much. And 24-bit PCM is not the reason for the gap in
sendspin-go, because FLAC is the better choice for that audio.One suggestion that comes out of this. The rule about self-contained role files is not in CONTRIBUTING.md. I proposed the opposite because I could not see the rule. Issue #153 adds it.
Generated by Claude Code
docs: record the editorial rules in CONTRIBUTING.md (#165)