$ErrorActionPreference = 'Stop' $projectRoot = [System.IO.Path]::GetFullPath((Join-Path $PSScriptRoot '..')) $outputPath = Join-Path $projectRoot 'assets/array-geometries/rectangular-16x12.array.json' $microphones = [System.Collections.Generic.List[object]]::new() $columns = 16 $rows = 12 $width = 0.45 $height = 0.45 for ($row = 0; $row -lt $rows; $row++) { for ($column = 0; $column -lt $columns; $column++) { $index = $row * $columns + $column $x = -$width / 2 + $column * $width / ($columns - 1) $y = -$height / 2 + $row * $height / ($rows - 1) $microphones.Add([ordered]@{ id = 'mic-{0:D3}' -f ($index + 1) position = @([Math]::Round($x, 6), [Math]::Round($y, 6), 0) }) } } $arrayDefinition = [ordered]@{ schemaVersion = '1.0.0' kind = 'micarrsim.array' id = 'rectangular-16x12' name = '16x12 rectangular baseline' description = '192-channel uniform rectangular layout on a 0.45 m square aperture' units = 'm' coordinateSystem = [ordered]@{ handedness = 'right' xAxis = 'right' yAxis = 'up' zAxis = 'toward-scene' } aperture = [ordered]@{ width = $width; height = $height } microphones = $microphones } $json = $arrayDefinition | ConvertTo-Json -Depth 8 [System.IO.File]::WriteAllText($outputPath, $json + [Environment]::NewLine, [System.Text.UTF8Encoding]::new($false)) Write-Host "Generated $($microphones.Count) microphones: $outputPath" $spiralOutputPath = Join-Path $projectRoot 'assets/array-geometries/fermat-spiral-192.array.json' $spiralMicrophones = [System.Collections.Generic.List[object]]::new() $microphoneCount = 192 $radius = 0.225 $goldenAngle = [Math]::PI * (3 - [Math]::Sqrt(5)) for ($index = 0; $index -lt $microphoneCount; $index++) { $microphoneRadius = $radius * [Math]::Sqrt(($index + 0.5) / $microphoneCount) $angle = $index * $goldenAngle $x = $microphoneRadius * [Math]::Cos($angle) $y = $microphoneRadius * [Math]::Sin($angle) $spiralMicrophones.Add([ordered]@{ id = 'mic-{0:D3}' -f ($index + 1) position = @([Math]::Round($x, 6), [Math]::Round($y, 6), 0) }) } $spiralDefinition = [ordered]@{ schemaVersion = '1.0.0' kind = 'micarrsim.array' id = 'fermat-spiral-192' name = '192-channel Fermat spiral' description = 'Equal-area Fermat spiral on a 0.45 m circular aperture for comparison with the rectangular baseline' units = 'm' coordinateSystem = [ordered]@{ handedness = 'right' xAxis = 'right' yAxis = 'up' zAxis = 'toward-scene' } aperture = [ordered]@{ width = 0.45; height = 0.45 } microphones = $spiralMicrophones } $spiralJson = $spiralDefinition | ConvertTo-Json -Depth 8 [System.IO.File]::WriteAllText( $spiralOutputPath, $spiralJson + [Environment]::NewLine, [System.Text.UTF8Encoding]::new($false) ) Write-Host "Generated $($spiralMicrophones.Count) microphones: $spiralOutputPath"