Skip to content

Commit 265bafd

Browse files
authored
Update sds.yml audio-channels property to channels (#116)
1 parent 883e23e commit 265bafd

8 files changed

Lines changed: 22 additions & 22 deletions

File tree

schema/sds.schema.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@
144144
"minimum": 1,
145145
"description": "Bits per audio sample"
146146
},
147-
"audio-channels": {
148-
"title": "audio-channels:\nDocumentation: https://arm-software.github.io/SDS-Framework/main/theory.html#audio-data-stream",
147+
"channels": {
148+
"title": "channels:\nDocumentation: https://arm-software.github.io/SDS-Framework/main/theory.html#audio-data-stream",
149149
"type": "integer",
150150
"minimum": 1,
151151
"description": "Number of interleaved audio channels"
@@ -162,7 +162,7 @@
162162
"required": [
163163
"sample-frequency",
164164
"bit-depth",
165-
"audio-channels"
165+
"channels"
166166
],
167167
"additionalProperties": false
168168
}

snippets/sds-metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
" - audio:",
5757
" sample-frequency: ${6:44100}",
5858
" bit-depth: ${7|16,8,24,32|}",
59-
" audio-channels: ${8|1,2|}",
59+
" channels: ${8|1,2|}",
6060
" format: ${9:pcm}"
6161
]
6262
},

