Csound music file
application/octet-stream
Magic Bytes
Offset: 0
3C 48 50 53 20 76 65 72 73 69 6F 6E 3D 22
Csound Unified File Format (CSD) is an XML-based container developed by the Csound community and based on Barry Vercoe’s research at MIT. It integrates audio processing instructions and score data into a single file to facilitate software-based sound synthesis and algorithmic composition. As a structured text format, it is generally considered safe for exchange and editing, although it requires the Csound interpreter to generate audio from the source instructions.
Validation Code
How to validate .csd files in Python
Python
def is_csd(file_path: str) -> bool:
"""Check if file is a valid CSD by magic bytes."""
signature = bytes([0x3C, 0x48, 0x50, 0x53, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x3D, 0x22])
with open(file_path, "rb") as f:
return f.read(14) == signature
How to validate .csd files in Node.js
Node.js
function isCSD(buffer: Buffer): boolean {
const signature = Buffer.from([0x3C, 0x48, 0x50, 0x53, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x3D, 0x22]);
return buffer.subarray(0, 14).equals(signature);
}
Go
func IsCSD(data []byte) bool {
signature := []byte{0x3C, 0x48, 0x50, 0x53, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x3D, 0x22}
if len(data) < 14 {
return false
}
return bytes.Equal(data[:14], signature)
}
API Endpoint
GET
/api/v1/csd
curl https://filesignature.org/api/v1/csd