src/sds/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export interface SdsImageMeta {
7474
export interface SdsAudioMeta {
7575
'sample-frequency': number; // Sample rate in Hz (e.g., 44100)
7676
'bit-depth': number; // Bits per sample (e.g., 16, 24, 32)
77-
'audio-channels': number; // Number of audio channels (1=mono, 2=stereo)
77+
'channels': number; // Number of audio channels (1=mono, 2=stereo)
7878
format?: string; // Codec identifier (e.g., 'pcm', 'wav', 'opus')
7979
//frame_size?: number; // Samples per frame (for block-based codecs)
8080
}

src/sds/writer.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ function appendMediaBlockFields(yaml: string, content: SdsContentValue, block: M
264264
`;
265265
yaml += `${fieldIndent}bit-depth: ${content.audio['bit-depth']}
266266
`;
267-
yaml += `${fieldIndent}audio-channels: ${content.audio['audio-channels']}
267+
yaml += `${fieldIndent}channels: ${content.audio['channels']}
268268
`;
269269
if (content.audio.format) {
270270
yaml += `${fieldIndent}format: ${content.audio.format}
@@ -372,7 +372,7 @@ export function parseMetadataString(text: string, options: ParseMetadataOptions
372372
currentContent.image = { pixel_format: 'RGB888', width: 0, height: 0, stride_bytes: 0 };
373373
} else if (trimmed === '- audio:') {
374374
inAudio = true;
375-
currentContent.audio = { 'sample-frequency': 0, 'bit-depth': 16, 'audio-channels': 1 };
375+
currentContent.audio = { 'sample-frequency': 0, 'bit-depth': 16, 'channels': 1 };
376376
} else if (trimmed === '- video:') {
377377
inVideo = true;
378378
currentContent.video = { pixel_format: 'RGB888', width: 0, height: 0, fps: 0 };
@@ -393,7 +393,7 @@ export function parseMetadataString(text: string, options: ParseMetadataOptions
393393
inAudio = true;
394394
inImage = false;
395395
inVideo = false;
396-
currentContent.audio = { 'sample-frequency': 0, 'bit-depth': 16, 'audio-channels': 1 };
396+
currentContent.audio = { 'sample-frequency': 0, 'bit-depth': 16, 'channels': 1 };
397397
continue;
398398
}
399399
if (trimmed === 'video:') {
@@ -424,8 +424,8 @@ export function parseMetadataString(text: string, options: ParseMetadataOptions
424424
currentContent.audio['sample-frequency'] = parseInt(trimmed.replace('sample-frequency:', '').trim(), 10);
425425
} else if (trimmed.startsWith('bit-depth:')) {
426426
currentContent.audio['bit-depth'] = parseInt(trimmed.replace('bit-depth:', '').trim(), 10);
427-
} else if (trimmed.startsWith('audio-channels:')) {
428-
currentContent.audio['audio-channels'] = parseInt(trimmed.replace('audio-channels:', '').trim(), 10);
427+
} else if (trimmed.startsWith('channels:')) {
428+
currentContent.audio['channels'] = parseInt(trimmed.replace('channels:', '').trim(), 10);
429429
} else if (trimmed.startsWith('format:')) {
430430
currentContent.audio['format'] = extractYamlValue(trimmed.replace('format:', '').trim());
431431
}

src/viewer/sdsMediaViewerPanel.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,15 +294,15 @@ export class SdsMediaViewerPanel {
294294
const tickFreq = metadata.sds['tick-frequency'] ?? 1000;
295295
for (const record of parsed.records) {
296296
try {
297-
const block = decodeAudioBlock(record.data, audioMeta['sample-frequency'], audioMeta['bit-depth'], audioMeta['audio-channels']);
297+
const block = decodeAudioBlock(record.data, audioMeta['sample-frequency'], audioMeta['bit-depth'], audioMeta['channels']);
298298
frames.push({ timestamp: record.timestamp / tickFreq, samples: Array.from(block[0]) });
299299
} catch { /* skip */ }
300300
}
301301

302302
this.audioFrames = frames;
303303
this.audioSampleRate = audioMeta['sample-frequency'];
304304
this.audioBitDepth = audioMeta['bit-depth'];
305-
this.audioChannels = audioMeta['audio-channels'];
305+
this.audioChannels = audioMeta['channels'];
306306

307307
const totalSamples = frames.reduce((sum, frame) => sum + frame.samples.length, 0);
308308
const domainStart = frames.length > 0 ? frames[0].timestamp : 0;
@@ -322,7 +322,7 @@ export class SdsMediaViewerPanel {
322322
decimationPreset,
323323
sampleRate: audioMeta['sample-frequency'],
324324
bitDepth: audioMeta['bit-depth'],
325-
channels: audioMeta['audio-channels'],
325+
channels: audioMeta['channels'],
326326
totalSamples,
327327
totalRecords: parsed.records.length,
328328
fileStats: this.sdsFileStats,

test/generate-test-project.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ console.log(`Generating test project in: ${outDir}\n`);
425425
audio: {
426426
'sample-frequency': sampleRate,
427427
'bit-depth': 16,
428-
'audio-channels': 1,
428+
'channels': 1,
429429
format: 'pcm',
430430
},
431431
}],
@@ -462,7 +462,7 @@ console.log(`Generating test project in: ${outDir}\n`);
462462
audio: {
463463
'sample-frequency': sampleRate,
464464
'bit-depth': 16,
465-
'audio-channels': channels,
465+
'channels': channels,
466466
format: 'pcm',
467467
},
468468
}],

test/unit/sds-parser-writer.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ describe('metadata helpers', () => {
661661
name: 'Mic',
662662
'sample-frequency': 1,
663663
content: [
664-
{ audio: { 'sample-frequency': 16000, 'bit-depth': 16, 'audio-channels': 1 } },
664+
{ audio: { 'sample-frequency': 16000, 'bit-depth': 16, 'channels': 1 } },
665665
],
666666
},
667667
})).toBe('audio');
@@ -807,7 +807,7 @@ describe('metadata YAML roundtrip', () => {
807807
name: 'Mic',
808808
'sample-frequency': 1,
809809
content: [{
810-
audio: { 'sample-frequency': 16000, 'bit-depth': 16, 'audio-channels': 1 },
810+
audio: { 'sample-frequency': 16000, 'bit-depth': 16, 'channels': 1 },
811811
}],
812812
},
813813
};
@@ -821,7 +821,7 @@ describe('metadata YAML roundtrip', () => {
821821
expect(parsed.sds.content[0].audio).toBeDefined();
822822
expect(parsed.sds.content[0].audio!['sample-frequency']).toBe(16000);
823823
expect(parsed.sds.content[0].audio!['bit-depth']).toBe(16);
824-
expect(parsed.sds.content[0].audio!['audio-channels']).toBe(1);
824+
expect(parsed.sds.content[0].audio!['channels']).toBe(1);
825825
});
826826

827827
it('writes metadata into missing directories and preserves optional media fields', () => {
@@ -834,7 +834,7 @@ describe('metadata YAML roundtrip', () => {
834834
image: { pixel_format: 'RGB888', width: 2, height: 1, stride_bytes: 8 },
835835
},
836836
{
837-
audio: { 'sample-frequency': 48000, 'bit-depth': 24, 'audio-channels': 2, format: 'pcm' },
837+
audio: { 'sample-frequency': 48000, 'bit-depth': 24, 'channels': 2, format: 'pcm' },
838838
},
839839

840840
],
@@ -868,7 +868,7 @@ sds:
868868
- audio:
869869
sample-frequency: 48000
870870
bit-depth: 16
871-
audio-channels: 2
871+
channels: 2
872872
- video:
873873
pixel_format: NV12
874874
width: 640
@@ -880,7 +880,7 @@ sds:
880880
`);
881881

882882
expect(parsed.sds.content[0].image).toMatchObject({ pixel_format: 'RAW8', width: 2, height: 1 });
883-
expect(parsed.sds.content[1].audio).toMatchObject({ 'sample-frequency': 48000, 'bit-depth': 16, 'audio-channels': 2 });
883+
expect(parsed.sds.content[1].audio).toMatchObject({ 'sample-frequency': 48000, 'bit-depth': 16, 'channels': 2 });
884884
expect(parsed.sds.content[2].video).toMatchObject({
885885
pixel_format: 'NV12',
886886
width: 640,

test/unit/viewer-panels.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ describe('SdsMediaViewerPanel', () => {
569569
name: 'audio',
570570
'sample-frequency': 100,
571571
'tick-frequency': 1000,
572-
content: [{ audio: { 'sample-frequency': 1000, 'bit-depth': 16, 'audio-channels': 1 } }],
572+
content: [{ audio: { 'sample-frequency': 1000, 'bit-depth': 16, 'channels': 1 } }],
573573
},
574574
};
575575
const records = Array.from({ length: 200 }, (_value, index) => ({

0 commit comments

Comments
 (0)