diff --git a/REVIEW_LIVE_CODING_MODE b/REVIEW_LIVE_CODING_MODE deleted file mode 100644 index e69de29..0000000 diff --git a/package.json b/package.json index 6cd4e45..83f5a22 100644 --- a/package.json +++ b/package.json @@ -40,6 +40,7 @@ "@hlolli/codemirror-lang-csound": "1.0.0-alpha10", "@replit/codemirror-vim": "^6.3.0", "codemirror": "^6.0.2", + "fuse.js": "^7.1.0", "lucide-svelte": "^0.545.0", "pako": "^2.1.0" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 27883fe..1c82994 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -56,6 +56,9 @@ importers: codemirror: specifier: ^6.0.2 version: 6.0.2 + fuse.js: + specifier: ^7.1.0 + version: 7.1.0 lucide-svelte: specifier: ^0.545.0 version: 0.545.0(svelte@5.39.13) @@ -447,6 +450,10 @@ packages: engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} os: [darwin] + fuse.js@7.1.0: + resolution: {integrity: sha512-trLf4SzuuUxfusZADLINj+dE8clK1frKdmqiJNb1Es75fmI5oY6X2mxLVUciLLjxqw/xr72Dhy+lER6dGd02FQ==} + engines: {node: '>=10'} + glob@7.2.3: resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==} deprecated: Glob versions prior to v9 are no longer supported @@ -1161,6 +1168,8 @@ snapshots: fsevents@2.3.3: optional: true + fuse.js@7.1.0: {} + glob@7.2.3: dependencies: fs.realpath: 1.0.0 diff --git a/scripts/csound-parser/.gitignore b/scripts/csound-parser/.gitignore new file mode 100644 index 0000000..8ca07f3 --- /dev/null +++ b/scripts/csound-parser/.gitignore @@ -0,0 +1,5 @@ +node_modules/ +dist/ +downloaded-opcodes/ +*.log +.DS_Store diff --git a/scripts/csound-parser/README.md b/scripts/csound-parser/README.md new file mode 100644 index 0000000..1e288ab --- /dev/null +++ b/scripts/csound-parser/README.md @@ -0,0 +1,277 @@ +# Csound Manual Parser + +A robust parser that converts the Csound reference manual into TypeScript reference files for use in code editors with hover tooltips and searchable documentation. + +## Features + +- Downloads markdown files directly from GitHub +- Parses 1000+ Csound opcodes +- Extracts structured data (syntax, parameters, examples) +- Generates organized TypeScript files by category +- Creates a main aggregator file with lookup functions +- Handles edge cases and provides detailed error reporting + +## Installation + +```bash +cd scripts/csound-parser +pnpm install +``` + +## Usage + +### Option 1: Download and Parse (Recommended) + +Download fresh markdown files from GitHub and parse them: + +```bash +pnpm run download +``` + +This will: +1. Download all opcode markdown files from the Csound manual repository +2. Parse them into structured data +3. Generate TypeScript reference files in `src/lib/csound-reference/` + +### Option 2: Parse Local Files + +If you already have the Csound manual cloned locally: + +```bash +pnpm run parse -- --input=/path/to/csound-manual/docs/opcodes +``` + +### Custom Output Directory + +```bash +pnpm run parse -- --output=/custom/output/path +``` + +## Output Structure + +The parser generates: + +``` +src/lib/csound-reference/ +├── types.ts # Type definitions +├── csoundReference.ts # Main aggregator +├── signal-generators-basic-oscillators.ts +├── signal-modifiers-standard-filters.ts +├── mathematical-operations-trigonometric-functions.ts +└── ... (100+ category files) +``` + +Each category file contains an array of `CsoundReference` objects: + +```typescript +export const signalGeneratorsBasicOscillators: CsoundReference[] = [ + { + name: 'oscil', + type: 'opcode', + category: 'Signal Generators:Basic Oscillators', + description: 'A simple oscillator without any interpolation.', + syntax: 'ares = oscil(xamp, xcps [, ifn, iphs])\nkres = oscil(kamp, kcps [, ifn, iphs])', + rates: ['a-rate', 'k-rate', 'i-rate'], + parameters: [ + { + name: 'ifn', + description: 'function table number. Requires a wrap-around guard point.', + type: 'initialization' + }, + // ... + ], + seeAlso: ['oscili', 'poscil'] + }, + // ... +] +``` + +## Integration + +Import in your application: + +```typescript +import { + allCsoundReferences, + getCsoundReference, + getCsoundReferencesByCategory +} from './lib/csound-reference/csoundReference' + +// Get a specific opcode +const oscil = getCsoundReference('oscil') + +// Get all oscillators +const oscillators = getCsoundReferencesByCategory('Signal Generators:Basic Oscillators') + +// Search all references +const filtered = allCsoundReferences.filter(ref => + ref.description.includes('filter') +) +``` + +## Use Cases + +### 1. Hover Tooltips in CodeMirror + +Create a tooltip extension similar to the GLSL tooltips: + +```typescript +import { hoverTooltip } from '@codemirror/view' +import { getCsoundReference } from './lib/csound-reference/csoundReference' + +export const csoundTooltip = hoverTooltip((view, pos) => { + const word = getWordAt(view, pos) + if (!word) return null + + const reference = getCsoundReference(word.text) + if (!reference) return null + + return { + pos: word.from, + end: word.to, + above: true, + create() { + const dom = document.createElement('div') + dom.innerHTML = ` +
+ ${reference.name} + ${reference.type} +
+
${reference.description}
+ ${reference.syntax ? `
${reference.syntax}
` : ''} + ` + return { dom } + } + } +}) +``` + +### 2. Searchable Help Panel + +Create a reference panel with fuzzy search: + +```typescript +import { allCsoundReferences } from './lib/csound-reference/csoundReference' +import Fuse from 'fuse.js' + +const fuse = new Fuse(allCsoundReferences, { + keys: ['name', 'description', 'category'], + threshold: 0.4 +}) + +const results = fuse.search('oscillator') +``` + +### 3. Autocomplete + +Use the reference data for intelligent autocomplete: + +```typescript +import { allCsoundReferences } from './lib/csound-reference/csoundReference' + +const completions = allCsoundReferences.map(ref => ({ + label: ref.name, + type: ref.type, + info: ref.description, + detail: ref.syntax +})) +``` + +## Data Structure + +### CsoundReference Interface + +```typescript +interface CsoundReference { + name: string // Opcode name (e.g., "oscil") + type: 'opcode' | 'keyword' | 'header' | 'constant' + category: string // Full category path + description: string // Brief description + syntax?: string // Syntax examples + example?: string // Code example + rates?: string[] // ['a-rate', 'k-rate', 'i-rate'] + parameters?: { + name: string + description: string + type: 'initialization' | 'performance' + }[] + seeAlso?: string[] // Related opcodes +} +``` + +## Parser Architecture + +### 1. Downloader (`downloader.ts`) +- Fetches markdown files from GitHub API +- Handles rate limiting and retries +- Downloads to `downloaded-opcodes/` directory + +### 2. Parser (`parser.ts`) +- Parses markdown frontmatter (id, category) +- Extracts sections using regex +- Extracts parameters from initialization/performance sections +- Handles modern and classic syntax variants +- Detects rate types (a-rate, k-rate, i-rate) + +### 3. Generator (`generator.ts`) +- Groups opcodes by category +- Sanitizes category names for file names +- Generates TypeScript files with proper escaping +- Creates main aggregator with imports +- Provides lookup functions + +## Troubleshooting + +### Download Fails + +If the GitHub download fails, manually clone the repository: + +```bash +git clone https://github.com/csound/manual.git +cd manual +git checkout develop +``` + +Then run the parser with the local path: + +```bash +pnpm run parse -- --input=../manual/docs/opcodes +``` + +### Missing Categories + +Some opcodes may not have categories defined. The parser will skip these and log warnings. + +### Parse Errors + +The parser is robust and will continue parsing even if individual files fail. Check the console output for warnings about skipped files. + +## Extending the Parser + +### Adding New Extraction + +To extract additional information from the markdown files, modify `parser.ts`: + +```typescript +extractNewField(content: string): string { + const section = this.extractSection(content, 'NewSection') + // Parse the section content + return parsed +} +``` + +Then add the field to the `CsoundReference` interface in `types.ts`. + +### Custom Categories + +To reorganize categories, modify the `category` field in the parser or create a mapping function in the generator. + +## Performance + +- Parsing 1000+ opcodes: ~2-5 seconds +- Generating TypeScript files: ~1-2 seconds +- Download from GitHub: ~30-60 seconds (network dependent) + +## License + +MIT diff --git a/scripts/csound-parser/debug-params.ts b/scripts/csound-parser/debug-params.ts new file mode 100644 index 0000000..7907c5b --- /dev/null +++ b/scripts/csound-parser/debug-params.ts @@ -0,0 +1,45 @@ +import * as fs from 'fs'; +import { CsoundManualParser } from './parser'; + +const parser = new CsoundManualParser(); +const content = fs.readFileSync('downloaded-opcodes/moogladder.md', 'utf-8'); + +console.log('=== Testing moogladder.md ===\n'); + +// Test extractSection +const syntaxSection = parser.extractSection(content, 'Syntax'); +console.log('Syntax section length:', syntaxSection.length); +console.log('First 200 chars:', syntaxSection.substring(0, 200)); +console.log('\n---\n'); + +// Look for ### Initialization +const initMatch = syntaxSection.match(/###\s+Initialization\s*\n([\s\S]*?)(?=\n###|\n##|$)/i); +console.log('Initialization match:', initMatch ? 'FOUND' : 'NOT FOUND'); +if (initMatch) { + console.log('Init section content (first 300 chars):'); + console.log(initMatch[1].substring(0, 300)); + console.log('\n---\n'); + + // Test the parameter regex + const paramRegex = /_([a-zA-Z0-9_,\s/]+)_\s*[-–—]+\s*([^\n]+(?:\n(?!_)[^\n]+)*)/g; + const params = Array.from(initMatch[1].matchAll(paramRegex)); + console.log(`Found ${params.length} parameters`); + params.forEach((p, i) => { + console.log(` Param ${i + 1}: name="${p[1]}", desc="${p[2].substring(0, 60)}..."`); + }); +} + +// Test extractParameters directly +const initParams = parser.extractParameters(content, 'Initialization'); +const perfParams = parser.extractParameters(content, 'Performance'); + +console.log('\n=== extractParameters results ==='); +console.log(`Initialization params: ${initParams.length}`); +initParams.forEach(p => { + console.log(` - ${p.name}: ${p.description.substring(0, 60)}...`); +}); + +console.log(`\nPerformance params: ${perfParams.length}`); +perfParams.forEach(p => { + console.log(` - ${p.name}: ${p.description.substring(0, 60)}...`); +}); diff --git a/scripts/csound-parser/debug-section.ts b/scripts/csound-parser/debug-section.ts new file mode 100644 index 0000000..93ea87f --- /dev/null +++ b/scripts/csound-parser/debug-section.ts @@ -0,0 +1,30 @@ +import * as fs from 'fs'; + +const content = fs.readFileSync('downloaded-opcodes/moogladder.md', 'utf-8'); + +console.log('Full content length:', content.length); +console.log('\n=== Testing extractSection regex ===\n'); + +const regex = /##\s+Syntax\s*\n([\s\S]*?)(?=\n##|$)/i; +const match = content.match(regex); + +if (match) { + console.log('Match found!'); + console.log('Captured content length:', match[1].length); + console.log('\nFull captured content:'); + console.log('---START---'); + console.log(match[1]); + console.log('---END---'); +} else { + console.log('No match found'); +} + +// Also check what comes after +const syntaxIndex = content.indexOf('## Syntax'); +const examplesIndex = content.indexOf('## Examples'); +console.log('\n=== Indices ==='); +console.log('## Syntax at:', syntaxIndex); +console.log('## Examples at:', examplesIndex); +console.log('Distance:', examplesIndex - syntaxIndex); +console.log('\nContent between (first 500 chars):'); +console.log(content.substring(syntaxIndex, syntaxIndex + 500)); diff --git a/scripts/csound-parser/downloader.ts b/scripts/csound-parser/downloader.ts new file mode 100644 index 0000000..39a67c6 --- /dev/null +++ b/scripts/csound-parser/downloader.ts @@ -0,0 +1,123 @@ +import * as fs from 'fs'; +import * as path from 'path'; +import * as https from 'https'; + +interface GitHubFile { + name: string; + download_url: string; + type: string; +} + +export class GitHubDownloader { + private apiBase = 'https://api.github.com/repos/csound/manual/contents'; + private branch = 'develop'; + private downloadDir: string; + + constructor(downloadDir: string) { + this.downloadDir = downloadDir; + } + + private async fetchJson(url: string): Promise { + return new Promise((resolve, reject) => { + https.get( + url, + { + headers: { + 'User-Agent': 'Csound-Parser', + }, + }, + (res) => { + let data = ''; + + res.on('data', (chunk) => { + data += chunk; + }); + + res.on('end', () => { + if (res.statusCode === 200) { + try { + resolve(JSON.parse(data)); + } catch (err) { + reject(new Error(`Failed to parse JSON: ${err}`)); + } + } else { + reject(new Error(`HTTP ${res.statusCode}: ${data}`)); + } + }); + } + ).on('error', reject); + }); + } + + private async downloadFile(url: string, destPath: string): Promise { + return new Promise((resolve, reject) => { + https.get(url, (res) => { + if (res.statusCode === 302 || res.statusCode === 301) { + if (res.headers.location) { + this.downloadFile(res.headers.location, destPath).then(resolve).catch(reject); + return; + } + } + + const fileStream = fs.createWriteStream(destPath); + res.pipe(fileStream); + + fileStream.on('finish', () => { + fileStream.close(); + resolve(); + }); + + fileStream.on('error', (err) => { + fs.unlink(destPath, () => {}); + reject(err); + }); + }).on('error', reject); + }); + } + + async downloadOpcodes(): Promise { + console.log('Fetching opcode list from GitHub...'); + + const url = `${this.apiBase}/docs/opcodes?ref=${this.branch}`; + const files = await this.fetchJson(url); + + const markdownFiles = files.filter(f => f.type === 'file' && f.name.endsWith('.md')); + + console.log(`Found ${markdownFiles.length} markdown files`); + + if (!fs.existsSync(this.downloadDir)) { + fs.mkdirSync(this.downloadDir, { recursive: true }); + } + + let downloaded = 0; + let failed = 0; + + for (const file of markdownFiles) { + const destPath = path.join(this.downloadDir, file.name); + + try { + await this.downloadFile(file.download_url, destPath); + downloaded++; + + if (downloaded % 50 === 0) { + console.log(`Downloaded ${downloaded}/${markdownFiles.length}...`); + } + } catch (err) { + console.error(`Failed to download ${file.name}:`, err); + failed++; + } + } + + console.log(`\nDownloaded ${downloaded} files, ${failed} failed`); + return downloaded; + } + + async downloadCategories(): Promise { + console.log('Downloading categories.py...'); + const url = 'https://raw.githubusercontent.com/csound/manual/develop/categories.py'; + const destPath = path.join(this.downloadDir, 'categories.py'); + + await this.downloadFile(url, destPath); + console.log('Categories file downloaded'); + } +} diff --git a/scripts/csound-parser/generator.ts b/scripts/csound-parser/generator.ts new file mode 100644 index 0000000..2326642 --- /dev/null +++ b/scripts/csound-parser/generator.ts @@ -0,0 +1,207 @@ +import * as fs from 'fs'; +import * as path from 'path'; +import type { CsoundReference } from './types'; + +export class TypeScriptGenerator { + private outputDir: string; + + constructor(outputDir: string) { + this.outputDir = outputDir; + } + + sanitizeCategoryName(category: string): string { + return category + .toLowerCase() + .replace(/[^a-z0-9]+/g, '-') + .replace(/^-+|-+$/g, ''); + } + + sanitizeVariableName(category: string): string { + return category + .replace(/[^a-zA-Z0-9]+/g, ' ') + .split(' ') + .map((word, index) => + index === 0 + ? word.toLowerCase() + : word.charAt(0).toUpperCase() + word.slice(1).toLowerCase() + ) + .join('') + .replace(/^[0-9]/, '_$&'); + } + + escapeString(str: string): string { + return str + .replace(/\\/g, '\\\\') + .replace(/'/g, "\\'") + .replace(/\n/g, '\\n') + .replace(/\r/g, '\\r') + .replace(/\t/g, '\\t'); + } + + generateReferenceObject(ref: CsoundReference, indent: string = ' '): string { + const lines: string[] = []; + lines.push(`{`); + lines.push(`${indent}name: '${this.escapeString(ref.name)}',`); + lines.push(`${indent}type: '${ref.type}',`); + lines.push(`${indent}category: '${this.escapeString(ref.category)}',`); + lines.push(`${indent}description: '${this.escapeString(ref.description)}',`); + + if (ref.syntax) { + lines.push(`${indent}syntax: '${this.escapeString(ref.syntax)}',`); + } + + if (ref.example) { + const escapedExample = this.escapeString(ref.example); + lines.push(`${indent}example: '${escapedExample}',`); + } + + if (ref.rates && ref.rates.length > 0) { + lines.push(`${indent}rates: [${ref.rates.map(r => `'${r}'`).join(', ')}],`); + } + + if (ref.parameters && ref.parameters.length > 0) { + lines.push(`${indent}parameters: [`); + for (const param of ref.parameters) { + lines.push(`${indent} {`); + lines.push(`${indent} name: '${this.escapeString(param.name)}',`); + lines.push(`${indent} description: '${this.escapeString(param.description)}',`); + lines.push(`${indent} type: '${param.type}'`); + lines.push(`${indent} },`); + } + lines.push(`${indent}],`); + } + + if (ref.seeAlso && ref.seeAlso.length > 0) { + lines.push(`${indent}seeAlso: [${ref.seeAlso.map(s => `'${this.escapeString(s)}'`).join(', ')}]`); + } + + lines.push(`}`); + return lines.join('\n'); + } + + generateCategoryFile( + category: string, + references: CsoundReference[], + fileName: string + ): string { + const varName = this.sanitizeVariableName(category); + + const lines: string[] = []; + lines.push(`import type { CsoundReference } from './types'`); + lines.push(``); + lines.push(`// ${category}`); + lines.push(`export const ${varName}: CsoundReference[] = [`); + + for (const ref of references) { + const refLines = this.generateReferenceObject(ref, ' '); + lines.push(refLines + ','); + } + + lines.push(`]`); + lines.push(``); + + return lines.join('\n'); + } + + generateMainFile(categories: Map): string { + const lines: string[] = []; + + lines.push(`import type { CsoundReference } from './types'`); + + const imports: string[] = []; + const varNames: string[] = []; + + for (const [category] of categories) { + const fileName = this.sanitizeCategoryName(category); + const varName = this.sanitizeVariableName(category); + imports.push(`import { ${varName} } from './${fileName}'`); + varNames.push(varName); + } + + lines.push(...imports); + lines.push(``); + lines.push(`export type { CsoundReference }`); + lines.push(``); + lines.push(`export const allCsoundReferences: CsoundReference[] = [`); + for (const varName of varNames) { + lines.push(` ...${varName},`); + } + lines.push(`]`); + lines.push(``); + + lines.push(`export const csoundReferenceMap = new Map()`); + lines.push(`allCsoundReferences.forEach(ref => {`); + lines.push(` csoundReferenceMap.set(ref.name, ref)`); + lines.push(`})`); + lines.push(``); + + lines.push(`export function getCsoundReference(name: string): CsoundReference | undefined {`); + lines.push(` return csoundReferenceMap.get(name)`); + lines.push(`}`); + lines.push(``); + + lines.push(`export function getCsoundReferencesByCategory(category: string): CsoundReference[] {`); + lines.push(` return allCsoundReferences.filter(ref => ref.category === category)`); + lines.push(`}`); + lines.push(``); + + lines.push(`export {`); + for (const varName of varNames) { + lines.push(` ${varName},`); + } + lines.push(`}`); + lines.push(``); + + return lines.join('\n'); + } + + writeCategoryFiles(categories: Map): void { + if (!fs.existsSync(this.outputDir)) { + fs.mkdirSync(this.outputDir, { recursive: true }); + } + + let fileCount = 0; + + for (const [category, references] of categories) { + const fileName = this.sanitizeCategoryName(category); + const filePath = path.join(this.outputDir, `${fileName}.ts`); + const content = this.generateCategoryFile(category, references, fileName); + + fs.writeFileSync(filePath, content, 'utf-8'); + fileCount++; + console.log(`Generated: ${fileName}.ts (${references.length} opcodes)`); + } + + console.log(`\nGenerated ${fileCount} category files`); + } + + writeMainFile(categories: Map): void { + const filePath = path.join(this.outputDir, 'csoundReference.ts'); + const content = this.generateMainFile(categories); + + fs.writeFileSync(filePath, content, 'utf-8'); + console.log(`Generated: csoundReference.ts`); + } + + copyTypes(): void { + if (!fs.existsSync(this.outputDir)) { + fs.mkdirSync(this.outputDir, { recursive: true }); + } + + const sourceTypes = path.join(__dirname, 'types.ts'); + const destTypes = path.join(this.outputDir, 'types.ts'); + + if (fs.existsSync(sourceTypes)) { + fs.copyFileSync(sourceTypes, destTypes); + console.log(`Copied: types.ts`); + } + } + + generateAll(categories: Map): void { + console.log(`\nGenerating TypeScript files...`); + this.copyTypes(); + this.writeCategoryFiles(categories); + this.writeMainFile(categories); + console.log(`\nDone!`); + } +} diff --git a/scripts/csound-parser/index.ts b/scripts/csound-parser/index.ts new file mode 100644 index 0000000..7e8ab57 --- /dev/null +++ b/scripts/csound-parser/index.ts @@ -0,0 +1,92 @@ +#!/usr/bin/env node + +import * as path from 'path'; +import { CsoundManualParser } from './parser'; +import { TypeScriptGenerator } from './generator'; +import { GitHubDownloader } from './downloader'; + +const DOWNLOAD_DIR = path.join(__dirname, 'downloaded-opcodes'); +const OUTPUT_DIR = path.join(__dirname, '../../src/lib/csound-reference'); + +async function main() { + const args = process.argv.slice(2); + const shouldDownload = args.includes('--download') || args.includes('-d'); + const inputDir = args.find(arg => arg.startsWith('--input='))?.split('=')[1] || DOWNLOAD_DIR; + const outputDir = args.find(arg => arg.startsWith('--output='))?.split('=')[1] || OUTPUT_DIR; + + console.log('='.repeat(60)); + console.log('Csound Manual Parser'); + console.log('='.repeat(60)); + + if (shouldDownload) { + console.log('\nStep 1: Downloading markdown files from GitHub...'); + const downloader = new GitHubDownloader(DOWNLOAD_DIR); + + try { + await downloader.downloadOpcodes(); + await downloader.downloadCategories(); + } catch (err) { + console.error('Download failed:', err); + console.log('\nYou can also manually clone the repository:'); + console.log(' git clone https://github.com/csound/manual.git'); + console.log(' Then run: npm run parse -- --input=manual/docs/opcodes'); + process.exit(1); + } + } else { + console.log(`\nUsing existing files from: ${inputDir}`); + console.log('(Use --download or -d to download fresh files from GitHub)'); + } + + console.log('\nStep 2: Parsing markdown files...'); + const parser = new CsoundManualParser(); + + try { + parser.parseDirectory(inputDir); + } catch (err) { + console.error('Parsing failed:', err); + console.log('\nMake sure the input directory exists and contains .md files'); + console.log(`Input directory: ${inputDir}`); + process.exit(1); + } + + const opcodeCount = parser.getOpcodes().length; + console.log(`\nParsed ${opcodeCount} opcodes`); + + if (opcodeCount === 0) { + console.error('No opcodes found. Check the input directory.'); + process.exit(1); + } + + console.log('\nStep 3: Grouping by category...'); + const categoriesMap = parser.getReferencesByCategory(); + console.log(`Found ${categoriesMap.size} categories`); + + const topCategories = Array.from(categoriesMap.entries()) + .sort((a, b) => b[1].length - a[1].length) + .slice(0, 10); + + console.log('\nTop 10 categories by opcode count:'); + for (const [category, refs] of topCategories) { + console.log(` - ${category}: ${refs.length} opcodes`); + } + + console.log('\nStep 4: Generating TypeScript files...'); + const generator = new TypeScriptGenerator(outputDir); + generator.generateAll(categoriesMap); + + console.log('\n' + '='.repeat(60)); + console.log('Success!'); + console.log('='.repeat(60)); + console.log(`\nGenerated files in: ${outputDir}`); + console.log(`Total opcodes: ${opcodeCount}`); + console.log(`Total categories: ${categoriesMap.size}`); + console.log('\nYou can now import the reference in your application:'); + console.log(` import { allCsoundReferences, getCsoundReference } from './lib/csound-reference/csoundReference'`); +} + +if (require.main === module) { + main().catch(err => { + console.error('Fatal error:', err); + process.exit(1); + }); +} diff --git a/scripts/csound-parser/package.json b/scripts/csound-parser/package.json new file mode 100644 index 0000000..71b90c3 --- /dev/null +++ b/scripts/csound-parser/package.json @@ -0,0 +1,26 @@ +{ + "name": "csound-manual-parser", + "version": "1.0.0", + "description": "Parser for Csound manual to generate TypeScript reference files", + "main": "index.ts", + "scripts": { + "parse": "tsx index.ts", + "download": "tsx index.ts --download", + "build": "tsc" + }, + "keywords": [ + "csound", + "parser", + "documentation" + ], + "author": "", + "license": "MIT", + "devDependencies": { + "@types/node": "^20.0.0", + "tsx": "^4.0.0", + "typescript": "^5.0.0" + }, + "dependencies": { + "fuse.js": "^7.1.0" + } +} diff --git a/scripts/csound-parser/parser.ts b/scripts/csound-parser/parser.ts new file mode 100644 index 0000000..6b20201 --- /dev/null +++ b/scripts/csound-parser/parser.ts @@ -0,0 +1,245 @@ +import * as fs from 'fs'; +import * as path from 'path'; +import type { ParsedOpcode, CsoundReference } from './types'; + +interface FrontMatter { + id?: string; + category?: string; +} + +export class CsoundManualParser { + private opcodes: Map = new Map(); + + parseFrontMatter(content: string): FrontMatter { + const frontMatterMatch = content.match(/^/); + if (!frontMatterMatch) return {}; + + const frontMatter: FrontMatter = {}; + const lines = frontMatterMatch[1].split('\n'); + + for (const line of lines) { + const [key, ...valueParts] = line.split(':'); + if (key && valueParts.length > 0) { + const trimmedKey = key.trim(); + const value = valueParts.join(':').trim(); + if (trimmedKey === 'id') frontMatter.id = value; + if (trimmedKey === 'category') frontMatter.category = value; + } + } + + return frontMatter; + } + + extractFirstParagraph(content: string): string { + const withoutFrontMatter = content.replace(/^\n/, ''); + const withoutTitle = withoutFrontMatter.replace(/^#\s+.*\n/, ''); + + const lines = withoutTitle.split('\n'); + const paragraphLines: string[] = []; + + for (const line of lines) { + const trimmed = line.trim(); + if (trimmed === '') { + if (paragraphLines.length > 0) break; + continue; + } + if (trimmed.startsWith('#')) break; + paragraphLines.push(trimmed); + } + + return paragraphLines.join(' ').trim(); + } + + extractSection(content: string, sectionTitle: string): string { + const regex = new RegExp(`##\\s+${sectionTitle}\\s*\\n([\\s\\S]*?)(?=\\n##(?!#)|$)`, 'i'); + const match = content.match(regex); + return match ? match[1].trim() : ''; + } + + extractSyntax(content: string): { modern?: string; classic?: string } { + const syntaxSection = this.extractSection(content, 'Syntax'); + if (!syntaxSection) return {}; + + const modernMatch = syntaxSection.match(/===\s*"Modern"[\s\S]*?```[\s\S]*?\n([\s\S]*?)```/); + const classicMatch = syntaxSection.match(/===\s*"Classic"[\s\S]*?```[\s\S]*?\n([\s\S]*?)```/); + + return { + modern: modernMatch ? modernMatch[1].trim() : undefined, + classic: classicMatch ? classicMatch[1].trim() : undefined, + }; + } + + extractParameters(content: string, subsectionTitle: string): { name: string; description: string }[] { + const syntaxSection = this.extractSection(content, 'Syntax'); + const subsectionRegex = new RegExp(`###\\s+${subsectionTitle}\\s*\\n([\\s\\S]*?)(?=\\n###|\\n##|$)`, 'i'); + const match = syntaxSection.match(subsectionRegex); + + if (!match) return []; + + const subsectionContent = match[1]; + const params: { name: string; description: string }[] = []; + + const paramMatches = subsectionContent.matchAll(/_([a-zA-Z0-9_,\s/]+)_\s*[-–—]+\s*([^\n]+(?:\n(?!_)[^\n]+)*)/g); + + for (const paramMatch of paramMatches) { + const names = paramMatch[1] + .split(/[,/]/) + .map(n => n.trim().replace(/^_+|_+$/g, '')) + .filter(n => n.length > 0); + const description = paramMatch[2].trim().replace(/\s+/g, ' '); + + for (const name of names) { + params.push({ name, description }); + } + } + + return params; + } + + extractExample(content: string): string | undefined { + const exampleSection = this.extractSection(content, 'Examples'); + if (!exampleSection) return undefined; + + const codeMatch = exampleSection.match(/```[\s\S]*?\n([\s\S]*?)```/); + return codeMatch ? codeMatch[1].trim() : undefined; + } + + extractSeeAlso(content: string): string[] { + const seeAlsoSection = this.extractSection(content, 'See also'); + if (!seeAlsoSection) return []; + + const links = seeAlsoSection.matchAll(/\[([^\]]+)\]/g); + return Array.from(links, match => match[1]); + } + + parseMarkdownFile(filePath: string, content: string): ParsedOpcode | null { + try { + const frontMatter = this.parseFrontMatter(content); + + if (!frontMatter.id || !frontMatter.category) { + console.warn(`Skipping ${filePath}: missing id or category`); + return null; + } + + const description = this.extractFirstParagraph(content); + const syntax = this.extractSyntax(content); + const initParams = this.extractParameters(content, 'Initialization'); + const perfParams = this.extractParameters(content, 'Performance'); + const example = this.extractExample(content); + const seeAlso = this.extractSeeAlso(content); + + return { + id: frontMatter.id, + category: frontMatter.category, + title: frontMatter.id, + description, + syntaxModern: syntax.modern, + syntaxClassic: syntax.classic, + initParams, + perfParams, + example, + seeAlso, + rawContent: content, + }; + } catch (error) { + console.error(`Error parsing ${filePath}:`, error); + return null; + } + } + + parseDirectory(dirPath: string): void { + if (!fs.existsSync(dirPath)) { + throw new Error(`Directory not found: ${dirPath}`); + } + + const files = fs.readdirSync(dirPath); + let parsed = 0; + let skipped = 0; + + for (const file of files) { + if (!file.endsWith('.md')) continue; + + const filePath = path.join(dirPath, file); + const content = fs.readFileSync(filePath, 'utf-8'); + const opcode = this.parseMarkdownFile(file, content); + + if (opcode) { + this.opcodes.set(opcode.id, opcode); + parsed++; + } else { + skipped++; + } + } + + console.log(`Parsed ${parsed} opcodes, skipped ${skipped}`); + } + + convertToReference(opcode: ParsedOpcode): CsoundReference { + const syntax = opcode.syntaxModern || opcode.syntaxClassic; + + const parameters = [ + ...opcode.initParams.map(p => ({ ...p, type: 'initialization' as const })), + ...opcode.perfParams.map(p => ({ ...p, type: 'performance' as const })), + ]; + + const rates = this.extractRates(syntax || ''); + + return { + name: opcode.id, + type: 'opcode', + category: opcode.category, + description: opcode.description, + syntax, + example: opcode.example, + rates, + parameters: parameters.length > 0 ? parameters : undefined, + seeAlso: opcode.seeAlso.length > 0 ? opcode.seeAlso : undefined, + }; + } + + private extractRates(syntax: string): string[] { + const rates: Set = new Set(); + + if (/\bares\b|\basin\b|\basig\b/.test(syntax)) rates.add('a-rate'); + if (/\bkres\b|\bkamp\b|\bkcps\b|\bkin\b/.test(syntax)) rates.add('k-rate'); + if (/\bires\b|\bifn\b|\biphs\b/.test(syntax)) rates.add('i-rate'); + + return Array.from(rates); + } + + getOpcodes(): ParsedOpcode[] { + return Array.from(this.opcodes.values()); + } + + getOpcodesByCategory(): Map { + const categories = new Map(); + + for (const opcode of this.opcodes.values()) { + const category = opcode.category; + if (!categories.has(category)) { + categories.set(category, []); + } + categories.get(category)!.push(opcode); + } + + return categories; + } + + getReferences(): CsoundReference[] { + return this.getOpcodes().map(op => this.convertToReference(op)); + } + + getReferencesByCategory(): Map { + const categories = new Map(); + + for (const opcode of this.opcodes.values()) { + const category = opcode.category; + if (!categories.has(category)) { + categories.set(category, []); + } + categories.get(category)!.push(this.convertToReference(opcode)); + } + + return categories; + } +} diff --git a/scripts/csound-parser/pnpm-lock.yaml b/scripts/csound-parser/pnpm-lock.yaml new file mode 100644 index 0000000..817b8bb --- /dev/null +++ b/scripts/csound-parser/pnpm-lock.yaml @@ -0,0 +1,352 @@ +lockfileVersion: '9.0' + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + +importers: + + .: + dependencies: + fuse.js: + specifier: ^7.1.0 + version: 7.1.0 + devDependencies: + '@types/node': + specifier: ^20.0.0 + version: 20.19.21 + tsx: + specifier: ^4.0.0 + version: 4.20.6 + typescript: + specifier: ^5.0.0 + version: 5.9.3 + +packages: + + '@esbuild/aix-ppc64@0.25.11': + resolution: {integrity: sha512-Xt1dOL13m8u0WE8iplx9Ibbm+hFAO0GsU2P34UNoDGvZYkY8ifSiy6Zuc1lYxfG7svWE2fzqCUmFp5HCn51gJg==} + engines: {node: '>=18'} + cpu: [ppc64] + os: [aix] + + '@esbuild/android-arm64@0.25.11': + resolution: {integrity: sha512-9slpyFBc4FPPz48+f6jyiXOx/Y4v34TUeDDXJpZqAWQn/08lKGeD8aDp9TMn9jDz2CiEuHwfhRmGBvpnd/PWIQ==} + engines: {node: '>=18'} + cpu: [arm64] + os: [android] + + '@esbuild/android-arm@0.25.11': + resolution: {integrity: sha512-uoa7dU+Dt3HYsethkJ1k6Z9YdcHjTrSb5NUy66ZfZaSV8hEYGD5ZHbEMXnqLFlbBflLsl89Zke7CAdDJ4JI+Gg==} + engines: {node: '>=18'} + cpu: [arm] + os: [android] + + '@esbuild/android-x64@0.25.11': + resolution: {integrity: sha512-Sgiab4xBjPU1QoPEIqS3Xx+R2lezu0LKIEcYe6pftr56PqPygbB7+szVnzoShbx64MUupqoE0KyRlN7gezbl8g==} + engines: {node: '>=18'} + cpu: [x64] + os: [android] + + '@esbuild/darwin-arm64@0.25.11': + resolution: {integrity: sha512-VekY0PBCukppoQrycFxUqkCojnTQhdec0vevUL/EDOCnXd9LKWqD/bHwMPzigIJXPhC59Vd1WFIL57SKs2mg4w==} + engines: {node: '>=18'} + cpu: [arm64] + os: [darwin] + + '@esbuild/darwin-x64@0.25.11': + resolution: {integrity: sha512-+hfp3yfBalNEpTGp9loYgbknjR695HkqtY3d3/JjSRUyPg/xd6q+mQqIb5qdywnDxRZykIHs3axEqU6l1+oWEQ==} + engines: {node: '>=18'} + cpu: [x64] + os: [darwin] + + '@esbuild/freebsd-arm64@0.25.11': + resolution: {integrity: sha512-CmKjrnayyTJF2eVuO//uSjl/K3KsMIeYeyN7FyDBjsR3lnSJHaXlVoAK8DZa7lXWChbuOk7NjAc7ygAwrnPBhA==} + engines: {node: '>=18'} + cpu: [arm64] + os: [freebsd] + + '@esbuild/freebsd-x64@0.25.11': + resolution: {integrity: sha512-Dyq+5oscTJvMaYPvW3x3FLpi2+gSZTCE/1ffdwuM6G1ARang/mb3jvjxs0mw6n3Lsw84ocfo9CrNMqc5lTfGOw==} + engines: {node: '>=18'} + cpu: [x64] + os: [freebsd] + + '@esbuild/linux-arm64@0.25.11': + resolution: {integrity: sha512-Qr8AzcplUhGvdyUF08A1kHU3Vr2O88xxP0Tm8GcdVOUm25XYcMPp2YqSVHbLuXzYQMf9Bh/iKx7YPqECs6ffLA==} + engines: {node: '>=18'} + cpu: [arm64] + os: [linux] + + '@esbuild/linux-arm@0.25.11': + resolution: {integrity: sha512-TBMv6B4kCfrGJ8cUPo7vd6NECZH/8hPpBHHlYI3qzoYFvWu2AdTvZNuU/7hsbKWqu/COU7NIK12dHAAqBLLXgw==} + engines: {node: '>=18'} + cpu: [arm] + os: [linux] + + '@esbuild/linux-ia32@0.25.11': + resolution: {integrity: sha512-TmnJg8BMGPehs5JKrCLqyWTVAvielc615jbkOirATQvWWB1NMXY77oLMzsUjRLa0+ngecEmDGqt5jiDC6bfvOw==} + engines: {node: '>=18'} + cpu: [ia32] + os: [linux] + + '@esbuild/linux-loong64@0.25.11': + resolution: {integrity: sha512-DIGXL2+gvDaXlaq8xruNXUJdT5tF+SBbJQKbWy/0J7OhU8gOHOzKmGIlfTTl6nHaCOoipxQbuJi7O++ldrxgMw==} + engines: {node: '>=18'} + cpu: [loong64] + os: [linux] + + '@esbuild/linux-mips64el@0.25.11': + resolution: {integrity: sha512-Osx1nALUJu4pU43o9OyjSCXokFkFbyzjXb6VhGIJZQ5JZi8ylCQ9/LFagolPsHtgw6himDSyb5ETSfmp4rpiKQ==} + engines: {node: '>=18'} + cpu: [mips64el] + os: [linux] + + '@esbuild/linux-ppc64@0.25.11': + resolution: {integrity: sha512-nbLFgsQQEsBa8XSgSTSlrnBSrpoWh7ioFDUmwo158gIm5NNP+17IYmNWzaIzWmgCxq56vfr34xGkOcZ7jX6CPw==} + engines: {node: '>=18'} + cpu: [ppc64] + os: [linux] + + '@esbuild/linux-riscv64@0.25.11': + resolution: {integrity: sha512-HfyAmqZi9uBAbgKYP1yGuI7tSREXwIb438q0nqvlpxAOs3XnZ8RsisRfmVsgV486NdjD7Mw2UrFSw51lzUk1ww==} + engines: {node: '>=18'} + cpu: [riscv64] + os: [linux] + + '@esbuild/linux-s390x@0.25.11': + resolution: {integrity: sha512-HjLqVgSSYnVXRisyfmzsH6mXqyvj0SA7pG5g+9W7ESgwA70AXYNpfKBqh1KbTxmQVaYxpzA/SvlB9oclGPbApw==} + engines: {node: '>=18'} + cpu: [s390x] + os: [linux] + + '@esbuild/linux-x64@0.25.11': + resolution: {integrity: sha512-HSFAT4+WYjIhrHxKBwGmOOSpphjYkcswF449j6EjsjbinTZbp8PJtjsVK1XFJStdzXdy/jaddAep2FGY+wyFAQ==} + engines: {node: '>=18'} + cpu: [x64] + os: [linux] + + '@esbuild/netbsd-arm64@0.25.11': + resolution: {integrity: sha512-hr9Oxj1Fa4r04dNpWr3P8QKVVsjQhqrMSUzZzf+LZcYjZNqhA3IAfPQdEh1FLVUJSiu6sgAwp3OmwBfbFgG2Xg==} + engines: {node: '>=18'} + cpu: [arm64] + os: [netbsd] + + '@esbuild/netbsd-x64@0.25.11': + resolution: {integrity: sha512-u7tKA+qbzBydyj0vgpu+5h5AeudxOAGncb8N6C9Kh1N4n7wU1Xw1JDApsRjpShRpXRQlJLb9wY28ELpwdPcZ7A==} + engines: {node: '>=18'} + cpu: [x64] + os: [netbsd] + + '@esbuild/openbsd-arm64@0.25.11': + resolution: {integrity: sha512-Qq6YHhayieor3DxFOoYM1q0q1uMFYb7cSpLD2qzDSvK1NAvqFi8Xgivv0cFC6J+hWVw2teCYltyy9/m/14ryHg==} + engines: {node: '>=18'} + cpu: [arm64] + os: [openbsd] + + '@esbuild/openbsd-x64@0.25.11': + resolution: {integrity: sha512-CN+7c++kkbrckTOz5hrehxWN7uIhFFlmS/hqziSFVWpAzpWrQoAG4chH+nN3Be+Kzv/uuo7zhX716x3Sn2Jduw==} + engines: {node: '>=18'} + cpu: [x64] + os: [openbsd] + + '@esbuild/openharmony-arm64@0.25.11': + resolution: {integrity: sha512-rOREuNIQgaiR+9QuNkbkxubbp8MSO9rONmwP5nKncnWJ9v5jQ4JxFnLu4zDSRPf3x4u+2VN4pM4RdyIzDty/wQ==} + engines: {node: '>=18'} + cpu: [arm64] + os: [openharmony] + + '@esbuild/sunos-x64@0.25.11': + resolution: {integrity: sha512-nq2xdYaWxyg9DcIyXkZhcYulC6pQ2FuCgem3LI92IwMgIZ69KHeY8T4Y88pcwoLIjbed8n36CyKoYRDygNSGhA==} + engines: {node: '>=18'} + cpu: [x64] + os: [sunos] + + '@esbuild/win32-arm64@0.25.11': + resolution: {integrity: sha512-3XxECOWJq1qMZ3MN8srCJ/QfoLpL+VaxD/WfNRm1O3B4+AZ/BnLVgFbUV3eiRYDMXetciH16dwPbbHqwe1uU0Q==} + engines: {node: '>=18'} + cpu: [arm64] + os: [win32] + + '@esbuild/win32-ia32@0.25.11': + resolution: {integrity: sha512-3ukss6gb9XZ8TlRyJlgLn17ecsK4NSQTmdIXRASVsiS2sQ6zPPZklNJT5GR5tE/MUarymmy8kCEf5xPCNCqVOA==} + engines: {node: '>=18'} + cpu: [ia32] + os: [win32] + + '@esbuild/win32-x64@0.25.11': + resolution: {integrity: sha512-D7Hpz6A2L4hzsRpPaCYkQnGOotdUpDzSGRIv9I+1ITdHROSFUWW95ZPZWQmGka1Fg7W3zFJowyn9WGwMJ0+KPA==} + engines: {node: '>=18'} + cpu: [x64] + os: [win32] + + '@types/node@20.19.21': + resolution: {integrity: sha512-CsGG2P3I5y48RPMfprQGfy4JPRZ6csfC3ltBZSRItG3ngggmNY/qs2uZKp4p9VbrpqNNSMzUZNFZKzgOGnd/VA==} + + esbuild@0.25.11: + resolution: {integrity: sha512-KohQwyzrKTQmhXDW1PjCv3Tyspn9n5GcY2RTDqeORIdIJY8yKIF7sTSopFmn/wpMPW4rdPXI0UE5LJLuq3bx0Q==} + engines: {node: '>=18'} + hasBin: true + + fsevents@2.3.3: + resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==} + engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} + os: [darwin] + + fuse.js@7.1.0: + resolution: {integrity: sha512-trLf4SzuuUxfusZADLINj+dE8clK1frKdmqiJNb1Es75fmI5oY6X2mxLVUciLLjxqw/xr72Dhy+lER6dGd02FQ==} + engines: {node: '>=10'} + + get-tsconfig@4.12.0: + resolution: {integrity: sha512-LScr2aNr2FbjAjZh2C6X6BxRx1/x+aTDExct/xyq2XKbYOiG5c0aK7pMsSuyc0brz3ibr/lbQiHD9jzt4lccJw==} + + resolve-pkg-maps@1.0.0: + resolution: {integrity: sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==} + + tsx@4.20.6: + resolution: {integrity: sha512-ytQKuwgmrrkDTFP4LjR0ToE2nqgy886GpvRSpU0JAnrdBYppuY5rLkRUYPU1yCryb24SsKBTL/hlDQAEFVwtZg==} + engines: {node: '>=18.0.0'} + hasBin: true + + typescript@5.9.3: + resolution: {integrity: sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==} + engines: {node: '>=14.17'} + hasBin: true + + undici-types@6.21.0: + resolution: {integrity: sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==} + +snapshots: + + '@esbuild/aix-ppc64@0.25.11': + optional: true + + '@esbuild/android-arm64@0.25.11': + optional: true + + '@esbuild/android-arm@0.25.11': + optional: true + + '@esbuild/android-x64@0.25.11': + optional: true + + '@esbuild/darwin-arm64@0.25.11': + optional: true + + '@esbuild/darwin-x64@0.25.11': + optional: true + + '@esbuild/freebsd-arm64@0.25.11': + optional: true + + '@esbuild/freebsd-x64@0.25.11': + optional: true + + '@esbuild/linux-arm64@0.25.11': + optional: true + + '@esbuild/linux-arm@0.25.11': + optional: true + + '@esbuild/linux-ia32@0.25.11': + optional: true + + '@esbuild/linux-loong64@0.25.11': + optional: true + + '@esbuild/linux-mips64el@0.25.11': + optional: true + + '@esbuild/linux-ppc64@0.25.11': + optional: true + + '@esbuild/linux-riscv64@0.25.11': + optional: true + + '@esbuild/linux-s390x@0.25.11': + optional: true + + '@esbuild/linux-x64@0.25.11': + optional: true + + '@esbuild/netbsd-arm64@0.25.11': + optional: true + + '@esbuild/netbsd-x64@0.25.11': + optional: true + + '@esbuild/openbsd-arm64@0.25.11': + optional: true + + '@esbuild/openbsd-x64@0.25.11': + optional: true + + '@esbuild/openharmony-arm64@0.25.11': + optional: true + + '@esbuild/sunos-x64@0.25.11': + optional: true + + '@esbuild/win32-arm64@0.25.11': + optional: true + + '@esbuild/win32-ia32@0.25.11': + optional: true + + '@esbuild/win32-x64@0.25.11': + optional: true + + '@types/node@20.19.21': + dependencies: + undici-types: 6.21.0 + + esbuild@0.25.11: + optionalDependencies: + '@esbuild/aix-ppc64': 0.25.11 + '@esbuild/android-arm': 0.25.11 + '@esbuild/android-arm64': 0.25.11 + '@esbuild/android-x64': 0.25.11 + '@esbuild/darwin-arm64': 0.25.11 + '@esbuild/darwin-x64': 0.25.11 + '@esbuild/freebsd-arm64': 0.25.11 + '@esbuild/freebsd-x64': 0.25.11 + '@esbuild/linux-arm': 0.25.11 + '@esbuild/linux-arm64': 0.25.11 + '@esbuild/linux-ia32': 0.25.11 + '@esbuild/linux-loong64': 0.25.11 + '@esbuild/linux-mips64el': 0.25.11 + '@esbuild/linux-ppc64': 0.25.11 + '@esbuild/linux-riscv64': 0.25.11 + '@esbuild/linux-s390x': 0.25.11 + '@esbuild/linux-x64': 0.25.11 + '@esbuild/netbsd-arm64': 0.25.11 + '@esbuild/netbsd-x64': 0.25.11 + '@esbuild/openbsd-arm64': 0.25.11 + '@esbuild/openbsd-x64': 0.25.11 + '@esbuild/openharmony-arm64': 0.25.11 + '@esbuild/sunos-x64': 0.25.11 + '@esbuild/win32-arm64': 0.25.11 + '@esbuild/win32-ia32': 0.25.11 + '@esbuild/win32-x64': 0.25.11 + + fsevents@2.3.3: + optional: true + + fuse.js@7.1.0: {} + + get-tsconfig@4.12.0: + dependencies: + resolve-pkg-maps: 1.0.0 + + resolve-pkg-maps@1.0.0: {} + + tsx@4.20.6: + dependencies: + esbuild: 0.25.11 + get-tsconfig: 4.12.0 + optionalDependencies: + fsevents: 2.3.3 + + typescript@5.9.3: {} + + undici-types@6.21.0: {} diff --git a/scripts/csound-parser/test-output.ts b/scripts/csound-parser/test-output.ts new file mode 100644 index 0000000..1d06db8 --- /dev/null +++ b/scripts/csound-parser/test-output.ts @@ -0,0 +1,71 @@ +import { + allCsoundReferences, + getCsoundReference, + getCsoundReferencesByCategory +} from '../../src/lib/csound-reference/csoundReference'; + +console.log('='.repeat(60)); +console.log('Csound Reference Output Test'); +console.log('='.repeat(60)); + +console.log(`\nTotal opcodes: ${allCsoundReferences.length}`); + +console.log('\n--- Testing getCsoundReference() ---'); +const oscil = getCsoundReference('oscil'); +if (oscil) { + console.log(`\nFound oscil:`); + console.log(` Name: ${oscil.name}`); + console.log(` Category: ${oscil.category}`); + console.log(` Description: ${oscil.description.substring(0, 80)}...`); + console.log(` Syntax: ${oscil.syntax?.substring(0, 80)}...`); + console.log(` Rates: ${oscil.rates?.join(', ')}`); + console.log(` Parameters: ${oscil.parameters?.length || 0}`); +} + +const moogladder = getCsoundReference('moogladder'); +if (moogladder) { + console.log(`\nFound moogladder:`); + console.log(` Name: ${moogladder.name}`); + console.log(` Category: ${moogladder.category}`); + console.log(` Description: ${moogladder.description}`); + console.log(` Syntax: ${moogladder.syntax?.substring(0, 100)}...`); + console.log(` Rates: ${moogladder.rates?.join(', ')}`); + console.log(` Parameters: ${moogladder.parameters?.length || 0}`); + if (moogladder.parameters) { + console.log(` Parameters detail:`); + moogladder.parameters.forEach(p => { + console.log(` - ${p.name} (${p.type}): ${p.description.substring(0, 60)}...`); + }); + } +} + +console.log('\n--- Testing getCsoundReferencesByCategory() ---'); +const oscillators = getCsoundReferencesByCategory('Signal Generators:Basic Oscillators'); +console.log(`\nBasic Oscillators (${oscillators.length} opcodes):`); +oscillators.slice(0, 5).forEach(op => { + console.log(` - ${op.name}: ${op.description.substring(0, 60)}...`); +}); + +console.log('\n--- Sample categories ---'); +const categories = new Set(allCsoundReferences.map(ref => ref.category)); +const categoryArray = Array.from(categories).sort(); +console.log(`\nTotal categories: ${categories.size}`); +console.log('First 10 categories:'); +categoryArray.slice(0, 10).forEach(cat => { + const count = allCsoundReferences.filter(r => r.category === cat).length; + console.log(` - ${cat} (${count} opcodes)`); +}); + +console.log('\n--- Checking for opcodes with parameters ---'); +const opcodesWithParams = allCsoundReferences.filter(ref => ref.parameters && ref.parameters.length > 0); +console.log(`\nOpcodes with parameters: ${opcodesWithParams.length} out of ${allCsoundReferences.length}`); +if (opcodesWithParams.length > 0) { + console.log('\nFirst 5 opcodes with parameters:'); + opcodesWithParams.slice(0, 5).forEach(op => { + console.log(` - ${op.name}: ${op.parameters?.length} parameters`); + }); +} + +console.log('\n' + '='.repeat(60)); +console.log('Test Complete!'); +console.log('='.repeat(60)); diff --git a/scripts/csound-parser/tsconfig.json b/scripts/csound-parser/tsconfig.json new file mode 100644 index 0000000..e8c0c01 --- /dev/null +++ b/scripts/csound-parser/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "target": "ES2020", + "module": "CommonJS", + "lib": ["ES2020"], + "outDir": "./dist", + "rootDir": "./", + "strict": true, + "esModuleInterop": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true, + "resolveJsonModule": true, + "moduleResolution": "node", + "types": ["node"] + }, + "include": ["*.ts"], + "exclude": ["node_modules", "dist"] +} diff --git a/scripts/csound-parser/types.ts b/scripts/csound-parser/types.ts new file mode 100644 index 0000000..ee03138 --- /dev/null +++ b/scripts/csound-parser/types.ts @@ -0,0 +1,35 @@ +export interface CsoundReference { + name: string + type: 'opcode' | 'keyword' | 'header' | 'constant' + category: string + description: string + syntax?: string + example?: string + rates?: string[] + parameters?: { + name: string + description: string + type: 'initialization' | 'performance' + }[] + seeAlso?: string[] +} + +export interface ParsedOpcode { + id: string + category: string + title: string + description: string + syntaxModern?: string + syntaxClassic?: string + initParams: { name: string; description: string }[] + perfParams: { name: string; description: string }[] + example?: string + seeAlso: string[] + rawContent: string +} + +export interface CategoryGroup { + categoryKey: string + categoryName: string + opcodes: CsoundReference[] +} diff --git a/src/App.svelte b/src/App.svelte index 2d25a3b..8467f3a 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -11,6 +11,7 @@ import ConfirmDialog from "./lib/components/ui/ConfirmDialog.svelte"; import InputDialog from "./lib/components/ui/InputDialog.svelte"; import TemplateDialog from "./lib/components/ui/TemplateDialog.svelte"; + import CsoundReference from "./lib/components/reference/CsoundReference.svelte"; import { createCsoundDerivedStores, type LogEntry, @@ -276,6 +277,11 @@ label: "Files", content: filesTabContent, }, + { + id: "reference", + label: "Reference", + content: referenceTabContent, + }, ]; @@ -294,6 +300,10 @@ /> {/snippet} +{#snippet referenceTabContent()} + +{/snippet} +
{#snippet leftActions()} diff --git a/src/lib/components/editor/Editor.svelte b/src/lib/components/editor/Editor.svelte index 39dc14d..509d7ce 100644 --- a/src/lib/components/editor/Editor.svelte +++ b/src/lib/components/editor/Editor.svelte @@ -19,6 +19,7 @@ getBlock, getDocument } from '../../editor/block-eval'; + import { csoundTooltip, csoundTooltipTheme } from '../../csound-reference/csoundTooltips'; interface Props { value: string; @@ -99,6 +100,8 @@ rectangularSelection(), crosshairCursor(), highlightSelectionMatches(), + csoundTooltip, + csoundTooltipTheme, keymap.of([ ...closeBracketsKeymap, ...defaultKeymap, diff --git a/src/lib/components/reference/CsoundReference.svelte b/src/lib/components/reference/CsoundReference.svelte new file mode 100644 index 0000000..7aeb2e2 --- /dev/null +++ b/src/lib/components/reference/CsoundReference.svelte @@ -0,0 +1,373 @@ + + +
+ + +
+ {#each filteredCategories() as category} + {@const references = getFilteredReferences(category)} + {#if references.length > 0} +
+ + + {#if expandedCategories.has(category)} +
+ {#each references as opcode} +
+
+ {opcode.name} + {opcode.type} +
+

{opcode.description}

+ {#if opcode.syntax} +
{opcode.syntax}
+ {/if} + {#if opcode.rates && opcode.rates.length > 0} +
+ Rates: {opcode.rates.join(', ')} +
+ {/if} + {#if opcode.parameters && opcode.parameters.length > 0} +
+
+ Parameters ({opcode.parameters.length}): +
+ {#each opcode.parameters.slice(0, 5) as param} +
+ {param.name} + ({param.type}) + + {param.description.length > 80 + ? param.description.substring(0, 80) + '...' + : param.description} + +
+ {/each} + {#if opcode.parameters.length > 5} +
+ ... and {opcode.parameters.length - 5} more +
+ {/if} +
+ {/if} +
+ {/each} +
+ {/if} +
+ {/if} + {/each} + + {#if searchTerm.trim() && filteredCategories().length === 0} +
+ +

No Results Found

+

Try adjusting your search terms

+
+ {/if} +
+
+ + diff --git a/src/lib/csound-reference/array-opcodes.ts b/src/lib/csound-reference/array-opcodes.ts new file mode 100644 index 0000000..edff017 --- /dev/null +++ b/src/lib/csound-reference/array-opcodes.ts @@ -0,0 +1,381 @@ +import type { CsoundReference } from './types' + +// Array Opcodes +export const arrayOpcodes: CsoundReference[] = [ +{ + name: 'array', + type: 'opcode', + category: 'Array Opcodes', + description: 'Converts an input into an array, optionally creating it.', + example: '--8<-- "examples/array.csd"', + seeAlso: ['array opcodes'] +}, +{ + name: 'copya2ftab', + type: 'opcode', + category: 'Array Opcodes', + description: 'The _copya2ftab_ opcode takes a k-array and copies the contents to an f-table.', + syntax: 'copya2ftab(kArray[], ktab [, koffset])\n copya2ftab(iArray[], itab [, ioffset])', + example: '--8<-- "examples/copya2ftab-modern.csd"', + parameters: [ + { + name: 'ktab', + description: 'f-table for destination.', + type: 'performance' + }, + { + name: 'koffset', + description: 'offset into the f-table (defaults to 0).', + type: 'performance' + }, + ], + seeAlso: ['Array opcodes'] +}, +{ + name: 'copyf2array', + type: 'opcode', + category: 'Array Opcodes', + description: 'The _copyf2array_ opcode takes an f-table and copies the contents to a t-var.', + syntax: 'copyf2array(tab, kftbl)', + example: '--8<-- "examples/copyf2array-modern.csd"', + parameters: [ + { + name: 'tab', + description: 'tables for destination.', + type: 'performance' + }, + { + name: 'kftbl', + description: 'f-tables for source.', + type: 'performance' + }, + ], + seeAlso: ['Array opcodes'] +}, +{ + name: 'deinterleave', + type: 'opcode', + category: 'Array Opcodes', + description: 'Deinterleaves arrays by picking alternate data from its input.', + syntax: 'kout1[], kout2[] = deinterleave(kin[])', + example: '--8<-- "examples/deinterleave.csd"', + rates: ['k-rate'], + seeAlso: ['Array opcodes'] +}, +{ + name: 'fillarray', + type: 'opcode', + category: 'Array Opcodes', + description: 'Generate a vector (one-dimensional k-rate array) with a sequence of numeric or string values.', + syntax: 'karray[] = fillarray(ival1, ival2,.....ivaln)\n karray = fillarray(ival1, ival2,.....ivaln)\n karray = fillarray(kval1, kval2,.....kvaln)', + example: '--8<-- "examples/fillarray.csd"', + seeAlso: ['Array opcodes'] +}, +{ + name: 'genarray', + type: 'opcode', + category: 'Array Opcodes', + description: 'Generate a vector (one-dimensional k-rate or i-rate array) with an arithmetic sequence.', + syntax: 'karray = genarray(kstart, kens [, inc])\n iarray = genarray(istart, iens [, inc])', + example: '--8<-- "examples/genarray.csd"', + parameters: [ + { + name: 'istart', + description: 'value to place in first element.', + type: 'initialization' + }, + { + name: 'iend', + description: 'last value to place in array.', + type: 'initialization' + }, + { + name: 'inc', + description: 'amount to add to previous value (default 1).', + type: 'initialization' + }, + ], + seeAlso: ['Array opcodes'] +}, +{ + name: 'getcol', + type: 'opcode', + category: 'Array Opcodes', + description: 'Gets a given column from a 2-dimensional array as a vector.', + syntax: 'i/kout[] = getcol(i/kin[], i/kcol)', + example: '--8<-- "examples/getcol.csd"', + rates: ['k-rate'], + parameters: [ + { + name: 'icol', + description: 'column to be extracted.', + type: 'initialization' + }, + { + name: 'kcol', + description: 'column to be extracted.', + type: 'performance' + }, + ], + seeAlso: ['Vectorial Opcodes', 'Array Opcodes'] +}, +{ + name: 'getrow', + type: 'opcode', + category: 'Array Opcodes', + description: 'Gets a given row from a 2-dimensional array as a vector.', + syntax: 'i/kout[] = getrow(i/kin[], i/krow)', + example: '--8<-- "examples/rfft.csd"', + rates: ['k-rate'], + parameters: [ + { + name: 'irow', + description: 'row to be extracted.', + type: 'initialization' + }, + { + name: 'krow', + description: 'row to be extracted.', + type: 'performance' + }, + ], + seeAlso: ['Vectorial Opcodes', 'Array Opcodes'] +}, +{ + name: 'interleave', + type: 'opcode', + category: 'Array Opcodes', + description: 'Interleaves arrays into a a single one by placing the input data in alternate positions.', + syntax: 'kout[] = interleave(kin1[], kin2[])', + example: '--8<-- "examples/interleave.csd"', + seeAlso: ['Array opcodes'] +}, +{ + name: 'maxarray', + type: 'opcode', + category: 'Array Opcodes', + description: 'Returns the maximum value in a k-rate array, and optional its index.', + syntax: 'kmax [,kindx] = maxarray(karray)', + example: '--8<-- "examples/maxarray.csd"', + parameters: [ + { + name: 'kmax', + description: 'variable for result.', + type: 'performance' + }, + { + name: 'kindx', + description: 'position (index) of result in array.', + type: 'performance' + }, + { + name: 'karray', + description: 'array for reading.', + type: 'performance' + }, + ], + seeAlso: ['Array opcodes'] +}, +{ + name: 'minarray', + type: 'opcode', + category: 'Array Opcodes', + description: 'Returns the minimum value in a k-rate array, and optional its index.', + syntax: 'kmin [,kindx] = minarray(karray)', + example: '--8<-- "examples/minarray.csd"', + parameters: [ + { + name: 'kmin', + description: 'variable for result.', + type: 'performance' + }, + { + name: 'kindx', + description: 'position (index) of result in array.', + type: 'performance' + }, + { + name: 'karray', + description: 'array for reading.', + type: 'performance' + }, + ], + seeAlso: ['Array opcodes'] +}, +{ + name: 'printarray', + type: 'opcode', + category: 'Array Opcodes', + description: 'Print the contents of an array.', + syntax: 'printarray(ixs[] [, Smft, Slabel ])\n printarray(kxs[] [, ktrig, Sfmt, Slabel ])', + example: '--8<-- "examples/printarray.csd"', + parameters: [ + { + name: 'Sfmt', + description: 'If given, it is passed to printf for each element of the array. Otherwise a default format is used', + type: 'initialization' + }, + { + name: 'Slabel', + description: 'If given, it is printed before the contents of the array, to easily identify the data', + type: 'initialization' + }, + { + name: 'ktrig', + description: 'The array will be printed whenever this value changes from 0 to possitive. Can be used together with metro to print at a given time interval. A value of -1 indicates to print at each k-cycle (default = 1)', + type: 'performance' + }, + ], + seeAlso: ['Printing and Display', 'Array opcodes'] +}, +{ + name: 'productarray', + type: 'opcode', + category: 'Array Opcodes', + description: 'Calculates the product of an array.', + syntax: 'kres/ires = product(karr[]/iarr[]) (k- or i-arrays )', + example: '--8<-- "examples/productarray.csd"', + rates: ['k-rate', 'i-rate'], + seeAlso: ['Array opcodes'] +}, +{ + name: 'reshapearray', + type: 'opcode', + category: 'Array Opcodes', + description: 'Reshape an array, maintaining its capacity.', + syntax: 'reshapearray(array[], isize0 [, isize1 ])', + example: '--8<-- "examples/reshapearray.csd"', + parameters: [ + { + name: 'isize0', + description: 'The size of the first dimension', + type: 'initialization' + }, + { + name: 'isize1', + description: 'The size of the second dimension (0 for 1D arrays). _Defaults to 0_', + type: 'initialization' + }, + ], + seeAlso: ['Array opcodes'] +}, +{ + name: 'scalearray', + type: 'opcode', + category: 'Array Opcodes', + description: 'The _scalearray_ opcode scales a subregion of a vector to a given minimum/maximum.', + syntax: 'scalearray(tarray, kmin, kmax[, kleft, kright])', + example: '--8<-- "examples/scalearray.csd"', + parameters: [ + { + name: 'karray', + description: 'array for operation.', + type: 'performance' + }, + { + name: 'kmin', + description: 'target minimum and maximum values.', + type: 'performance' + }, + { + name: 'kmax', + description: 'target minimum and maximum values.', + type: 'performance' + }, + { + name: 'kleft', + description: 'range of table to use, defaulting to 0 and size of the vector.', + type: 'performance' + }, + { + name: 'kright', + description: 'range of table to use, defaulting to 0 and size of the vector.', + type: 'performance' + }, + ], + seeAlso: ['Array opcodes'] +}, +{ + name: 'setcol', + type: 'opcode', + category: 'Array Opcodes', + description: 'Sets a given column of a 2-dimensional array from a vector.', + syntax: 'i/kout[] = setcol(i/kin[], i/kcol)', + example: '--8<-- "examples/setcol.csd"', + rates: ['k-rate'], + parameters: [ + { + name: 'icol', + description: 'column to be extracted.', + type: 'initialization' + }, + { + name: 'kcol', + description: 'column to be set.', + type: 'performance' + }, + ], + seeAlso: ['Vectorial Opcodes', 'Array Opcodes'] +}, +{ + name: 'setrow', + type: 'opcode', + category: 'Array Opcodes', + description: 'Sets a given row of a 2-dimensional array from a vector.', + syntax: 'i/kout[] = setrow(i/kin[], i/krow)', + example: '--8<-- "examples/rfft.csd"', + rates: ['k-rate'], + parameters: [ + { + name: 'irow', + description: 'row to be set.', + type: 'initialization' + }, + { + name: 'krow', + description: 'row to be set.', + type: 'performance' + }, + ], + seeAlso: ['Vectorial Opcodes', 'Array Opcodes'] +}, +{ + name: 'shiftin', + type: 'opcode', + category: 'Array Opcodes', + description: 'Shifts the contents of an audio variable into a 1-dimensional array.', + syntax: 'kout[] = shiftin(asig)', + example: '--8<-- "examples/shiftin.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'asig', + description: 'input audio', + type: 'performance' + }, + ], + seeAlso: ['Vectorial opcodes', 'array opcodes'] +}, +{ + name: 'shiftout', + type: 'opcode', + category: 'Array Opcodes', + description: 'Shifts the contents of a 1-dimensional array into an audio variable.', + syntax: 'asig = shiftout(kIn[] [, ioff])', + example: '--8<-- "examples/shiftout.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'ioff', + description: 'initial read offset position (optional, defaults to 0).', + type: 'initialization' + }, + { + name: 'asig', + description: 'output audio', + type: 'performance' + }, + ], + seeAlso: ['Vectorial opcodes', 'array opcodes'] +}, +] diff --git a/src/lib/csound-reference/array-operations-autocorrelation.ts b/src/lib/csound-reference/array-operations-autocorrelation.ts new file mode 100644 index 0000000..a171dea --- /dev/null +++ b/src/lib/csound-reference/array-operations-autocorrelation.ts @@ -0,0 +1,15 @@ +import type { CsoundReference } from './types' + +// Array Operations: Autocorrelation +export const arrayOperationsAutocorrelation: CsoundReference[] = [ +{ + name: 'autocorr', + type: 'opcode', + category: 'Array Operations: Autocorrelation', + description: 'This opcode takes in an input array and computes its autocorrelation.', + syntax: 'kout[] = autocorr(kin[])', + example: '--8<-- "examples/autocorr-modern.csd"', + rates: ['k-rate'], + seeAlso: ['Vectorial opcodes', 'array opcodes'] +}, +] diff --git a/src/lib/csound-reference/array-operations-cepstrum.ts b/src/lib/csound-reference/array-operations-cepstrum.ts new file mode 100644 index 0000000..50a5649 --- /dev/null +++ b/src/lib/csound-reference/array-operations-cepstrum.ts @@ -0,0 +1,37 @@ +import type { CsoundReference } from './types' + +// Array Operations: Cepstrum +export const arrayOperationsCepstrum: CsoundReference[] = [ +{ + name: 'ceps', + type: 'opcode', + category: 'Array Operations: Cepstrum', + description: 'Calculate the cepstrum of an array input, optionally filtering coefficients.', + syntax: 'keps[] = ceps(kmags[] [, icoefs])', + example: '--8<-- "examples/ceps-modern.csd"', + parameters: [ + { + name: 'icoefs', + description: 'the number of retained coefficients in the cepstrum output. By default, no coefficients are filtered.', + type: 'initialization' + }, + ], + seeAlso: ['Array-based spectral opcodes'] +}, +{ + name: 'cepsinv', + type: 'opcode', + category: 'Array Operations: Cepstrum', + description: 'Calculate the inverse cepstrum of an array.', + syntax: 'kenv = cepsinv(keps[])', + example: '--8<-- "examples/cepsinv-modern.csd"', + parameters: [ + { + name: 'kenv', + description: 'the inverse cepstrum (spectral envelope), an array of N+1 magnitudes.', + type: 'performance' + }, + ], + seeAlso: ['Array-based spectral opcodes'] +}, +] diff --git a/src/lib/csound-reference/array-operations-complex-numbers.ts b/src/lib/csound-reference/array-operations-complex-numbers.ts new file mode 100644 index 0000000..7cd1fa5 --- /dev/null +++ b/src/lib/csound-reference/array-operations-complex-numbers.ts @@ -0,0 +1,74 @@ +import type { CsoundReference } from './types' + +// Array Operations: complex numbers +export const arrayOperationsComplexNumbers: CsoundReference[] = [ +{ + name: 'c2r', + type: 'opcode', + category: 'Array Operations: complex numbers', + description: 'Real to complex format conversion.', + syntax: 'kout[] = c2r(kin[])', + example: '--8<-- "examples/c2r-modern.csd"', + rates: ['k-rate'], + seeAlso: ['Vectorial opcodes', 'array opcodes', 'Array-based spectral opcodes'] +}, +{ + name: 'cmplxprod', + type: 'opcode', + category: 'Array Operations: complex numbers', + description: 'Complex product of two arrays of the same size and in real-imaginary interleaved format.', + syntax: 'kout[] = cmplxprod(kin1[], kin2[])', + example: '--8<-- "examples/cmplxprod.csd"', + seeAlso: ['Vectorial opcodes', 'array opcodes', 'Array-based spectral opcodes'] +}, +{ + name: 'mags', + type: 'opcode', + category: 'Array Operations: complex numbers', + description: 'Obtains the magnitudes of a complex-number array.', + syntax: 'kout[] = mags(kin[])', + example: '--8<-- "examples/mags.csd"', + rates: ['k-rate'], + seeAlso: ['Vectorial opcodes', 'array opcodes', 'Array-based spectral opcodes'] +}, +{ + name: 'phs', + type: 'opcode', + category: 'Array Operations: complex numbers', + description: 'Obtains the phases of a complex-number array.', + syntax: 'kout[] = phs(kin[])', + example: '--8<-- "examples/phs.csd"', + rates: ['k-rate'], + seeAlso: ['Vectorial opcodes', 'array opcodes', 'Array-based spectral opcodes'] +}, +{ + name: 'pol2rect', + type: 'opcode', + category: 'Array Operations: complex numbers', + description: 'Converts an input array in magnitude-phase format to real-imaginary format.', + syntax: 'kout[] = pol2rect(kin[])\n kout[] = pol2rect(kmags[], kphs[])', + example: '--8<-- "examples/pol2rect.csd"', + rates: ['k-rate'], + seeAlso: ['Vectorial opcodes', 'array opcodes'] +}, +{ + name: 'r2c', + type: 'opcode', + category: 'Array Operations: complex numbers', + description: 'Real to complex format conversion.', + syntax: 'kout[] = r2c(kin[])', + example: '--8<-- "examples/r2c.csd"', + rates: ['k-rate'], + seeAlso: ['Vectorial opcodes', 'array opcodes', 'Array-based spectral opcodes'] +}, +{ + name: 'rect2pol', + type: 'opcode', + category: 'Array Operations: complex numbers', + description: 'Converts an input array in real-imaginary format to magnitude-phase format.', + syntax: 'kout[] = rect2pol(kin[])', + example: '--8<-- "examples/rect2pol.csd"', + rates: ['k-rate'], + seeAlso: ['Vectorial opcodes', 'array opcodes', 'Array-based spectral opcodes'] +}, +] diff --git a/src/lib/csound-reference/array-operations-discrete-cosine-transform.ts b/src/lib/csound-reference/array-operations-discrete-cosine-transform.ts new file mode 100644 index 0000000..49b3dc9 --- /dev/null +++ b/src/lib/csound-reference/array-operations-discrete-cosine-transform.ts @@ -0,0 +1,25 @@ +import type { CsoundReference } from './types' + +// Array Operations: Discrete Cosine Transform +export const arrayOperationsDiscreteCosineTransform: CsoundReference[] = [ +{ + name: 'dct', + type: 'opcode', + category: 'Array Operations: Discrete Cosine Transform', + description: 'Discrete Cosine Transform of a sample array (type-II DCT).', + syntax: 'kout[] = dct(kin[])\n iout[] = dct(iin[])', + example: '--8<-- "examples/dct.csd"', + rates: ['k-rate'], + seeAlso: ['Vectorial opcodes', 'array opcodes', 'dctinv'] +}, +{ + name: 'dctinv', + type: 'opcode', + category: 'Array Operations: Discrete Cosine Transform', + description: 'Inverse Discrete Cosine Transform of a sample array (type-III DCT).', + syntax: 'kout[] = dctinv(kin[])\n iout[] = dctinv(iin[])', + example: '--8<-- "examples/dctinv.csd"', + rates: ['k-rate'], + seeAlso: ['Vectorial opcodes', 'array opcodes', 'dct'] +}, +] diff --git a/src/lib/csound-reference/array-operations-dot-product.ts b/src/lib/csound-reference/array-operations-dot-product.ts new file mode 100644 index 0000000..adf4dfb --- /dev/null +++ b/src/lib/csound-reference/array-operations-dot-product.ts @@ -0,0 +1,15 @@ +import type { CsoundReference } from './types' + +// Array Operations: dot product +export const arrayOperationsDotProduct: CsoundReference[] = [ +{ + name: 'dot', + type: 'opcode', + category: 'Array Operations: dot product', + description: 'Calculates the dot product of two arrays.', + syntax: 'kres/ires = dot(karr1[]/iarr1[], karr2[]/iarr2[]) (k- or i-arrays)', + example: '--8<-- "examples/dot.csd"', + rates: ['k-rate', 'i-rate'], + seeAlso: ['Array opcodes'] +}, +] diff --git a/src/lib/csound-reference/array-operations-fast-fourier-transform.ts b/src/lib/csound-reference/array-operations-fast-fourier-transform.ts new file mode 100644 index 0000000..c27a94a --- /dev/null +++ b/src/lib/csound-reference/array-operations-fast-fourier-transform.ts @@ -0,0 +1,66 @@ +import type { CsoundReference } from './types' + +// Array Operations: Fast Fourier Transform +export const arrayOperationsFastFourierTransform: CsoundReference[] = [ +{ + name: 'fft', + type: 'opcode', + category: 'Array Operations: Fast Fourier Transform', + description: 'Complex-to-complex Fast Fourier Transform.', + syntax: 'out:k[] = fft(in:k[])\n in:Complex[] = fft(in:Complex[][,inverse:i])\n in:Complex[] = fft(in:k[]);\n out:k[] = fft(in:Complex[]);', + example: '--8<-- "examples/fft.csd"', + parameters: [ + { + name: 'out', + description: 'output array containing the complex or real-valued output, depending on the opcode version. It will be created if it does not exist.', + type: 'performance' + }, + { + name: 'in', + description: 'input array containing the complex or real-valued input, depending on the opcode version.', + type: 'performance' + }, + ], + seeAlso: ['Vectorial opcodes', 'array opcodes', 'Array-based spectral opcodes'] +}, +{ + name: 'fftinv', + type: 'opcode', + category: 'Array Operations: Fast Fourier Transform', + description: 'Complex-to-complex Inverse Fast Fourier Transform.', + syntax: 'kout[] = fftinv(kin[])', + example: '--8<-- "examples/ifft.csd"', + rates: ['k-rate'], + seeAlso: ['Vectorial opcodes', 'array opcodes', 'Array-based spectral opcodes'] +}, +{ + name: 'rfft', + type: 'opcode', + category: 'Array Operations: Fast Fourier Transform', + description: 'Fast Fourier Transform of a real-value array.', + syntax: 'out:k[] = rfft(in:k[])\n out:Complex[] = rfft(in:k[])', + example: '--8<-- "examples/rfft.csd"', + seeAlso: ['Vectorial opcodes', 'Array opcodes', 'Array-based spectral opcodes'] +}, +{ + name: 'rifft', + type: 'opcode', + category: 'Array Operations: Fast Fourier Transform', + description: 'Complex-to-real Inverse Fast Fourier Transform.', + syntax: 'out:k[] = rifft(in:k[])\n out:k[] = rifft(in:Complex[])', + example: '--8<-- "examples/irfft.csd"', + parameters: [ + { + name: 'out', + description: 'output array containing the real-valued output. It will be created if it does not exist.', + type: 'performance' + }, + { + name: 'in', + description: 'input array containing the complex input.', + type: 'performance' + }, + ], + seeAlso: ['Vectorial opcodes', 'array opcodes', 'Array-based spectral opcodes'] +}, +] diff --git a/src/lib/csound-reference/array-operations-mel-scale-filterbank.ts b/src/lib/csound-reference/array-operations-mel-scale-filterbank.ts new file mode 100644 index 0000000..e7b3772 --- /dev/null +++ b/src/lib/csound-reference/array-operations-mel-scale-filterbank.ts @@ -0,0 +1,32 @@ +import type { CsoundReference } from './types' + +// Array Operations: Mel scale filterbank +export const arrayOperationsMelScaleFilterbank: CsoundReference[] = [ +{ + name: 'mfb', + type: 'opcode', + category: 'Array Operations: Mel scale filterbank', + description: 'Mel scale filterbank for spectral magnitudes.', + syntax: 'kout[] = mfb(kin[], klow, khigh, ibands)', + example: '--8<-- "examples/mfb.csd"', + rates: ['k-rate'], + parameters: [ + { + name: 'ibands', + description: 'number of bands in the Mel filter bank. Determines the size of the output array.', + type: 'initialization' + }, + { + name: 'klow', + description: 'lowest frequency (rounded to the nearest bin centre frequency).', + type: 'performance' + }, + { + name: 'khigh', + description: 'highest lowest frequency (rounded to the nearest bin centre frequency).', + type: 'performance' + }, + ], + seeAlso: ['Vectorial opcodes', 'array opcodes', 'dct'] +}, +] diff --git a/src/lib/csound-reference/array-operations-sorting.ts b/src/lib/csound-reference/array-operations-sorting.ts new file mode 100644 index 0000000..03eb9ae --- /dev/null +++ b/src/lib/csound-reference/array-operations-sorting.ts @@ -0,0 +1,23 @@ +import type { CsoundReference } from './types' + +// Array Operations: sorting +export const arrayOperationsSorting: CsoundReference[] = [ +{ + name: 'sorta', + type: 'opcode', + category: 'Array Operations: sorting', + description: 'Takes a numeric array (k or i-rate) and returns it sorted in ascending order.', + syntax: 'k/i[] = sorta(k/i[]) (k- or i-arrays )', + example: '--8<-- "examples/sorta.csd"', + seeAlso: ['Array opcodes'] +}, +{ + name: 'sortd', + type: 'opcode', + category: 'Array Operations: sorting', + description: 'Takes a numeric array (k or i-rate) and returns it sorted in descending order.', + syntax: 'k/i[] = sortd(k/i[]) (k- or i-arrays )', + example: '--8<-- "examples/sortd.csd"', + seeAlso: ['Array opcodes'] +}, +] diff --git a/src/lib/csound-reference/csoundReference.ts b/src/lib/csound-reference/csoundReference.ts new file mode 100644 index 0000000..9feb6e3 --- /dev/null +++ b/src/lib/csound-reference/csoundReference.ts @@ -0,0 +1,322 @@ +import type { CsoundReference } from './types' +import { orchestraSyntaxHeader } from './orchestra-syntax-header' +import { spectralProcessingAts } from './spectral-processing-ats' +import { osc } from './osc' +import { mathematicalOperationsMathematicalFunctions } from './mathematical-operations-mathematical-functions' +import { instrumentControlRealtimePerformanceControl } from './instrument-control-realtime-performance-control' +import { mathematicalOperationsArithmeticAndLogicOperations } from './mathematical-operations-arithmetic-and-logic-operations' +import { signalGeneratorsEnvelopeGenerators } from './signal-generators-envelope-generators' +import { signalGeneratorsAdditiveSynthesisResynthesis } from './signal-generators-additive-synthesis-resynthesis' +import { realTimeMidiInput } from './real-time-midi-input' +import { spectralProcessingLpc } from './spectral-processing-lpc' +import { signalModifiersReverberation } from './signal-modifiers-reverberation' +import { signalFlowGraphOpcodes } from './signal-flow-graph-opcodes' +import { mathematicalOperationsAmplitudeFunctions } from './mathematical-operations-amplitude-functions' +import { realTimeMidiConverters } from './real-time-midi-converters' +import { serialIO } from './serial-i-o' +import { signalModifiersStandardFiltersResonant } from './signal-modifiers-standard-filters-resonant' +import { signalModifiersStandardFiltersControl } from './signal-modifiers-standard-filters-control' +import { arrayOpcodes } from './array-opcodes' +import { instrumentControlInitializationAndReinitialization } from './instrument-control-initialization-and-reinitialization' +import { signalModifiersStandardFilters } from './signal-modifiers-standard-filters' +import { arrayOperationsAutocorrelation } from './array-operations-autocorrelation' +import { signalModifiersAmplitudeModifiers } from './signal-modifiers-amplitude-modifiers' +import { signalGeneratorsModelsAndEmulations } from './signal-generators-models-and-emulations' +import { signalGeneratorsSamplePlayback } from './signal-generators-sample-playback' +import { signalGeneratorsRandomNoiseGenerators } from './signal-generators-random-noise-generators' +import { signalModifiersPanningAndSpatialization } from './signal-modifiers-panning-and-spatialization' +import { spectralProcessingStreaming } from './spectral-processing-streaming' +import { mathematicalOperationsRandomFunctions } from './mathematical-operations-random-functions' +import { signalGeneratorsLinearAndExponentialGenerators } from './signal-generators-linear-and-exponential-generators' +import { instrumentControlProgramFlowControl } from './instrument-control-program-flow-control' +import { instrumentControlSensingAndControl } from './instrument-control-sensing-and-control' +import { signalGeneratorsDynamicSpectrumOscillators } from './signal-generators-dynamic-spectrum-oscillators' +import { arrayOperationsComplexNumbers } from './array-operations-complex-numbers' +import { mathematicalOperationsArrays } from './mathematical-operations-arrays' +import { vectorialCellularAutomata } from './vectorial-cellular-automata' +import { pitchConvertersFunctions } from './pitch-converters-functions' +import { spectralProcessingOther } from './spectral-processing-other' +import { arrayOperationsCepstrum } from './array-operations-cepstrum' +import { signalIOSoftwareBus } from './signal-i-o-software-bus' +import { signalModifiersWaveshaping } from './signal-modifiers-waveshaping' +import { mathematicalOperationsComparatorsAndAccumulators } from './mathematical-operations-comparators-and-accumulators' +import { instrumentControlClockControl } from './instrument-control-clock-control' +import { signalModifiersComparatorsAndAccumulators } from './signal-modifiers-comparators-and-accumulators' +import { instrumentControlCompilation } from './instrument-control-compilation' +import { signalModifiersConvolutionAndMorphing } from './signal-modifiers-convolution-and-morphing' +import { mathematicalOperationsTrigonometricFunctions } from './mathematical-operations-trigonometric-functions' +import { pitchConvertersTuningOpcodes } from './pitch-converters-tuning-opcodes' +import { signalGeneratorsFmSynthesis } from './signal-generators-fm-synthesis' +import { instrumentControlTimeReading } from './instrument-control-time-reading' +import { signalModifiersSpecializedFilters } from './signal-modifiers-specialized-filters' +import { arrayOperationsDiscreteCosineTransform } from './array-operations-discrete-cosine-transform' +import { orchestraSyntaxMacros } from './orchestra-syntax-macros' +import { signalModifiersDelay } from './signal-modifiers-delay' +import { signalModifiersSampleLevelOperators } from './signal-modifiers-sample-level-operators' +import { miscellaneous } from './miscellaneous' +import { signalGeneratorsGranularSynthesis } from './signal-generators-granular-synthesis' +import { signalIOSignalInput } from './signal-i-o-signal-input' +import { signalIOPrintingAndDisplay } from './signal-i-o-printing-and-display' +import { signalModifiersSpecialEffects } from './signal-modifiers-special-effects' +import { mathematicalOperationsOpcodeEquivalentsOfFunctions } from './mathematical-operations-opcode-equivalents-of-functions' +import { arrayOperationsDotProduct } from './array-operations-dot-product' +import { signalIOFileIO } from './signal-i-o-file-i-o' +import { orchestraSyntaxBlockStatements } from './orchestra-syntax-block-statements' +import { signalGeneratorsPhasors } from './signal-generators-phasors' +import { instrumentControlConditionalValues } from './instrument-control-conditional-values' +import { instrumentControlInvocation } from './instrument-control-invocation' +import { midiFilesMidiInputAndInitialization } from './midi-files-midi-input-and-initialization' +import { arrayOperationsFastFourierTransform } from './array-operations-fast-fourier-transform' +import { signalIOSoundfileQueries } from './signal-i-o-soundfile-queries' +import { tableControlReadWriteOperations } from './table-control-read-write-operations' +import { tableControlTableQueries } from './table-control-table-queries' +import { tableControl } from './table-control' +import { signalGeneratorsHyperVectorialSynthesis } from './signal-generators-hyper-vectorial-synthesis' +import { instrumentControlDurationControl } from './instrument-control-duration-control' +import { remoteOpcodes } from './remote-opcodes' +import { realTimeMidiEventExtenders } from './real-time-midi-event-extenders' +import { signalGeneratorsBasicOscillators } from './signal-generators-basic-oscillators' +import { signalModifiersSignalLimiters } from './signal-modifiers-signal-limiters' +import { utilities } from './utilities' +import { realTimeMidiSystemRealtime } from './real-time-midi-system-realtime' +import { signalIOSignalOutput } from './signal-i-o-signal-output' +import { arrayOperationsMelScaleFilterbank } from './array-operations-mel-scale-filterbank' +import { realTimeMidiNoteOutput } from './real-time-midi-note-output' +import { realTimeMidiMidiScoreInteroperability } from './real-time-midi-midi-score-interoperability' +import { realTimeMidiGenericIO } from './real-time-midi-generic-i-o' +import { mixerOpcodes } from './mixer-opcodes' +import { realTimeMidiOutput } from './real-time-midi-output' +import { signalGeneratorsTableAccess } from './signal-generators-table-access' +import { signalGeneratorsWaveguidePhysicalModeling } from './signal-generators-waveguide-physical-modeling' +import { instrumentControlStacks } from './instrument-control-stacks' +import { stringsManipulation } from './strings-manipulation' +import { spectralProcessingStft } from './spectral-processing-stft' +import { network } from './network' +import { realTimeMidiSliderBanks } from './real-time-midi-slider-banks' +import { signalGeneratorsScannedSynthesis } from './signal-generators-scanned-synthesis' +import { arrayOperationsSorting } from './array-operations-sorting' +import { spectralProcessingNonStandard } from './spectral-processing-non-standard' +import { signalGeneratorsWaveTerrainSynthesis } from './signal-generators-wave-terrain-synthesis' +import { stringsConversion } from './strings-conversion' +import { stringsDefinition } from './strings-definition' + +export type { CsoundReference } + +export const allCsoundReferences: CsoundReference[] = [ + ...orchestraSyntaxHeader, + ...spectralProcessingAts, + ...osc, + ...mathematicalOperationsMathematicalFunctions, + ...instrumentControlRealtimePerformanceControl, + ...mathematicalOperationsArithmeticAndLogicOperations, + ...signalGeneratorsEnvelopeGenerators, + ...signalGeneratorsAdditiveSynthesisResynthesis, + ...realTimeMidiInput, + ...spectralProcessingLpc, + ...signalModifiersReverberation, + ...signalFlowGraphOpcodes, + ...mathematicalOperationsAmplitudeFunctions, + ...realTimeMidiConverters, + ...serialIO, + ...signalModifiersStandardFiltersResonant, + ...signalModifiersStandardFiltersControl, + ...arrayOpcodes, + ...instrumentControlInitializationAndReinitialization, + ...signalModifiersStandardFilters, + ...arrayOperationsAutocorrelation, + ...signalModifiersAmplitudeModifiers, + ...signalGeneratorsModelsAndEmulations, + ...signalGeneratorsSamplePlayback, + ...signalGeneratorsRandomNoiseGenerators, + ...signalModifiersPanningAndSpatialization, + ...spectralProcessingStreaming, + ...mathematicalOperationsRandomFunctions, + ...signalGeneratorsLinearAndExponentialGenerators, + ...instrumentControlProgramFlowControl, + ...instrumentControlSensingAndControl, + ...signalGeneratorsDynamicSpectrumOscillators, + ...arrayOperationsComplexNumbers, + ...mathematicalOperationsArrays, + ...vectorialCellularAutomata, + ...pitchConvertersFunctions, + ...spectralProcessingOther, + ...arrayOperationsCepstrum, + ...signalIOSoftwareBus, + ...signalModifiersWaveshaping, + ...mathematicalOperationsComparatorsAndAccumulators, + ...instrumentControlClockControl, + ...signalModifiersComparatorsAndAccumulators, + ...instrumentControlCompilation, + ...signalModifiersConvolutionAndMorphing, + ...mathematicalOperationsTrigonometricFunctions, + ...pitchConvertersTuningOpcodes, + ...signalGeneratorsFmSynthesis, + ...instrumentControlTimeReading, + ...signalModifiersSpecializedFilters, + ...arrayOperationsDiscreteCosineTransform, + ...orchestraSyntaxMacros, + ...signalModifiersDelay, + ...signalModifiersSampleLevelOperators, + ...miscellaneous, + ...signalGeneratorsGranularSynthesis, + ...signalIOSignalInput, + ...signalIOPrintingAndDisplay, + ...signalModifiersSpecialEffects, + ...mathematicalOperationsOpcodeEquivalentsOfFunctions, + ...arrayOperationsDotProduct, + ...signalIOFileIO, + ...orchestraSyntaxBlockStatements, + ...signalGeneratorsPhasors, + ...instrumentControlConditionalValues, + ...instrumentControlInvocation, + ...midiFilesMidiInputAndInitialization, + ...arrayOperationsFastFourierTransform, + ...signalIOSoundfileQueries, + ...tableControlReadWriteOperations, + ...tableControlTableQueries, + ...tableControl, + ...signalGeneratorsHyperVectorialSynthesis, + ...instrumentControlDurationControl, + ...remoteOpcodes, + ...realTimeMidiEventExtenders, + ...signalGeneratorsBasicOscillators, + ...signalModifiersSignalLimiters, + ...utilities, + ...realTimeMidiSystemRealtime, + ...signalIOSignalOutput, + ...arrayOperationsMelScaleFilterbank, + ...realTimeMidiNoteOutput, + ...realTimeMidiMidiScoreInteroperability, + ...realTimeMidiGenericIO, + ...mixerOpcodes, + ...realTimeMidiOutput, + ...signalGeneratorsTableAccess, + ...signalGeneratorsWaveguidePhysicalModeling, + ...instrumentControlStacks, + ...stringsManipulation, + ...spectralProcessingStft, + ...network, + ...realTimeMidiSliderBanks, + ...signalGeneratorsScannedSynthesis, + ...arrayOperationsSorting, + ...spectralProcessingNonStandard, + ...signalGeneratorsWaveTerrainSynthesis, + ...stringsConversion, + ...stringsDefinition, +] + +export const csoundReferenceMap = new Map() +allCsoundReferences.forEach(ref => { + csoundReferenceMap.set(ref.name, ref) +}) + +export function getCsoundReference(name: string): CsoundReference | undefined { + return csoundReferenceMap.get(name) +} + +export function getCsoundReferencesByCategory(category: string): CsoundReference[] { + return allCsoundReferences.filter(ref => ref.category === category) +} + +export { + orchestraSyntaxHeader, + spectralProcessingAts, + osc, + mathematicalOperationsMathematicalFunctions, + instrumentControlRealtimePerformanceControl, + mathematicalOperationsArithmeticAndLogicOperations, + signalGeneratorsEnvelopeGenerators, + signalGeneratorsAdditiveSynthesisResynthesis, + realTimeMidiInput, + spectralProcessingLpc, + signalModifiersReverberation, + signalFlowGraphOpcodes, + mathematicalOperationsAmplitudeFunctions, + realTimeMidiConverters, + serialIO, + signalModifiersStandardFiltersResonant, + signalModifiersStandardFiltersControl, + arrayOpcodes, + instrumentControlInitializationAndReinitialization, + signalModifiersStandardFilters, + arrayOperationsAutocorrelation, + signalModifiersAmplitudeModifiers, + signalGeneratorsModelsAndEmulations, + signalGeneratorsSamplePlayback, + signalGeneratorsRandomNoiseGenerators, + signalModifiersPanningAndSpatialization, + spectralProcessingStreaming, + mathematicalOperationsRandomFunctions, + signalGeneratorsLinearAndExponentialGenerators, + instrumentControlProgramFlowControl, + instrumentControlSensingAndControl, + signalGeneratorsDynamicSpectrumOscillators, + arrayOperationsComplexNumbers, + mathematicalOperationsArrays, + vectorialCellularAutomata, + pitchConvertersFunctions, + spectralProcessingOther, + arrayOperationsCepstrum, + signalIOSoftwareBus, + signalModifiersWaveshaping, + mathematicalOperationsComparatorsAndAccumulators, + instrumentControlClockControl, + signalModifiersComparatorsAndAccumulators, + instrumentControlCompilation, + signalModifiersConvolutionAndMorphing, + mathematicalOperationsTrigonometricFunctions, + pitchConvertersTuningOpcodes, + signalGeneratorsFmSynthesis, + instrumentControlTimeReading, + signalModifiersSpecializedFilters, + arrayOperationsDiscreteCosineTransform, + orchestraSyntaxMacros, + signalModifiersDelay, + signalModifiersSampleLevelOperators, + miscellaneous, + signalGeneratorsGranularSynthesis, + signalIOSignalInput, + signalIOPrintingAndDisplay, + signalModifiersSpecialEffects, + mathematicalOperationsOpcodeEquivalentsOfFunctions, + arrayOperationsDotProduct, + signalIOFileIO, + orchestraSyntaxBlockStatements, + signalGeneratorsPhasors, + instrumentControlConditionalValues, + instrumentControlInvocation, + midiFilesMidiInputAndInitialization, + arrayOperationsFastFourierTransform, + signalIOSoundfileQueries, + tableControlReadWriteOperations, + tableControlTableQueries, + tableControl, + signalGeneratorsHyperVectorialSynthesis, + instrumentControlDurationControl, + remoteOpcodes, + realTimeMidiEventExtenders, + signalGeneratorsBasicOscillators, + signalModifiersSignalLimiters, + utilities, + realTimeMidiSystemRealtime, + signalIOSignalOutput, + arrayOperationsMelScaleFilterbank, + realTimeMidiNoteOutput, + realTimeMidiMidiScoreInteroperability, + realTimeMidiGenericIO, + mixerOpcodes, + realTimeMidiOutput, + signalGeneratorsTableAccess, + signalGeneratorsWaveguidePhysicalModeling, + instrumentControlStacks, + stringsManipulation, + spectralProcessingStft, + network, + realTimeMidiSliderBanks, + signalGeneratorsScannedSynthesis, + arrayOperationsSorting, + spectralProcessingNonStandard, + signalGeneratorsWaveTerrainSynthesis, + stringsConversion, + stringsDefinition, +} diff --git a/src/lib/csound-reference/csoundTooltips.ts b/src/lib/csound-reference/csoundTooltips.ts new file mode 100644 index 0000000..8a0bb8a --- /dev/null +++ b/src/lib/csound-reference/csoundTooltips.ts @@ -0,0 +1,239 @@ +import { EditorView, hoverTooltip } from '@codemirror/view'; +import { getCsoundReference } from './csoundReference'; + +function getWordAt(view: EditorView, pos: number): { text: string; from: number; to: number } | null { + const doc = view.state.doc; + const line = doc.lineAt(pos); + let start = pos; + let end = pos; + + while (start > line.from) { + const char = doc.sliceString(start - 1, start); + if (!/[a-zA-Z0-9_]/.test(char)) break; + start--; + } + + while (end < line.to) { + const char = doc.sliceString(end, end + 1); + if (!/[a-zA-Z0-9_]/.test(char)) break; + end++; + } + + if (start === end) return null; + + const text = doc.sliceString(start, end); + return { text, from: start, to: end }; +} + +export const csoundTooltip = hoverTooltip((view, pos) => { + const word = getWordAt(view, pos); + if (!word) return null; + + const reference = getCsoundReference(word.text); + if (!reference) return null; + + return { + pos: word.from, + end: word.to, + above: true, + create() { + const dom = document.createElement('div'); + dom.className = 'csound-tooltip'; + + const header = document.createElement('div'); + header.className = 'csound-tooltip-header'; + + const title = document.createElement('span'); + title.className = 'csound-tooltip-title'; + title.textContent = reference.name; + + const type = document.createElement('span'); + type.className = 'csound-tooltip-type'; + type.textContent = reference.type; + + header.appendChild(title); + header.appendChild(type); + + const description = document.createElement('div'); + description.className = 'csound-tooltip-description'; + description.textContent = reference.description; + + dom.appendChild(header); + dom.appendChild(description); + + if (reference.syntax) { + const syntaxLabel = document.createElement('div'); + syntaxLabel.className = 'csound-tooltip-syntax-label'; + syntaxLabel.textContent = 'Syntax:'; + + const syntax = document.createElement('pre'); + syntax.className = 'csound-tooltip-syntax'; + syntax.textContent = reference.syntax; + + dom.appendChild(syntaxLabel); + dom.appendChild(syntax); + } + + if (reference.rates && reference.rates.length > 0) { + const rates = document.createElement('div'); + rates.className = 'csound-tooltip-rates'; + rates.textContent = `Rates: ${reference.rates.join(', ')}`; + dom.appendChild(rates); + } + + if (reference.parameters && reference.parameters.length > 0) { + const paramsLabel = document.createElement('div'); + paramsLabel.className = 'csound-tooltip-params-label'; + paramsLabel.textContent = `Parameters (${reference.parameters.length}):`; + dom.appendChild(paramsLabel); + + const paramsList = document.createElement('div'); + paramsList.className = 'csound-tooltip-params'; + + reference.parameters.slice(0, 5).forEach(param => { + const paramItem = document.createElement('div'); + paramItem.className = 'csound-tooltip-param'; + + const paramName = document.createElement('span'); + paramName.className = 'csound-tooltip-param-name'; + paramName.textContent = param.name; + + const paramDesc = document.createElement('span'); + paramDesc.className = 'csound-tooltip-param-desc'; + paramDesc.textContent = param.description.length > 60 + ? param.description.substring(0, 60) + '...' + : param.description; + + paramItem.appendChild(paramName); + paramItem.appendChild(paramDesc); + paramsList.appendChild(paramItem); + }); + + if (reference.parameters.length > 5) { + const more = document.createElement('div'); + more.className = 'csound-tooltip-more'; + more.textContent = `... and ${reference.parameters.length - 5} more`; + paramsList.appendChild(more); + } + + dom.appendChild(paramsList); + } + + return { dom }; + } + }; +}); + +export const csoundTooltipTheme = EditorView.theme({ + '.cm-tooltip.cm-tooltip-hover': { + backgroundColor: 'rgba(0, 0, 0, 0.95)', + backdropFilter: 'blur(8px)', + color: '#ffffff', + fontSize: '12px', + fontFamily: 'monospace', + padding: '0', + maxWidth: '500px', + border: '1px solid #3a3a3a', + zIndex: '100' + }, + + '.csound-tooltip': { + padding: '10px 12px' + }, + + '.csound-tooltip-header': { + display: 'flex', + alignItems: 'center', + gap: '8px', + marginBottom: '6px', + paddingBottom: '6px', + borderBottom: '1px solid #3a3a3a' + }, + + '.csound-tooltip-title': { + fontWeight: '600', + color: '#646cff', + fontSize: '14px' + }, + + '.csound-tooltip-type': { + fontSize: '10px', + color: '#9ca3af', + backgroundColor: 'rgba(255, 255, 255, 0.1)', + padding: '2px 6px', + textTransform: 'uppercase' + }, + + '.csound-tooltip-description': { + color: '#e5e7eb', + lineHeight: '1.5', + marginBottom: '8px' + }, + + '.csound-tooltip-syntax-label': { + fontSize: '10px', + color: '#9ca3af', + marginTop: '8px', + marginBottom: '4px', + textTransform: 'uppercase', + fontWeight: '500' + }, + + '.csound-tooltip-syntax': { + backgroundColor: 'rgba(0, 0, 0, 0.4)', + color: '#fbbf24', + padding: '6px 8px', + fontSize: '11px', + fontFamily: 'monospace', + margin: '0 0 8px 0', + whiteSpace: 'pre-wrap', + lineHeight: '1.4', + border: '1px solid #2a2a2a' + }, + + '.csound-tooltip-rates': { + fontSize: '11px', + color: '#60a5fa', + marginBottom: '8px' + }, + + '.csound-tooltip-params-label': { + fontSize: '10px', + color: '#9ca3af', + marginTop: '8px', + marginBottom: '4px', + textTransform: 'uppercase', + fontWeight: '500' + }, + + '.csound-tooltip-params': { + display: 'flex', + flexDirection: 'column', + gap: '4px' + }, + + '.csound-tooltip-param': { + display: 'flex', + gap: '6px', + fontSize: '11px', + lineHeight: '1.4' + }, + + '.csound-tooltip-param-name': { + color: '#10b981', + fontWeight: '500', + minWidth: '60px' + }, + + '.csound-tooltip-param-desc': { + color: '#d1d5db', + flex: '1' + }, + + '.csound-tooltip-more': { + fontSize: '10px', + color: '#9ca3af', + fontStyle: 'italic', + marginTop: '4px' + } +}); diff --git a/src/lib/csound-reference/instrument-control-clock-control.ts b/src/lib/csound-reference/instrument-control-clock-control.ts new file mode 100644 index 0000000..46745c1 --- /dev/null +++ b/src/lib/csound-reference/instrument-control-clock-control.ts @@ -0,0 +1,37 @@ +import type { CsoundReference } from './types' + +// Instrument Control:Clock Control +export const instrumentControlClockControl: CsoundReference[] = [ +{ + name: 'clockoff', + type: 'opcode', + category: 'Instrument Control:Clock Control', + description: 'Stops one of a number of internal clocks.', + syntax: 'clockoff(inum)', + example: '--8<-- "examples/clockoff-modern.csd"', + parameters: [ + { + name: 'inum', + description: 'the number of a clock. There are 32 clocks numbered 0 through 31. All other values are mapped to clock number 32.', + type: 'initialization' + }, + ], + seeAlso: ['Clock Control'] +}, +{ + name: 'clockon', + type: 'opcode', + category: 'Instrument Control:Clock Control', + description: 'Starts one of a number of internal clocks.', + syntax: 'clockon(inum)', + example: '--8<-- "examples/clockon-modern.csd"', + parameters: [ + { + name: 'inum', + description: 'the number of a clock. There are 32 clocks numbered 0 through 31. All other values are mapped to clock number 32.', + type: 'initialization' + }, + ], + seeAlso: ['Clock Control'] +}, +] diff --git a/src/lib/csound-reference/instrument-control-compilation.ts b/src/lib/csound-reference/instrument-control-compilation.ts new file mode 100644 index 0000000..1b874cf --- /dev/null +++ b/src/lib/csound-reference/instrument-control-compilation.ts @@ -0,0 +1,94 @@ +import type { CsoundReference } from './types' + +// Instrument Control:Compilation +export const instrumentControlCompilation: CsoundReference[] = [ +{ + name: 'compilecsd', + type: 'opcode', + category: 'Instrument Control:Compilation', + description: 'Compiles a new orchestra from an ASCII file.', + syntax: 'ires = compilecsd(Sfilename)', + example: '--8<-- "examples/compilecsd-modern.csd"', + rates: ['i-rate'], + parameters: [ + { + name: 'ires', + description: 'returns 0 if compilation was successful, or -1 if not.', + type: 'initialization' + }, + ], + seeAlso: ['Instrument Invocation'] +}, +{ + name: 'compileorc', + type: 'opcode', + category: 'Instrument Control:Compilation', + description: 'Compiles a new orchestra from an ASCII file.', + syntax: 'ires = compileorc(Sfilename)', + example: '--8<-- "examples/compileorc-modern.csd"', + rates: ['i-rate'], + parameters: [ + { + name: 'ires', + description: 'returns 0 if compilation was successful, or -1 if not.', + type: 'initialization' + }, + ], + seeAlso: ['Instrument Invocation'] +}, +{ + name: 'compilestr', + type: 'opcode', + category: 'Instrument Control:Compilation', + description: 'Compiles a new orchestra passed in as an ASCII string.', + syntax: 'ires = compilestr(Sorch)', + example: '--8<-- "examples/compilestr-modern.csd"', + rates: ['i-rate'], + parameters: [ + { + name: 'ires', + description: 'returns 0 if compilation was successful, or -1 if not.', + type: 'initialization' + }, + ], + seeAlso: ['Instrument Invocation'] +}, +{ + name: 'evalstr', + type: 'opcode', + category: 'Instrument Control:Compilation', + description: 'Evaluates a string containing Csound code, returning a value from the global space (instr 0).', + syntax: 'ires = evalstr(Scode)\n kres = evalstr(Scode, ktrig)', + example: 'ival evalstr "return 2 + 2"\nprint ival', + rates: ['k-rate', 'i-rate'], + parameters: [ + { + name: 'Scode', + description: 'a string to be compiled and evaluated.', + type: 'initialization' + }, + { + name: 'ktrig', + description: 'triggers the compilation/evaluation if non-zero.', + type: 'performance' + }, + ], + seeAlso: ['String Manipulation Opcodes'] +}, +{ + name: 'return', + type: 'opcode', + category: 'Instrument Control:Compilation', + description: 'Returns a value from an instrument at i-time.', + syntax: 'return(ival)', + example: 'ival evalstr "return 2 + 2"\nprint ival', + parameters: [ + { + name: 'ival', + description: 'a value to be returned by instrument.', + type: 'initialization' + }, + ], + seeAlso: ['String Manipulation Opcodes'] +}, +] diff --git a/src/lib/csound-reference/instrument-control-conditional-values.ts b/src/lib/csound-reference/instrument-control-conditional-values.ts new file mode 100644 index 0000000..f423411 --- /dev/null +++ b/src/lib/csound-reference/instrument-control-conditional-values.ts @@ -0,0 +1,53 @@ +import type { CsoundReference } from './types' + +// Instrument Control:Conditional Values +export const instrumentControlConditionalValues: CsoundReference[] = [ +{ + name: 'equals', + type: 'opcode', + category: 'Instrument Control:Conditional Values', + description: 'Compares two values for equality.', + example: '--8<-- "examples/equals.csd"', + seeAlso: ['Conditional Values'] +}, +{ + name: 'greaterequal', + type: 'opcode', + category: 'Instrument Control:Conditional Values', + description: 'Determines if one value is greater than or equal to another.', + example: '--8<-- "examples/greaterequal.csd"', + seeAlso: ['Conditional Values'] +}, +{ + name: 'greaterthan', + type: 'opcode', + category: 'Instrument Control:Conditional Values', + description: 'Determines if one value is greater than another.', + example: '--8<-- "examples/greaterthan.csd"', + seeAlso: ['Conditional Values'] +}, +{ + name: 'lessequal', + type: 'opcode', + category: 'Instrument Control:Conditional Values', + description: 'Determines if one value is less than or equal to another.', + example: '--8<-- "examples/lessequal.csd"', + seeAlso: ['Conditional Values'] +}, +{ + name: 'lessthan', + type: 'opcode', + category: 'Instrument Control:Conditional Values', + description: 'Determines if one value is less than another.', + example: '--8<-- "examples/lessthan.csd"', + seeAlso: ['Conditional Values'] +}, +{ + name: 'notequal', + type: 'opcode', + category: 'Instrument Control:Conditional Values', + description: 'Determines if one value is not equal to another.', + example: '--8<-- "examples/notequal.csd"', + seeAlso: ['Conditional Values'] +}, +] diff --git a/src/lib/csound-reference/instrument-control-duration-control.ts b/src/lib/csound-reference/instrument-control-duration-control.ts new file mode 100644 index 0000000..01dd48f --- /dev/null +++ b/src/lib/csound-reference/instrument-control-duration-control.ts @@ -0,0 +1,21 @@ +import type { CsoundReference } from './types' + +// Instrument Control:Duration Control +export const instrumentControlDurationControl: CsoundReference[] = [ +{ + name: 'ihold', + type: 'opcode', + category: 'Instrument Control:Duration Control', + description: 'Causes a finite-duration note to become a “held” note.', + syntax: 'ihold()', + example: '--8<-- "examples/ihold-modern.csd"', + parameters: [ + { + name: 'ihold', + description: 'this i-time statement causes a finite-duration note to become a “held” note. It thus has the same effect as a negative p3 ( see score [i Statement](../scoregens/i.md)), except that p3 here remains positive and the instrument reclassifies itself to being held indefinitely. The note can be turned off explicitly with _turnoff_, or its space taken over by another note of the same instrument number (i.e. it is tied into that note). Effective at i-time only; no-op during a _reinit_ pass.', + type: 'performance' + }, + ], + seeAlso: ['Duration Control Statements'] +}, +] diff --git a/src/lib/csound-reference/instrument-control-initialization-and-reinitialization.ts b/src/lib/csound-reference/instrument-control-initialization-and-reinitialization.ts new file mode 100644 index 0000000..9ebf0f7 --- /dev/null +++ b/src/lib/csound-reference/instrument-control-initialization-and-reinitialization.ts @@ -0,0 +1,185 @@ +import type { CsoundReference } from './types' + +// Instrument Control:Initialization and Reinitialization +export const instrumentControlInitializationAndReinitialization: CsoundReference[] = [ +{ + name: 'assign', + type: 'opcode', + category: 'Instrument Control:Initialization and Reinitialization', + description: 'Performs a simple assignment.', + example: '--8<-- "examples/assign-modern.csd"', + seeAlso: ['Initialization and Reinitialization', 'Array opcodes'] +}, +{ + name: 'create', + type: 'opcode', + category: 'Instrument Control:Initialization and Reinitialization', + description: '', + syntax: 'var:InstrDef = create(code:S)\n var:Instr = create(instr:InstrDef)\n var:Opcode = create(opc:OpcodeDef[,overload:i]\n var:Opcode[] = create(opc:OpcodeDef,len:i[,overload:i])', + example: '--8<-- "examples/create.csd"', + parameters: [ + { + name: 'code', + description: 'String containing Csound language code for an instrument.', + type: 'initialization' + }, + { + name: 'instr', + description: 'compiled instrument definition.', + type: 'initialization' + }, + { + name: 'opc', + description: 'opcode definition', + type: 'initialization' + }, + { + name: 'overload', + description: '(optional, defaults to 0) opcode overload (version) (see [opcodeinfo](../opcodes/opcodeinfo.md))', + type: 'initialization' + }, + { + name: 'len', + description: 'opcode object array length.', + type: 'initialization' + }, + ], +}, +{ + name: 'init', + type: 'opcode', + category: 'Instrument Control:Initialization and Reinitialization', + description: 'Initialises one or more objects.', + syntax: 'var:{a,k,i,S,OpcodeDef}[,...] = init(arg:{i,S}[,...])\n var{i[],k[],a[]} = init(size1:i[,size2:i,...])\n err:i = init(inst:Instr[,p4:i,...])\n [var:*,... =] init(op:Opcode[,arg1:*,...])', + example: '--8<-- "examples/init.csd"', + seeAlso: ['Initialization and Reinitialization', 'Array opcodes'] +}, +{ + name: 'nstrnum', + type: 'opcode', + category: 'Instrument Control:Initialization and Reinitialization', + description: 'Returns the number of a named instrument.', + syntax: 'insno = nstrnum("name")', + example: '--8<-- "examples/nstrnum_nstrstr.csd"', + parameters: [ + { + name: 'insno', + description: 'the instrument number of the named instrument.', + type: 'initialization' + }, + ], + seeAlso: ['Initialization and Reinitialization'] +}, +{ + name: 'nstrstr', + type: 'opcode', + category: 'Instrument Control:Initialization and Reinitialization', + description: 'Returns the string of a named instr from its number or an empty string if no such association exists.', + syntax: 'Sname = nstrstr(insno)\n Sname = nstrstr(knsno)', + example: '--8<-- "examples/nstrnum_nstrstr.csd"', + parameters: [ + { + name: 'insno', + description: 'the instrument number of the named instrument.', + type: 'initialization' + }, + { + name: 'knsno', + description: 'the named instrument\'s number.', + type: 'performance' + }, + { + name: 'Sname', + description: 'the named instrument\'s name.', + type: 'performance' + }, + ], +}, +{ + name: 'opcodeinfo', + type: 'opcode', + category: 'Instrument Control:Initialization and Reinitialization', + description: '', + syntax: 'opcodeinfo(opc:OpcodeDef)\n opcodeinfo(obj:Opcode)', + example: '--8<-- "examples/opcodeinfo.csd"', + parameters: [ + { + name: 'opc', + description: 'opcode definition', + type: 'initialization' + }, + { + name: 'obj', + description: 'opcode object', + type: 'initialization' + }, + ], +}, +{ + name: 'p', + type: 'opcode', + category: 'Instrument Control:Initialization and Reinitialization', + description: 'Show the value in a given p-field.', + example: '--8<-- "examples/p.csd"', + parameters: [ + { + name: 'x', + description: 'the number of the p-field.', + type: 'initialization' + }, + ], + seeAlso: ['Initialization and Reinitialization'] +}, +{ + name: 'passign', + type: 'opcode', + category: 'Instrument Control:Initialization and Reinitialization', + description: 'Assigns a range of p-fields to ivariables, or i- or k-array.', + syntax: 'ivar1, ... = passign([istart][, iend])\n iarray = passign([istart][, iend])\n karray = passign([istart][, iend])', + example: '--8<-- "examples/passign.csd"', + seeAlso: ['assign', 'pcount', 'Initialization and Reinitialization'] +}, +{ + name: 'plusbecomes', + type: 'opcode', + category: 'Instrument Control:Initialization and Reinitialization', + description: 'Performs add and assignment.', + example: '--8<-- "examples/reverb.csd"', + seeAlso: ['Initialization and Reinitialization'] +}, +{ + name: 'pset', + type: 'opcode', + category: 'Instrument Control:Initialization and Reinitialization', + description: 'Defines and initializes numeric arrays at orchestra load time.', + syntax: 'pset(icon1 [, icon2] [...])', + example: '--8<-- "examples/pset.csd"', + seeAlso: ['Initialization and Reinitialization', 'Orchestra Header Statements'] +}, +{ + name: 'reinit', + type: 'opcode', + category: 'Instrument Control:Initialization and Reinitialization', + description: 'Suspends a performance while a special initialization pass is executed.', + syntax: 'reinit(label)', + example: '--8<-- "examples/reinit-modern.csd"', + seeAlso: ['Initialization and Reinitialization'] +}, +{ + name: 'rigoto', + type: 'opcode', + category: 'Instrument Control:Initialization and Reinitialization', + description: 'Transfers control during a reinit pass.', + syntax: 'rigoto(label)', + seeAlso: ['Initialization and Reinitialization'] +}, +{ + name: 'rireturn', + type: 'opcode', + category: 'Instrument Control:Initialization and Reinitialization', + description: 'Terminates a [reinit](../opcodes/reinit.md) pass (i.e., no-op at standard i-time).', + syntax: 'rireturn()', + example: '--8<-- "examples/reinit.csd"', + seeAlso: ['Initialization and Reinitialization'] +}, +] diff --git a/src/lib/csound-reference/instrument-control-invocation.ts b/src/lib/csound-reference/instrument-control-invocation.ts new file mode 100644 index 0000000..bb474bd --- /dev/null +++ b/src/lib/csound-reference/instrument-control-invocation.ts @@ -0,0 +1,313 @@ +import type { CsoundReference } from './types' + +// Instrument Control:Invocation +export const instrumentControlInvocation: CsoundReference[] = [ +{ + name: 'event', + type: 'opcode', + category: 'Instrument Control:Invocation', + description: 'Generates a score event from an instrument.', + syntax: 'event("scorechar", kinsnum, kdelay, kdur, [, kp4] [, kp5] [, ...])\n event("scorechar", "insname", kdelay, kdur, [, kp4] [, kp5] [, ...])', + example: '--8<-- "examples/event.csd"', + parameters: [ + { + name: 'kinsnum', + description: 'The instrument to use for the event. This corresponds to the first p-field, p1, in a score statement.', + type: 'performance' + }, + { + name: 'kdelay', + description: 'When (in seconds) the event will occur from the current performance time. This corresponds to the second p-field, p2, in a score statement.', + type: 'performance' + }, + { + name: 'kdur', + description: 'How long (in seconds) the event will happen. This corresponds to the third p-field, p3, in a score statement.', + type: 'performance' + }, + ], + seeAlso: ['Instrument Invocation'] +}, +{ + name: 'event_i', + type: 'opcode', + category: 'Instrument Control:Invocation', + description: 'Generates a score event from an instrument.', + syntax: 'event_i("scorechar", iinsnum, idelay, idur, [, ip4] [, ip5] [, ...])\n event_i("scorechar", "insname", idelay, idur, [, ip4] [, ip5] [, ...])', + example: '--8<-- "examples/event_i.csd"', + parameters: [ + { + name: 'iinsnum', + description: 'The instrument to use for the event. This corresponds to the first p-field, p1, in a score statement.', + type: 'initialization' + }, + { + name: 'idelay', + description: 'When (in seconds) the event will occur from the current performance time. This corresponds to the second p-field, p2, in a score statement.', + type: 'initialization' + }, + { + name: 'idur', + description: 'How long (in seconds) the event will happen. This corresponds to the third p-field, p3, in a score statement.', + type: 'initialization' + }, + ], + seeAlso: ['Instrument Invocation'] +}, +{ + name: 'mute', + type: 'opcode', + category: 'Instrument Control:Invocation', + description: 'Mutes/unmutes new instances of a given instrument.', + syntax: 'mute(insnum [, iswitch])\n mute("insname" [, iswitch])', + example: '--8<-- "examples/mute.csd"', + parameters: [ + { + name: 'insnum', + description: 'instrument number. Equivalent to _p1_ in a score [i statement](../scoregens/i.md).', + type: 'initialization' + }, + ], + seeAlso: ['Instrument Invocation'] +}, +{ + name: 'nstance', + type: 'opcode', + category: 'Instrument Control:Invocation', + description: 'Schedules a new instrument instance, storing the instance handle in a variable.', + syntax: 'iHandle = nstance(insnum, iwhen, idur [, ip4] [, ip5] [...])\n iHandle = nstance("insname", iwhen, idur [, ip4] [, ip5] [...])', + example: '--8<-- "examples/nstance.csd"', + parameters: [ + { + name: 'iHandle', + description: 'this variable will contain a handle to the event instance. It can be used, for example, to stop the given instrument instance via the turnoff opcode. Note that the instance handle is only valid once the instrument is initialised.', + type: 'initialization' + }, + { + name: 'insnum', + description: 'instrument number. Equivalent to p1 in a score [i statement](../scoregens/i.md). _insnum_ must be a number greater than the number of the calling instrument.', + type: 'initialization' + }, + { + name: 'iwhen', + description: 'start time of the new event. Equivalent to p2 in a score [i statement](../scoregens/i.md). _iwhen_ must be nonnegative. If _iwhen_ is zero, _insum_ must be greater than or equal to the p1 of the current instrument.', + type: 'initialization' + }, + { + name: 'idur', + description: 'duration of event. Equivalent to p3 in a score [i statement](../scoregens/i.md).', + type: 'initialization' + }, + ], + seeAlso: ['Instrument Invocation', 'http://www.csoundjournal.com/issue15/phrase_loops.html'] +}, +{ + name: 'readscore', + type: 'opcode', + category: 'Instrument Control:Invocation', + description: 'Read, preprocess and schedule a score from an input string.', + syntax: 'readscore(Sin)', + example: '--8<-- "examples/readscore.csd"', + seeAlso: ['Instrument Invocation'] +}, +{ + name: 'remove', + type: 'opcode', + category: 'Instrument Control:Invocation', + description: 'Removes the definition of an instrument as long as it is not in use.', + syntax: 'remove(insnum)', + parameters: [ + { + name: 'insnum', + description: 'number or name of the instrument to be deleted', + type: 'initialization' + }, + ], + seeAlso: ['Instrument Invocation'] +}, +{ + name: 'schedkwhen', + type: 'opcode', + category: 'Instrument Control:Invocation', + description: 'Adds a new score event generated by a k-rate trigger.', + syntax: 'schedkwhen(ktrigger, kmintim, kmaxnum, kinsnum, kwhen, kdur )\n [, ip4] [, ip5] [...])\n schedkwhen(ktrigger, kmintim, kmaxnum, "insname", kwhen, kdur \\\n [, ip4] [, ip5] [...])', + example: '--8<-- "examples/schedkwhen.csd"', + parameters: [ + { + name: 'ktrigger', + description: 'triggers a new score event. If _ktrigger_ = 0, no new event is triggered.', + type: 'performance' + }, + { + name: 'kmintim', + description: 'minimum time between generated events, in seconds. If _kmintim_ <= 0, no time limit exists. If the _kinsnum_ is negative (to turn off an instrument), this test is bypassed.', + type: 'performance' + }, + { + name: 'kmaxnum', + description: 'maximum number of simultaneous instances of instrument _kinsnum_ allowed. If the number of existant instances of _kinsnum_ is >= _kmaxnum_, no new event is generated. If _kmaxnum_ is <= 0, it is not used to limit event generation. If the _kinsnum_ is negative (to turn off an instrument), this test is bypassed.', + type: 'performance' + }, + { + name: 'kinsnum', + description: 'instrument number. Equivalent to p1 in a score [i statement](../scoregens/i.md).', + type: 'performance' + }, + { + name: 'kwhen', + description: 'start time of the new event. Equivalent to p2 in a score [i statement](../scoregens/i.md). Measured from the time of the triggering event. _kwhen_ must be >= 0. If _kwhen_ > 0, the instrument will not be initialized until the actual time when it should start performing.', + type: 'performance' + }, + { + name: 'kdur', + description: 'duration of event. Equivalent to p3 in a score [i statement](../scoregens/i.md). If _kdur_ = 0, the instrument will only do an initialization pass, with no performance. If _kdur_ is negative, a held note is initiated. (See [ihold](../opcodes/ihold.md) and [i statement](../scoregens/i.md).)', + type: 'performance' + }, + ], + seeAlso: ['Instrument Invocation'] +}, +{ + name: 'schedkwhennamed', + type: 'opcode', + category: 'Instrument Control:Invocation', + description: 'Similar to [schedkwhen](../opcodes/schedkwhen.md) but uses a named instrument at init-time.', + syntax: 'schedkwhennamed(ktrigger, kmintim, kmaxnum, "name", kwhen, kdur \\\n [, ip4] [, ip5] [...])', + example: '--8<-- "examples/schedkwhennamed.csd"', + parameters: [ + { + name: 'ktrigger', + description: 'triggers a new score event. If _ktrigger_ is 0, no new event is triggered.', + type: 'performance' + }, + { + name: 'kmintim', + description: 'minimum time between generated events, in seconds. If _kmintim_ is less than or equal to 0, no time limit exists.', + type: 'performance' + }, + { + name: 'kmaxnum', + description: 'maximum number of simultaneous instances of named instrument allowed. If the number of existant instances of the named instrument is greater than or equal to _kmaxnum_, no new event is generated. If _kmaxnum_ is less than or equal to 0, it is not used to limit event generation.', + type: 'performance' + }, + { + name: 'kwhen', + description: 'start time of the new event. Equivalent to p2 in a score [i statement](../scoregens/i.md). Measured from the time of the triggering event. _kwhen_ must be greater than or equal to 0. If _kwhen_ greater than 0, the instrument will not be initialized until the actual time when it should start performing.', + type: 'performance' + }, + { + name: 'kdur', + description: 'duration of event. Equivalent to p3 in a score [i statement](../scoregens/i.md). If _kdur_ is 0, the instrument will only do an initialization pass, with no performance. If _kdur_ is negative, a held note is initiated. (See [ihold](../opcodes/ihold.md) and [i statement](../scoregens/i.md).)', + type: 'performance' + }, + ], + seeAlso: ['Instrument Invocation'] +}, +{ + name: 'schedule', + type: 'opcode', + category: 'Instrument Control:Invocation', + description: 'Adds a new score event.', + syntax: 'schedule(insnum, iwhen, idur [, ip4] [, ip5] [...])\n schedule("insname", iwhen, idur [, ip4] [, ip5] [...])\n schedule(iPar[])', + example: '--8<-- "examples/schedule.csd"', + parameters: [ + { + name: 'insnum', + description: 'instrument number. Equivalent to p1 in a score [i statement](../scoregens/i.md). _insnum_ must be a number greater than the number of the calling instrument.', + type: 'initialization' + }, + { + name: 'iwhen', + description: 'start time of the new event. Equivalent to p2 in a score [i statement](../scoregens/i.md). _iwhen_ must be nonnegative. If _iwhen_ is zero, _insum_ must be greater than or equal to the p1 of the current instrument.', + type: 'initialization' + }, + { + name: 'idur', + description: 'duration of event. Equivalent to p3 in a score [i statement](../scoregens/i.md).', + type: 'initialization' + }, + ], + seeAlso: ['Instrument Invocation', 'http://www.csoundjournal.com/issue15/phrase_loops.html'] +}, +{ + name: 'schedulek', + type: 'opcode', + category: 'Instrument Control:Invocation', + description: 'Adds a new score event.', + syntax: 'schedulek(knsnum, kwhen, kdur [, kp4] [, kp5] [...])\n schedulek("insname", kwhen, kdur [, kp4] [, kp5] [...])\n schedulek(kPar[])', + example: '--8<-- "examples/schedulek.csd"', + parameters: [ + { + name: 'knsnum', + description: 'instrument number. Equivalent to p1 in a score [i statement](../scoregens/i.md). _knsnum_ must be a number greater than the number of the calling instrument.', + type: 'performance' + }, + { + name: 'kwhen', + description: 'start time of the new event. Equivalent to p2 in a score [i statement](../scoregens/i.md). _kwhen_ must be nonnegative. If _kwhen_ is zero, _insum_ must be greater than or equal to the p1 of the current instrument.', + type: 'performance' + }, + { + name: 'kdur', + description: 'duration of event. Equivalent to p3 in a score [i statement](../scoregens/i.md).', + type: 'performance' + }, + ], + seeAlso: ['Instrument Invocation'] +}, +{ + name: 'schedwhen', + type: 'opcode', + category: 'Instrument Control:Invocation', + description: 'Adds a new score event.', + syntax: 'schedwhen(ktrigger, kinsnum, kwhen, kdur [, ip4] [, ip5] [...])\n schedwhen(ktrigger, "insname", kwhen, kdur [, ip4] [, ip5] [...])', + example: '--8<-- "examples/schedwhen.csd"', + parameters: [ + { + name: 'kinsnum', + description: 'instrument number. Equivalent to p1 in a score [i statement](../scoregens/i.md).', + type: 'performance' + }, + { + name: 'ktrigger', + description: 'trigger value for new event', + type: 'performance' + }, + { + name: 'kwhen', + description: 'start time of the new event. Equivalent to p2 in a score [i statement](../scoregens/i.md).', + type: 'performance' + }, + { + name: 'kdur', + description: 'duration of event. Equivalent to p3 in a score [i statement](../scoregens/i.md).', + type: 'performance' + }, + ], + seeAlso: ['Instrument Invocation'] +}, +{ + name: 'scoreline', + type: 'opcode', + category: 'Instrument Control:Invocation', + description: 'Issues one or more score line events from an instrument.', + syntax: 'scoreline(Sin, ktrig)', + example: '--8<-- "examples/scoreline.csd"', + parameters: [ + { + name: 'ktrig', + description: 'event trigger, 1 issues the score event, 0 bypasses it.', + type: 'performance' + }, + ], + seeAlso: ['Instrument Invocation', 'http://www.csoundjournal.com/issue15/phrase_loops.html', 'https://flossmanual.csound.com/csound-language/live-events'] +}, +{ + name: 'scoreline_i', + type: 'opcode', + category: 'Instrument Control:Invocation', + description: 'Issues one or more score line events from an instrument at i-time.', + syntax: 'scoreline_i(Sin)', + example: '--8<-- "examples/scoreline_i.csd"', + seeAlso: ['Instrument Invocation', 'http://www.csoundjournal.com/issue15/phrase_loops.html', 'https://flossmanual.csound.com/csound-language/live-events'] +}, +] diff --git a/src/lib/csound-reference/instrument-control-program-flow-control.ts b/src/lib/csound-reference/instrument-control-program-flow-control.ts new file mode 100644 index 0000000..37837d8 --- /dev/null +++ b/src/lib/csound-reference/instrument-control-program-flow-control.ts @@ -0,0 +1,288 @@ +import type { CsoundReference } from './types' + +// Instrument Control:Program Flow Control +export const instrumentControlProgramFlowControl: CsoundReference[] = [ +{ + name: 'break', + type: 'opcode', + category: 'Instrument Control:Program Flow Control', + description: 'A syntactic looping construction used in for, while, and until loops.', + example: '--8<-- "examples/break.csd"', + seeAlso: ['Program Flow Control: Looping Constructions'] +}, +{ + name: 'cggoto', + type: 'opcode', + category: 'Instrument Control:Program Flow Control', + description: 'Conditionally transfer control to _label_ on every pass. (Combination of [cigoto](../opcodes/cigoto.md) and [ckgoto](../opcodes/ckgoto.md))', + syntax: 'cggoto(condition, label)', + example: '--8<-- "examples/cggoto-modern.csd"', + seeAlso: ['Program Flow Control'] +}, +{ + name: 'cigoto', + type: 'opcode', + category: 'Instrument Control:Program Flow Control', + description: 'During the i-time pass only, conditionally transfer control to the statement labeled by _label_.', + syntax: 'cigoto(condition, label)', + example: '--8<-- "examples/cigoto-modern.csd"', + seeAlso: ['Program Flow Control'] +}, +{ + name: 'ckgoto', + type: 'opcode', + category: 'Instrument Control:Program Flow Control', + description: 'During the p-time passes only, conditionally transfer control to the statement labeled by _label_.', + syntax: 'ckgoto(condition, label)', + example: '--8<-- "examples/ckgoto-modern.csd"', + seeAlso: ['Program Flow Control'] +}, +{ + name: 'cngoto', + type: 'opcode', + category: 'Instrument Control:Program Flow Control', + description: 'Transfers control on every pass when the condition is _not_ true.', + syntax: 'cngoto(condition, label)', + example: '--8<-- "examples/cngoto-modern.csd"', + seeAlso: ['Program Flow Control'] +}, +{ + name: 'continue', + type: 'opcode', + category: 'Instrument Control:Program Flow Control', + description: 'A syntactic looping construction used in for, while, and until loops.', + example: '--8<-- "examples/continue.csd"', + seeAlso: ['Program Flow Control: Looping Constructions'] +}, +{ + name: 'else', + type: 'opcode', + category: 'Instrument Control:Program Flow Control', + description: 'Executes a block of code when an "if...then" condition is false.', + example: '--8<-- "examples/else.csd"', + seeAlso: ['Program Flow Control', 'http://www.csoundjournal.com/2006spring/controlFlow.html'] +}, +{ + name: 'elseif', + type: 'opcode', + category: 'Instrument Control:Program Flow Control', + description: 'Defines another "if...then" condition when a "if...then" condition is false.', + example: '--8<-- "examples/elseif.csd"', + seeAlso: ['Program Flow Control', 'http://www.csoundjournal.com/2006spring/controlFlow.html'] +}, +{ + name: 'endif', + type: 'opcode', + category: 'Instrument Control:Program Flow Control', + description: 'Closes a block of code that begins with an ["if...then"](../opcodes/if.md) statement.', + example: '--8<-- "examples/endif.csd"', + seeAlso: ['Program Flow Control', 'http://www.csoundjournal.com/2006spring/controlFlow.html'] +}, +{ + name: 'for', + type: 'opcode', + category: 'Instrument Control:Program Flow Control', + description: 'A syntactic looping construction.', + example: '--8<-- "examples/forin.csd"', + seeAlso: ['Program Flow Control: Looping Constructions'] +}, +{ + name: 'goto', + type: 'opcode', + category: 'Instrument Control:Program Flow Control', + description: 'Transfer control to _label_ on every pass. (Combination of [igoto](../opcodes/igoto.md) and [kgoto](../opcodes/kgoto.md))', + syntax: 'goto(label)', + example: '--8<-- "examples/goto-modern.csd"', + seeAlso: ['Program Flow Control'] +}, +{ + name: 'if', + type: 'opcode', + category: 'Instrument Control:Program Flow Control', + description: 'Branches conditionally at initialization or during performance time.', + example: '--8<-- "examples/igoto.csd"', + seeAlso: ['Program Flow Control'] +}, +{ + name: 'igoto', + type: 'opcode', + category: 'Instrument Control:Program Flow Control', + description: 'During the i-time pass only, unconditionally transfer control to the statement labeled by _label_.', + syntax: 'igoto(label)', + example: '--8<-- "examples/igoto-modern.csd"', + seeAlso: ['Program Flow Control'] +}, +{ + name: 'kgoto', + type: 'opcode', + category: 'Instrument Control:Program Flow Control', + description: 'During the p-time passes only, unconditionally transfer control to the statement labeled by _label_.', + syntax: 'kgoto(label)', + example: '--8<-- "examples/kgoto.csd"', + seeAlso: ['Program Flow Control'] +}, +{ + name: 'loop_ge', + type: 'opcode', + category: 'Instrument Control:Program Flow Control', + description: 'Construction of looping operations.', + syntax: 'loop_ge(indx, idecr, imin, label)\n loop_ge(kndx, kdecr, kmin, label)', + example: '--8<-- "examples/loop_-group-modern.csd"', + parameters: [ + { + name: 'indx', + description: 'i-rate variable to count loop.', + type: 'initialization' + }, + { + name: 'idecr', + description: 'value to decrement the loop.', + type: 'initialization' + }, + { + name: 'imin', + description: 'minimum value of loop index.', + type: 'initialization' + }, + { + name: 'kndx', + description: 'k-rate variable to count loop.', + type: 'performance' + }, + { + name: 'kdecr', + description: 'value to decrement the loop.', + type: 'performance' + }, + { + name: 'kmin', + description: 'minimum value of loop index.', + type: 'performance' + }, + ], + seeAlso: ['Program Flow Control: Looping Constructions', 'http://www.csoundjournal.com/2006summer/controlFlow_part2.html', ' https://flossmanual.csound.com/csound-language/control-structures'] +}, +{ + name: 'loop_gt', + type: 'opcode', + category: 'Instrument Control:Program Flow Control', + description: 'Construction of looping operations.', + syntax: 'loop_gt(indx, idecr, imin, label)\n loop_gt(kndx, kdecr, kmin, label)', + example: '--8<-- "examples/loop_gt.csd"', + parameters: [ + { + name: 'indx', + description: 'i-rate variable to count loop.', + type: 'initialization' + }, + { + name: 'idecr', + description: 'value to decrement the loop.', + type: 'initialization' + }, + { + name: 'imin', + description: 'minimum value of loop index.', + type: 'initialization' + }, + { + name: 'kndx', + description: 'k-rate variable to count loop.', + type: 'performance' + }, + { + name: 'kdecr', + description: 'value to decrement the loop.', + type: 'performance' + }, + { + name: 'kmin', + description: 'minimum value of loop index.', + type: 'performance' + }, + ], + seeAlso: ['Program Flow Control: Looping Constructions', 'http://www.csoundjournal.com/2006summer/controlFlow_part2.html', ' https://flossmanual.csound.com/csound-language/control-structures'] +}, +{ + name: 'loop_le', + type: 'opcode', + category: 'Instrument Control:Program Flow Control', + description: 'Construction of looping operations.', + syntax: 'loop_le(indx, incr, imax, label)\n loop_le(kndx, kncr, kmax, label)', + example: '--8<-- "examples/loop_le.csd"', + parameters: [ + { + name: 'indx', + description: 'i-rate variable to count loop.', + type: 'initialization' + }, + { + name: 'incr', + description: 'value to increment the loop.', + type: 'initialization' + }, + { + name: 'imax', + description: 'maximum value of loop index.', + type: 'initialization' + }, + { + name: 'kndx', + description: 'k-rate variable to count loop.', + type: 'performance' + }, + { + name: 'kncr', + description: 'value to increment the loop.', + type: 'performance' + }, + { + name: 'kmax', + description: 'maximum value of loop index.', + type: 'performance' + }, + ], + seeAlso: ['Program Flow Control: Looping Constructions', 'http://www.csoundjournal.com/2006summer/controlFlow_part2.html', ' https://flossmanual.csound.com/csound-language/control-structures'] +}, +{ + name: 'loop_lt', + type: 'opcode', + category: 'Instrument Control:Program Flow Control', + description: 'Construction of looping operations.', + syntax: 'loop_lt(indx, incr, imax, label)\n loop_lt(kndx, kncr, kmax, label)', + example: '--8<-- "examples/loop_lt.csd"', + parameters: [ + { + name: 'indx', + description: 'i-rate variable to count loop.', + type: 'initialization' + }, + { + name: 'incr', + description: 'value to increment the loop.', + type: 'initialization' + }, + { + name: 'imax', + description: 'maximum value of loop index.', + type: 'initialization' + }, + { + name: 'kndx', + description: 'k-rate variable to count loop.', + type: 'performance' + }, + { + name: 'kncr', + description: 'value to increment the loop.', + type: 'performance' + }, + { + name: 'kmax', + description: 'maximum value of loop index.', + type: 'performance' + }, + ], + seeAlso: ['Program Flow Control: Looping Constructions', 'http://www.csoundjournal.com/2006summer/controlFlow_part2.html', ' https://flossmanual.csound.com/csound-language/control-structures'] +}, +] diff --git a/src/lib/csound-reference/instrument-control-realtime-performance-control.ts b/src/lib/csound-reference/instrument-control-realtime-performance-control.ts new file mode 100644 index 0000000..9dd9ffe --- /dev/null +++ b/src/lib/csound-reference/instrument-control-realtime-performance-control.ts @@ -0,0 +1,175 @@ +import type { CsoundReference } from './types' + +// Instrument Control:Realtime Performance Control +export const instrumentControlRealtimePerformanceControl: CsoundReference[] = [ +{ + name: 'active', + type: 'opcode', + category: 'Instrument Control:Realtime Performance Control', + description: 'Returns the number of active instances of an instrument with options to ignore releasing instances.', + syntax: 'ir = active(insnum [,iopt [,inorel]])\n ir = active(Sinsname [,iopt [,inorel]])\n kres = active(kinsnum [,iopt [,inorel]])', + example: '--8<-- "examples/active-modern.csd"', + rates: ['k-rate'], + parameters: [ + { + name: 'insnum', + description: 'number or string name of the instrument to be reported', + type: 'initialization' + }, + { + name: 'Sinsname', + description: 'instrument name', + type: 'initialization' + }, + { + name: 'iopt', + description: 'select currently active (zero, default), or all every active (non zero)', + type: 'initialization' + }, + { + name: 'inorel', + description: 'if non-zero ignore instruments in release phase (zero, default), only valid if iopts is zero.', + type: 'initialization' + }, + { + name: 'kinsnum', + description: 'number or string name of the instrument to be reported', + type: 'performance' + }, + ], + seeAlso: ['Real-time Performance Control'] +}, +{ + name: 'cpumeter', + type: 'opcode', + category: 'Instrument Control:Realtime Performance Control', + description: 'Reports the usage of cpu either total or per core to monitor how close to max-out the processing is.', + syntax: 'ktot[,kcpu1, kcpu2,...] = cpumeter(ifreq)', + example: '--8<-- "examples/cpumeter.csd"', + seeAlso: ['Real-time Performance Control'] +}, +{ + name: 'cpuprc', + type: 'opcode', + category: 'Instrument Control:Realtime Performance Control', + description: 'Control allocation of cpu resources on a per-instrument basis, to optimize realtime output.', + syntax: 'cpuprc(insnum, ipercent)\n cpuprc(Sinsname, ipercent)', + example: '--8<-- "examples/cpuprc.csd"', + parameters: [ + { + name: 'insnum', + description: 'instrument number or string', + type: 'initialization' + }, + { + name: 'Sinsname', + description: 'instrument number or string', + type: 'initialization' + }, + { + name: 'ipercent', + description: 'percent of cpu processing-time to assign. Can also be expressed as a fractional value.', + type: 'initialization' + }, + ], + seeAlso: ['Real-time Performance Control'] +}, +{ + name: 'exitnow', + type: 'opcode', + category: 'Instrument Control:Realtime Performance Control', + description: 'Exit Csound as fast as possible, with no cleaning up.', + syntax: 'exitnow([ivalue])', + example: '--8<-- "examples/exitnow.csd"', + seeAlso: ['Real-time Performance Control'] +}, +{ + name: 'maxalloc', + type: 'opcode', + category: 'Instrument Control:Realtime Performance Control', + description: 'Limits the number of allocations of an instrument.', + syntax: 'maxalloc(insnum, icount)\n maxalloc(Sinsname, icount)', + example: '--8<-- "examples/maxalloc.csd"', + parameters: [ + { + name: 'insnum', + description: 'instrument number', + type: 'initialization' + }, + { + name: 'Sinsname', + description: 'instrument name', + type: 'initialization' + }, + { + name: 'icount', + description: 'number of instrument allocations', + type: 'initialization' + }, + ], + seeAlso: ['Real-time Performance Control'] +}, +{ + name: 'perf', + type: 'opcode', + category: 'Instrument Control:Realtime Performance Control', + description: '', + syntax: 'err:k = perf(ins:Instr[, p4:k, ...])\n [var:*,... =] perf(opc:Opcode[,arg1:*,...])', + example: '--8<-- "examples/create.csd"', + parameters: [ + { + name: 'err', + description: 'error code (0 if successful)', + type: 'performance' + }, + ], + seeAlso: ['Initialization and Reinitialization'] +}, +{ + name: 'prealloc', + type: 'opcode', + category: 'Instrument Control:Realtime Performance Control', + description: 'Creates space for instruments but does not run them.', + syntax: 'prealloc(insnum, icount)\n prealloc("insname", icount)', + example: '--8<-- "examples/prealloc.csd"', + parameters: [ + { + name: 'insnum', + description: 'instrument number', + type: 'initialization' + }, + { + name: 'icount', + description: 'number of instrument allocations', + type: 'initialization' + }, + ], + seeAlso: ['Real-time Performance Control'] +}, +{ + name: 'setp', + type: 'opcode', + category: 'Instrument Control:Realtime Performance Control', + description: '', + syntax: 'setp(ins:Instr,num:k,val:k)', + example: '--8<-- "examples/create.csd"', + parameters: [ + { + name: 'ins', + description: 'instrument instance', + type: 'performance' + }, + { + name: 'num', + description: 'parameter number', + type: 'performance' + }, + { + name: 'val', + description: 'parameter value', + type: 'performance' + }, + ], + seeAlso: ['Initialization and Reinitialization'] +}, +] diff --git a/src/lib/csound-reference/instrument-control-sensing-and-control.ts b/src/lib/csound-reference/instrument-control-sensing-and-control.ts new file mode 100644 index 0000000..7e12f09 --- /dev/null +++ b/src/lib/csound-reference/instrument-control-sensing-and-control.ts @@ -0,0 +1,1097 @@ +import type { CsoundReference } from './types' + +// Instrument Control:Sensing and Control +export const instrumentControlSensingAndControl: CsoundReference[] = [ +{ + name: 'button', + type: 'opcode', + category: 'Instrument Control:Sensing and Control', + description: 'Sense on-screen controls. Requires Winsound or TCL/TK.', + syntax: 'kres = button(knum)', + example: '--8<-- "examples/checkbox.csd"', + rates: ['k-rate'], + parameters: [ + { + name: 'kres', + description: 'value of the button control. If the button has been pushed since the last k-period, then return 1, otherwise return 0.', + type: 'performance' + }, + { + name: 'knum', + description: 'the number of the button. If it does not exist, it is made on-screen at initialization.', + type: 'performance' + }, + ], + seeAlso: ['Sensing and Control: TCL/TK widgets'] +}, +{ + name: 'changed', + type: 'opcode', + category: 'Instrument Control:Sensing and Control', + description: 'k-rate signal change detector.', + syntax: 'ktrig = changed(kvar1 [, kvar2,..., kvarN])', + example: '--8<-- "examples/changed-modern.csd"', + parameters: [ + { + name: 'ktrig', + description: 'Outputs a value of 1 when any of the k-rate signals has changed, otherwise outputs 0.', + type: 'performance' + }, + ], + seeAlso: ['Sensing and Control: Tempo and Sequencing'] +}, +{ + name: 'changed2', + type: 'opcode', + category: 'Instrument Control:Sensing and Control', + description: 'k-rate signal change detector.', + syntax: 'ktrig = changed2(kvar1 [, kvar2,..., kvarN])\n ktrig = changed2(karr[])\n ktrig = changed2(aarr[])', + example: '--8<-- "examples/changed2-modern.csd"', + parameters: [ + { + name: 'ktrig', + description: 'Outputs a value of 1 when any of the k-rate signals has changed, or any value in the array, otherwise outputs 0.', + type: 'performance' + }, + { + name: 'xarray', + description: 'any array type.', + type: 'performance' + }, + ], + seeAlso: ['Sensing and Control: Tempo and Sequencing'] +}, +{ + name: 'checkbox', + type: 'opcode', + category: 'Instrument Control:Sensing and Control', + description: 'Sense on-screen controls. Requires Winsound or TCL/TK.', + syntax: 'kres = checkbox(knum)', + example: '--8<-- "examples/checkbox-modern.csd"', + rates: ['k-rate'], + parameters: [ + { + name: 'kres', + description: 'value of the checkbox control. If the checkbox is set (pushed) then return 1, if not, return 0.', + type: 'performance' + }, + { + name: 'knum', + description: 'the number of the checkbox. If it does not exist, it is made on-screen at initialization.', + type: 'performance' + }, + ], + seeAlso: ['Sensing and Control: TCL/TK widgets'] +}, +{ + name: 'cntDelete', + type: 'opcode', + category: 'Instrument Control:Sensing and Control', + description: 'Delete a counter and render any memory used.', + syntax: 'kval = cntDelete(icnt)', + parameters: [ + { + name: 'icnt', + description: 'the handle of a counter object from a call to _cntCreate_.', + type: 'initialization' + }, + { + name: 'kval', + description: 'the handle deleted or a negative number if there was no such counter.', + type: 'performance' + }, + ], + seeAlso: ['Program Flow Control: Counter'] +}, +{ + name: 'cntDelete_i', + type: 'opcode', + category: 'Instrument Control:Sensing and Control', + description: 'Delete a counter.', + syntax: 'ival = cntDelete_i(icnt)', + parameters: [ + { + name: 'icnt', + description: 'the handle of a counter object from a call to _cntCreate_.', + type: 'initialization' + }, + { + name: 'ival', + description: 'the handle deleted or a negative number if there was no such counter.', + type: 'performance' + }, + ], + seeAlso: ['Program Flow Control: Counter'] +}, +{ + name: 'cntCreate', + type: 'opcode', + category: 'Instrument Control:Sensing and Control', + description: 'Create a counter object.', + syntax: 'icnt = cntCreate([imax, imin, inc])', + example: '--8<-- "examples/counter.csd"', + parameters: [ + { + name: 'imax', + description: 'optional maximum value for the counter, defaulting to 1.', + type: 'initialization' + }, + { + name: 'imin', + description: 'optional minimun value for the counter, defaulting to 0.', + type: 'initialization' + }, + { + name: 'inc', + description: 'optional increment for the counter, defaulting to 1.', + type: 'initialization' + }, + { + name: 'icnt', + description: 'a handle for the counter.', + type: 'initialization' + }, + ], + seeAlso: ['Program Flow Control: Counter'] +}, +{ + name: 'cntCycles', + type: 'opcode', + category: 'Instrument Control:Sensing and Control', + description: 'Get the number of times a counter has cycled.', + syntax: 'kval = cntCycles(icnt)', + parameters: [ + { + name: 'icnt', + description: 'the handle of a counter object from a call to _cntCreate_.', + type: 'initialization' + }, + { + name: 'kval', + description: 'returned value.', + type: 'performance' + }, + ], + seeAlso: ['Program Flow Control: Counter'] +}, +{ + name: 'cntRead', + type: 'opcode', + category: 'Instrument Control:Sensing and Control', + description: 'Read current value of a counter object without changing it.', + syntax: 'kval = cntRead(icnt)', + parameters: [ + { + name: 'icnt', + description: 'a handle for the counter.', + type: 'initialization' + }, + ], + seeAlso: ['Program Flow Control: Counter'] +}, +{ + name: 'cntReset', + type: 'opcode', + category: 'Instrument Control:Sensing and Control', + description: 'Resets a counter object to its initial state.', + syntax: 'cntReset(icnt)', + parameters: [ + { + name: 'icnt', + description: 'a handle for the counter.', + type: 'initialization' + }, + ], + seeAlso: ['Program Flow Control: Counter'] +}, +{ + name: 'cntState', + type: 'opcode', + category: 'Instrument Control:Sensing and Control', + description: 'Gives the range and increment of a counter.', + syntax: 'kmax, kmin, kinc = cntState(icnt)', + parameters: [ + { + name: 'icnt', + description: 'a handle for the counter.', + type: 'initialization' + }, + ], + seeAlso: ['Program Flow Control: Counter'] +}, +{ + name: 'control', + type: 'opcode', + category: 'Instrument Control:Sensing and Control', + description: 'Configurable slider controls for realtime user input. Requires Winsound or TCL/TK. It reads a slider\'s value.', + syntax: 'kres = control(knum)', + rates: ['k-rate'], + parameters: [ + { + name: 'knum', + description: 'number of the slider to be read.', + type: 'performance' + }, + ], + seeAlso: ['Sensing and Control: TCL/TK widgets'] +}, +{ + name: 'count', + type: 'opcode', + category: 'Instrument Control:Sensing and Control', + description: 'Get the next value from a counter.', + syntax: 'kval = count(icnt)', + example: '--8<-- "examples/counter.csd"', + parameters: [ + { + name: 'icnt', + description: 'the handle of a counter object from a call to _cntCreate_.', + type: 'initialization' + }, + { + name: 'kval', + description: 'returned value.', + type: 'performance' + }, + ], + seeAlso: ['Program Flow Control: Counter'] +}, +{ + name: 'count_i', + type: 'opcode', + category: 'Instrument Control:Sensing and Control', + description: 'Get the next value from a counter.', + syntax: 'ival = count_i(icnt)', + example: '--8<-- "examples/counter.csd"', + parameters: [ + { + name: 'icnt', + description: 'the handle of a counter object from a call to _cntCreate_.', + type: 'initialization' + }, + { + name: 'ival', + description: 'returned value.', + type: 'performance' + }, + ], + seeAlso: ['Program Flow Control: Counter'] +}, +{ + name: 'follow', + type: 'opcode', + category: 'Instrument Control:Sensing and Control', + description: 'Envelope follower unit generator.', + syntax: 'ares = follow(asig, idt)', + example: '--8<-- "examples/follow.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'idt', + description: 'This is the period, in seconds, that the average amplitude of _asig_ is reported. If the frequency of _asig_ is low then _idt_ must be large (more than half the period of _asig_ )', + type: 'initialization' + }, + { + name: 'asig', + description: 'This is the signal from which to extract the envelope.', + type: 'performance' + }, + ], + seeAlso: ['Sensing and Control: Envelope followers'] +}, +{ + name: 'follow2', + type: 'opcode', + category: 'Instrument Control:Sensing and Control', + description: 'Another controllable envelope extractor using the algorithm attributed to Jean-Marc Jot.', + syntax: 'ares = follow2(asig, katt, krel)', + example: '--8<-- "examples/follow2.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'asig', + description: 'the input signal whose envelope is followed', + type: 'performance' + }, + { + name: 'katt', + description: 'the attack rate (60dB attack time in seconds)', + type: 'performance' + }, + { + name: 'krel', + description: 'the decay rate (60dB decay time in seconds)', + type: 'performance' + }, + ], + seeAlso: ['Sensing and Control: Envelope followers'] +}, +{ + name: 'getcfg', + type: 'opcode', + category: 'Instrument Control:Sensing and Control', + description: 'Return various configuration settings in Svalue as a string at init time.', + syntax: 'Svalue = getcfg(iopt)', + example: '--8<-- "examples/getcfg.csd"', + parameters: [ + { + name: 'iopt', + description: 'The parameter to be returned, can be one of:', + type: 'initialization' + }, + ], + seeAlso: ['Sensing and Control: System'] +}, +{ + name: 'joystick', + type: 'opcode', + category: 'Instrument Control:Sensing and Control', + description: 'Reads data from a Linux joystick controller.', + syntax: 'kres = joystick(kdevice, ktab)', + example: '--8<-- "examples/joystick.csd"', + rates: ['k-rate'], + parameters: [ + { + name: 'kdevice', + description: 'the index of the joystick device, either /dev/js_N_ or /dev/input/js_N_.', + type: 'performance' + }, + { + name: 'ktab', + description: 'A table to hold input results, should be at least enough elements to store one value for each stick axis and one for each button + 2. The first two elements of the table are initialized with the number of axes and the number of buttons, respectively, when a joystick is opened. If a joystick is unplugged during performance, the opcode will repeatedly attempt to reopen the device with a delay between attempts.', + type: 'performance' + }, + ], + seeAlso: ['Sensing and Control: Keyboard and mouse sensing', 'non-MIDI devices'] +}, +{ + name: 'metro', + type: 'opcode', + category: 'Instrument Control:Sensing and Control', + description: 'Trigger Metronome.', + syntax: 'ktrig = metro( kfreq [, initphase])', + example: '--8<-- "examples/metro.csd"', + parameters: [ + { + name: 'initphase', + description: 'initial phase value (in the 0 to 1 range)', + type: 'initialization' + }, + { + name: 'ktrig', + description: 'output trigger signal', + type: 'performance' + }, + { + name: 'kfreq', + description: 'frequency of trigger bangs in cps', + type: 'performance' + }, + ], + seeAlso: ['Sensing and Control: Tempo and Sequencing', 'https://flossmanual.csound.com/csound-language/control-structures'] +}, +{ + name: 'metro2', + type: 'opcode', + category: 'Instrument Control:Sensing and Control', + description: 'Trigger Metronome with Swing and Accents.', + syntax: 'ktrig = metro2( kfreq, kswing [, iamp, initphase])', + example: '--8<-- "examples/metro2.csd"', + parameters: [ + { + name: 'iamp', + description: 'off-beat click amplitude', + type: 'initialization' + }, + { + name: 'initphase', + description: 'initial phase value (in the 0 to 1 range)', + type: 'initialization' + }, + { + name: 'ktrig', + description: 'output trigger signal', + type: 'performance' + }, + { + name: 'kfreq', + description: 'frequency of trigger bangs in cps', + type: 'performance' + }, + { + name: 'kswing', + description: 'value (in the 0 to 1 range)', + type: 'performance' + }, + ], + seeAlso: ['Sensing and Control: Tempo and Sequencing'] +}, +{ + name: 'metrobpm', + type: 'opcode', + category: 'Instrument Control:Sensing and Control', + description: 'Trigger Metronome with optional gate.', + syntax: 'ktrig = metrobpm( kfreq [, initphase] [, kgate])', + parameters: [ + { + name: 'initphase', + description: 'initial phase value (in the 0 to 1 range)', + type: 'initialization' + }, + { + name: 'ktrig', + description: 'output trigger signal', + type: 'performance' + }, + { + name: 'kfreq', + description: 'frequency of trigger bangs in beats per minute', + type: 'performance' + }, + { + name: 'kgate', + description: 'proportion of the cycle that the trigger held at one', + type: 'performance' + }, + ], + seeAlso: ['Sensing and Control: Tempo and Sequencing'] +}, +{ + name: 'midifilein', + type: 'opcode', + category: 'Instrument Control:Sensing and Control', + description: 'Returns a generic MIDI message from a MIDI file.', + syntax: 'status:i,chan:i,data1:i,data2:i,time:i = midifilein(index:i,[id:i])\n status:k, chan:k, data1:k, data2:k, time:k = midifilein(index:k,[id:k])', + example: '--8<-- "examples/midifilein.csd"', + seeAlso: ['Sensing and Control: Tempo and Sequencing'] +}, +{ + name: 'midifilelen', + type: 'opcode', + category: 'Instrument Control:Sensing and Control', + description: 'Returns the length of a MIDI file.', + syntax: 'len:i = midifilelen([id:i])', + example: '--8<-- "examples/midifilelen.csd"', + seeAlso: ['Sensing and Control: Tempo and Sequencing'] +}, +{ + name: 'midifilemute', + type: 'opcode', + category: 'Instrument Control:Sensing and Control', + description: 'Toggle-mutes playback of a MIDI file (without pausing playback).', + syntax: 'midifilemute([id:i])', + example: '--8<-- "examples/midifilemute.csd"', + seeAlso: ['Sensing and Control: Tempo and Sequencing'] +}, +{ + name: 'midifileopen', + type: 'opcode', + category: 'Instrument Control:Sensing and Control', + description: 'Open a MIDI file for playback.', + syntax: 'id:i = midfileopen(name:S[,port:i])', + example: '--8<-- "examples/midifileopen.csd"', + parameters: [ + { + name: 'name', + description: 'MIDI file name.', + type: 'initialization' + }, + ], + seeAlso: ['Sensing and Control: Tempo and Sequencing'] +}, +{ + name: 'midifilepause', + type: 'opcode', + category: 'Instrument Control:Sensing and Control', + description: 'Pauses MIDI file playback.', + syntax: 'midifilepause([id:i])', + example: '--8<-- "examples/midifilepause.csd"', + seeAlso: ['Sensing and Control: Tempo and Sequencing'] +}, +{ + name: 'midifileplay', + type: 'opcode', + category: 'Instrument Control:Sensing and Control', + description: 'Starts playback of a MIDI file.', + syntax: 'midifileplay([id:i])', + example: '--8<-- "examples/midifileplay.csd"', + seeAlso: ['Sensing and Control: Tempo and Sequencing'] +}, +{ + name: 'midifilepos', + type: 'opcode', + category: 'Instrument Control:Sensing and Control', + description: 'Gets/Sets the playback position of a MIDI file.', + syntax: 'pos:i = midifilepos([id:i])\n pos:k = midifilepos([id:i])\n midifilepos(pos:i[,id:i])\n midifilepos(pos:k[,id:i])', + example: '--8<-- "examples/midifilepos.csd"', + parameters: [ + { + name: 'pos', + description: 'playback position in seconds', + type: 'initialization' + }, + ], + seeAlso: ['Sensing and Control: Tempo and Sequencing'] +}, +{ + name: 'midifilerewind', + type: 'opcode', + category: 'Instrument Control:Sensing and Control', + description: 'Rewinds playback of a MIDI file.', + syntax: 'midifilerewind([id:i])', + example: '--8<-- "examples/midifilerewind.csd"', + seeAlso: ['Sensing and Control: Tempo and Sequencing'] +}, +{ + name: 'midifiletempo', + type: 'opcode', + category: 'Instrument Control:Sensing and Control', + description: 'Sets the playback tempo of a MIDI file.', + syntax: 'midifiletempo(tempo:i[,id:i])\n midifiletempo(tempo:k[,id:i])', + example: '--8<-- "examples/midifiletempo.csd"', + parameters: [ + { + name: 'tempo', + description: 'if positive, the bpm to set. If negative, the absolute value is used as a tempo scaling parameter (playback speed).', + type: 'initialization' + }, + ], + seeAlso: ['Sensing and Control: Tempo and Sequencing'] +}, +{ + name: 'midifilevents', + type: 'opcode', + category: 'Instrument Control:Sensing and Control', + description: 'Returns the number of events in a MIDI file.', + syntax: 'num:i = midifilevents([id:i])', + example: '--8<-- "examples/midifilevents.csd"', + seeAlso: ['Sensing and Control: Tempo and Sequencing'] +}, +{ + name: 'miditempo', + type: 'opcode', + category: 'Instrument Control:Sensing and Control', + description: 'Returns the current tempo at k-rate, of either the MIDI file (if available) or the score. (provided the -t option is used).', + syntax: 'itempo = miditempo([id:i])\n ktempo = miditempo([id:i])', + example: '--8<-- "examples/miditempo.csd"', + seeAlso: ['Sensing and Control: Tempo and Sequencing'] +}, +{ + name: 'pcount', + type: 'opcode', + category: 'Instrument Control:Sensing and Control', + description: 'Returns the number of pfields belonging to a note event.', + syntax: 'icount = pcount()', + example: '--8<-- "examples/pcount.csd"', + parameters: [ + { + name: 'icount', + description: 'stores the number of pfields for the current note event.', + type: 'initialization' + }, + ], + seeAlso: ['Sensing and Control: Score control'] +}, +{ + name: 'peak', + type: 'opcode', + category: 'Instrument Control:Sensing and Control', + description: 'Maintains the output equal to the highest absolute value received.', + syntax: 'kres = peak(asig)\n kres = peak(ksig)', + example: '--8<-- "examples/peak.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'kres', + description: 'Output equal to the highest absolute value received so far. This is effectively an input to the opcode as well, since it reads _kres_ in order to decide whether to write something higher into it.', + type: 'performance' + }, + { + name: 'ksig', + description: 'k-rate input signal.', + type: 'performance' + }, + { + name: 'asig', + description: 'a-rate input signal.', + type: 'performance' + }, + ], + seeAlso: ['Sensing and Control: Envelope followers'] +}, +{ + name: 'pindex', + type: 'opcode', + category: 'Instrument Control:Sensing and Control', + description: 'Returns the value of a specified pfield.', + syntax: 'ivalue = pindex(ipfieldIndex)', + example: '--8<-- "examples/pindex.csd"', + parameters: [ + { + name: 'ipfieldIndex', + description: 'pfield number to query.', + type: 'initialization' + }, + { + name: 'ivalue', + description: 'value of the pfield.', + type: 'initialization' + }, + ], + seeAlso: ['Sensing and Control: Score control'] +}, +{ + name: 'pitch', + type: 'opcode', + category: 'Instrument Control:Sensing and Control', + description: 'Tracks the pitch of a signal.', + syntax: 'koct, kamp = pitch(asig, iupdte, ilo, ihi, idbthresh [, ifrqs] [, iconf] \\\n [, istrt] [, iocts] [, iq] [, inptls] [, irolloff] [, iskip])', + example: '--8<-- "examples/pitch.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'iupdte', + description: 'length of period, in seconds, that outputs are updated', + type: 'initialization' + }, + { + name: 'ilo', + description: 'range in which pitch is detected, expressed in octave point decimal', + type: 'initialization' + }, + { + name: 'ihi', + description: 'range in which pitch is detected, expressed in octave point decimal', + type: 'initialization' + }, + { + name: 'idbthresh', + description: 'amplitude, expressed in decibels, necessary for the pitch to be detected. Once started it continues until it is 6 dB down.', + type: 'initialization' + }, + { + name: 'koct', + description: 'The pitch output, given in the octave point decimal format.', + type: 'performance' + }, + { + name: 'kamp', + description: 'The amplitude output.', + type: 'performance' + }, + ], + seeAlso: ['Sensing and Control: Tempo and Pitch estimation'] +}, +{ + name: 'pitchamdf', + type: 'opcode', + category: 'Instrument Control:Sensing and Control', + description: 'Follows the pitch of a signal based on the AMDF method (Average Magnitude Difference Function).', + syntax: 'kcps, krms = pitchamdf(asig, imincps, imaxcps [, icps] [, imedi] \\\n [, idowns] [, iexcps] [, irmsmedi])', + example: '--8<-- "examples/pitchamdf.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'imincps', + description: 'estimated minimum frequency (expressed in Hz) present in the signal', + type: 'initialization' + }, + { + name: 'imaxcps', + description: 'estimated maximum frequency present in the signal', + type: 'initialization' + }, + { + name: 'kcps', + description: 'pitch tracking output', + type: 'performance' + }, + { + name: 'krms', + description: 'amplitude tracking output', + type: 'performance' + }, + ], + seeAlso: ['Sensing and Control: Tempo and Pitch estimation'] +}, +{ + name: 'plltrack', + type: 'opcode', + category: 'Instrument Control:Sensing and Control', + description: 'Tracks the pitch of a signal.', + syntax: 'acps, alock = plltrack(asig, kd [, kloopf, kloopq, klf, khf, kthresh])', + example: '--8<-- "examples/plltrack.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'acps', + description: 'estimated pitch in Hz.', + type: 'performance' + }, + { + name: 'alock', + description: 'phase lock indicator, a phase error indicating the quality of the tracking, with values between 0 and 1. Higher values indicate good tracking', + type: 'performance' + }, + { + name: 'kd', + description: 'PLL feedback gain, controls frequency range of PLL (between 0 and 1). Higher values increase the range of the tracking.', + type: 'performance' + }, + { + name: 'kloopf', + description: 'PLL LP filter cf, controls frequency range of PLL (opt, defaults to 20Hz).', + type: 'performance' + }, + { + name: 'kloopq', + description: 'PLL LP filter Q, controls rise time of FO step (opt, defaults to 1/3)', + type: 'performance' + }, + { + name: 'klf', + description: 'lowest tracking freq (opt, defaults to 20Hz)', + type: 'performance' + }, + { + name: 'khf', + description: 'highest tracking freq (opt, defaults to 1500Hz)', + type: 'performance' + }, + { + name: 'kthresh', + description: 'tracking signal level threshold (optional, defaults to 0.001, equiv to -60dBfs)', + type: 'performance' + }, + ], + seeAlso: ['Sensing and Control: Tempo and Pitch estimation'] +}, +{ + name: 'ptrack', + type: 'opcode', + category: 'Instrument Control:Sensing and Control', + description: 'Tracks the pitch of a signal.', + syntax: 'kcps, kamp = ptrack(asig, ihopsize[,ipeaks])', + example: '--8<-- "examples/ptrack.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'ihopsize', + description: 'size of the analysis \'hop\', in samples, required to be power-of-two (min 64, max 4096). This is the period between measurements.', + type: 'initialization' + }, + { + name: 'ipeaks', + description: 'number of spectral peaks to use in the analysis, defaults to 20 (optional)', + type: 'initialization' + }, + { + name: 'ihi', + description: 'number of spectral peaks to use in the analysis, defaults to 20 (optional)', + type: 'initialization' + }, + { + name: 'kcps', + description: 'estimated pitch in Hz.', + type: 'performance' + }, + { + name: 'kamp', + description: 'estimated amplitude in dB relative to full-scale (0dB) (ie. always <= 0).', + type: 'performance' + }, + ], + seeAlso: ['Sensing and Control: Tempo and Pitch estimation'] +}, +{ + name: 'readscratch', + type: 'opcode', + category: 'Instrument Control:Sensing and Control', + description: 'Returns one of four scalar values stored in the instance of an instrument.', + syntax: 'ival = readscratch([index])', + example: '--8<-- "examples/readscratch.csd"', + seeAlso: ['writescratch', 'Miscellaneous opcodes'] +}, +{ + name: 'rewindscore', + type: 'opcode', + category: 'Instrument Control:Sensing and Control', + description: 'Rewinds the playback position of the current score performance.', + syntax: 'rewindscore()', + example: '--8<-- "examples/rewindscore.csd"', + seeAlso: ['Sensing and Control: Score control'] +}, +{ + name: 'rms', + type: 'opcode', + category: 'Instrument Control:Sensing and Control', + description: 'Determines the root-mean-square amplitude of an audio signal.', + syntax: 'kres = rms(asig [, ihp] [, iskip])', + example: '--8<-- "examples/rms.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'asig', + description: 'input audio signal', + type: 'performance' + }, + { + name: 'kres', + description: 'low-pass filtered rms value of the input signal', + type: 'performance' + }, + ], + seeAlso: ['Sensing and Control: Envelope followers'] +}, +{ + name: 'sense', + type: 'opcode', + category: 'Instrument Control:Sensing and Control', + description: 'Same as the [sensekey](../opcodes/sensekey.md) opcode.', +}, +{ + name: 'sensekey', + type: 'opcode', + category: 'Instrument Control:Sensing and Control', + description: 'Returns the ASCII code of a key that has been pressed, or -1 if no key has been pressed.', + syntax: 'kres [, kkeydown] = sensekey()', + example: '--8<-- "examples/sensekey.csd"', + rates: ['k-rate'], + parameters: [ + { + name: 'kres', + description: 'returns the ASCII value of a key which is pressed or released.', + type: 'performance' + }, + { + name: 'kkeydown', + description: 'returns 1 if the key was pressed, 0 if it was released or if there is no key event.', + type: 'performance' + }, + ], + seeAlso: ['Sensing and Control: Keyboard and mouse sensing'] +}, +{ + name: 'seqtime', + type: 'opcode', + category: 'Instrument Control:Sensing and Control', + description: 'Generates a trigger signal according to the values stored in a table.', + syntax: 'ktrig_out = seqtime(ktime_unit, kstart, kloop, kinitndx, kfn_times)', + example: '--8<-- "examples/seqtime.csd"', + parameters: [ + { + name: 'ktrig_out', + description: 'output trigger signal', + type: 'performance' + }, + { + name: 'ktime_unit', + description: 'unit of measure of time, related to seconds.', + type: 'performance' + }, + { + name: 'kstart', + description: 'start index of looped section', + type: 'performance' + }, + { + name: 'kloop', + description: 'end index of looped section', + type: 'performance' + }, + { + name: 'kinitndx', + description: 'initial index', + type: 'performance' + }, + { + name: 'kfn_times', + description: 'number of table containing a sequence of times', + type: 'performance' + }, + ], + seeAlso: ['Sensing and Control: Tempo and Sequencing'] +}, +{ + name: 'seqtime2', + type: 'opcode', + category: 'Instrument Control:Sensing and Control', + description: 'Generates a trigger signal according to the values stored in a table.', + syntax: 'ktrig_out = seqtime2(ktrig_in, ktime_unit, kstart, kloop, kinitndx, kfn_times)', + example: '--8<-- "examples/seqtime2.csd"', + parameters: [ + { + name: 'ktrig_out', + description: 'output trigger signal', + type: 'performance' + }, + { + name: 'ktime_unit', + description: 'unit of measure of time, related to seconds.', + type: 'performance' + }, + { + name: 'ktrig_in', + description: 'input trigger signal.', + type: 'performance' + }, + { + name: 'kstart', + description: 'start index of looped section', + type: 'performance' + }, + { + name: 'kloop', + description: 'end index of looped section', + type: 'performance' + }, + { + name: 'kinitndx', + description: 'initial index', + type: 'performance' + }, + { + name: 'kfn_times', + description: 'number of table containing a sequence of times', + type: 'performance' + }, + ], + seeAlso: ['Sensing and Control: Tempo and Sequencing'] +}, +{ + name: 'sequ', + type: 'opcode', + category: 'Instrument Control:Sensing and Control', + description: 'Emulate a hardware sequencer.', + syntax: 'kres = sequ(irhythm[], iinstr[], idata[], kbpm, klen [, kmode] [, kstep] \\\n [, kreset] [, kverbose])\n kres = sequ(irhythm[], iinstr[], idata[][], kbpm, klen [, kmode] [, kstep] \\\n [, kreset] [, kverbose])', + example: '--8<-- "examples/sequ1.csd"', + rates: ['k-rate'], + parameters: [ + { + name: 'irhythm', + description: 'array of durations in beats. The actual duration is determined by these values divided by the current BPM.', + type: 'initialization' + }, + { + name: 'iinstr', + description: 'array of instrument numbers scheduled per step. An instrument number zero does nothing. It skips the note associated with the step and produces a silence for that note\'s duration.', + type: 'initialization' + }, + { + name: 'idata', + description: 'Either a vector of p4 values to the associated iinstr step or a two dimensional array of p4, p5, p6...values. Typically, one would specify pitch information in cps, or MIDI note number; but the arbitrary list of p4 data values could have other uses in the called iinstr.', + type: 'initialization' + }, + { + name: 'kbpm', + description: 'speed of looping in beats per minute.', + type: 'performance' + }, + { + name: 'klen', + description: 'length of the active part of the sequence (starting from step 0).', + type: 'performance' + }, + { + name: 'kmode', + description: 'control the sequencer playback. A value of 0 (default) loops forward through the sequence, calling the associated instrument on each step. Other modes are supported. (See below).', + type: 'performance' + }, + { + name: 'kstep', + description: 'if non zero replace the irhythm array with k-rate triggers. These could be from a MIDI keyboard or any other krate controller. An event is scheduled if this argument is positive, and just waits if it is negative. Default is zero.', + type: 'performance' + }, + { + name: 'kreset', + description: 'if non zero resets the sequencer (like mode -7). Default is zero.', + type: 'performance' + }, + { + name: 'kverbose', + description: 'if non zero prints messages about the internal state changes. Default is zero.', + type: 'performance' + }, + { + name: 'kres', + description: 'gives the index of the event created for the current k-cycle, or -1 if no event happened.', + type: 'performance' + }, + ], + seeAlso: ['Sensing and Control: Tempo and Sequencing'] +}, +{ + name: 'setctrl', + type: 'opcode', + category: 'Instrument Control:Sensing and Control', + description: 'Configurable slider controls for realtime user input.', + syntax: 'setctrl(inum, ival, itype)', + example: '--8<-- "examples/setctrl.csd"', + parameters: [ + { + name: 'inum', + description: 'number of the slider to set', + type: 'initialization' + }, + { + name: 'ival', + description: 'value to be sent to the slider', + type: 'initialization' + }, + { + name: 'itype', + description: 'type of value sent to the slider as follows:', + type: 'initialization' + }, + ], + seeAlso: ['Sensing and Control: TCL/TK widgets'] +}, +{ + name: 'setscorepos', + type: 'opcode', + category: 'Instrument Control:Sensing and Control', + description: 'Sets the playback position of the current score performance to a given position.', + syntax: 'setscorepos(ipos)', + example: '--8<-- "examples/setscorepos.csd"', + parameters: [ + { + name: 'ipos', + description: 'playback position in seconds.', + type: 'initialization' + }, + ], + seeAlso: ['Sensing and Control: Score control'] +}, +{ + name: 'splitrig', + type: 'opcode', + category: 'Instrument Control:Sensing and Control', + description: 'Split a trigger signal (i.e. a timed sequence of control-rate impulses) into several channels following a structure designed by the user.', + syntax: 'splitrig(ktrig, kndx, imaxtics, ifn, kout1 [,kout2,...,koutN])', + example: '--8<-- "examples/splitrig.csd"', + rates: ['i-rate'], + parameters: [ + { + name: 'imaxtics', + description: 'number of tics belonging to largest pattern', + type: 'initialization' + }, + { + name: 'ifn', + description: 'number of table containing channel-data structuring', + type: 'initialization' + }, + { + name: 'asig', + description: 'incoming (input) signal', + type: 'performance' + }, + { + name: 'ktrig', + description: 'trigger signal', + type: 'performance' + }, + ], + seeAlso: ['Sensing and Control: Tempo and Sequencing'] +}, +] diff --git a/src/lib/csound-reference/instrument-control-stacks.ts b/src/lib/csound-reference/instrument-control-stacks.ts new file mode 100644 index 0000000..dd6c453 --- /dev/null +++ b/src/lib/csound-reference/instrument-control-stacks.ts @@ -0,0 +1,69 @@ +import type { CsoundReference } from './types' + +// Instrument Control:Stacks +export const instrumentControlStacks: CsoundReference[] = [ +{ + name: 'pop', + type: 'opcode', + category: 'Instrument Control:Stacks', + description: 'Pops values from the global stack. Deprecated.', + syntax: 'xval1, [xval2, ... , xval31] = pop()\n ival1, [ival2, ... , ival31] = pop()', + example: '--8<-- "examples/pop.csd"', + seeAlso: ['Stacks', 'http://csound.1045644.n5.nabble.com/passing-a-string-to-a-UDO-td1099284.html'] +}, +{ + name: 'pop_f', + type: 'opcode', + category: 'Instrument Control:Stacks', + description: 'Pops an f-sig frame from the global stack. Deprecated.', + syntax: 'fsig = pop_f()', + parameters: [ + { + name: 'fsig', + description: 'f-signal to be popped from the stack.', + type: 'performance' + }, + ], + seeAlso: ['Stacks'] +}, +{ + name: 'push', + type: 'opcode', + category: 'Instrument Control:Stacks', + description: 'Pushes a value into the global stack. Deprecated.', + syntax: 'push(xval1, [xval2, ... , xval31])\n push(ival1, [ival2, ... , ival31])', + example: '--8<-- "examples/push.csd"', + seeAlso: ['Stacks', 'http://csound.1045644.n5.nabble.com/passing-a-string-to-a-UDO-td1099284.html'] +}, +{ + name: 'push_f', + type: 'opcode', + category: 'Instrument Control:Stacks', + description: 'Pushes an f-sig frame into the global stack. Deprecated.', + syntax: 'push_f(fsig)', + parameters: [ + { + name: 'fsig', + description: 'f-signal to be pushed into the stack.', + type: 'performance' + }, + ], + seeAlso: ['Stacks'] +}, +{ + name: 'stack', + type: 'opcode', + category: 'Instrument Control:Stacks', + description: 'Initializes and sets the size of the global stack. Deprecated.', + syntax: 'stack(iStackSize)', + example: '--8<-- "examples/stack.csd"', + parameters: [ + { + name: 'iStackSize', + description: 'size of the stack in bytes.', + type: 'initialization' + }, + ], + seeAlso: ['Stacks', 'http://csound.1045644.n5.nabble.com/passing-a-string-to-a-UDO-td1099284.html'] +}, +] diff --git a/src/lib/csound-reference/instrument-control-time-reading.ts b/src/lib/csound-reference/instrument-control-time-reading.ts new file mode 100644 index 0000000..9743b26 --- /dev/null +++ b/src/lib/csound-reference/instrument-control-time-reading.ts @@ -0,0 +1,102 @@ +import type { CsoundReference } from './types' + +// Instrument Control:Time Reading +export const instrumentControlTimeReading: CsoundReference[] = [ +{ + name: 'date', + type: 'opcode', + category: 'Instrument Control:Time Reading', + description: 'Returns the number seconds since a base date, using the operating system\'s clock.', + syntax: 'ir[, inano] = date()\n kr[, knano] = date()', + example: '--8<-- "examples/date.csd"', + seeAlso: ['Time Reading'] +}, +{ + name: 'dates', + type: 'opcode', + category: 'Instrument Control:Time Reading', + description: 'Returns as a string the date and time specified.', + syntax: 'Sir = dates([ itime])', + example: '--8<-- "examples/dates.csd"', + parameters: [ + { + name: 'itime', + description: 'the time is seconds since the start of the epoch. If omited or negative the current time is taken.', + type: 'initialization' + }, + { + name: 'Sir', + description: 'the date and time as a string.', + type: 'initialization' + }, + ], + seeAlso: ['Time Reading'] +}, +{ + name: 'elapsedcycles', + type: 'opcode', + category: 'Instrument Control:Time Reading', + description: 'Read absolute time, in k-rate cycles, since the start of the performance.', + syntax: 'ires = elapsedcycles()\n kres = elapsedcycles()', + rates: ['k-rate', 'i-rate'], + seeAlso: ['Time Reading'] +}, +{ + name: 'elapsedtime', + type: 'opcode', + category: 'Instrument Control:Time Reading', + description: 'Read absolute time, in seconds, since the start of the performance.', + syntax: 'ires = elapsedtime()\n kres = elapsedtime()', + rates: ['k-rate', 'i-rate'], + seeAlso: ['Time Reading'] +}, +{ + name: 'eventcycles', + type: 'opcode', + category: 'Instrument Control:Time Reading', + description: 'Read absolute time in k-rate cycles, since the start of an instance of an instrument.', + syntax: 'kres = eventcycles()', + rates: ['k-rate'], + seeAlso: ['Time Reading'] +}, +{ + name: 'eventtime', + type: 'opcode', + category: 'Instrument Control:Time Reading', + description: 'Read absolute time, in seconds, since the start of an instance of an instrument.', + syntax: 'kres = eventtime()', + rates: ['k-rate'], + seeAlso: ['Time Reading'] +}, +{ + name: 'readclock', + type: 'opcode', + category: 'Instrument Control:Time Reading', + description: 'Reads the value of an internal clock.', + syntax: 'ir = readclock(inum)', + example: '--8<-- "examples/readclock.csd"', + parameters: [ + { + name: 'inum', + description: 'the number of a clock. There are 32 clocks numbered 0 through 31. All other values are mapped to clock number 32.', + type: 'initialization' + }, + { + name: 'ir', + description: 'value at i-time, of the clock specified by _inum_', + type: 'initialization' + }, + ], + seeAlso: ['Time Reading'] +}, +{ + name: 'rtclock', + type: 'opcode', + category: 'Instrument Control:Time Reading', + description: 'Read the real time clock from the operating system.', + syntax: 'ires = rtclock()\n kres = rtclock()', + example: '--8<-- "examples/rtclock.csd"', + rates: ['k-rate', 'i-rate'], + seeAlso: ['Time Reading'] +}, +] diff --git a/src/lib/csound-reference/mathematical-operations-amplitude-functions.ts b/src/lib/csound-reference/mathematical-operations-amplitude-functions.ts new file mode 100644 index 0000000..c63761d --- /dev/null +++ b/src/lib/csound-reference/mathematical-operations-amplitude-functions.ts @@ -0,0 +1,52 @@ +import type { CsoundReference } from './types' + +// Mathematical Operations:Amplitude Functions +export const mathematicalOperationsAmplitudeFunctions: CsoundReference[] = [ +{ + name: 'ampdb', + type: 'opcode', + category: 'Mathematical Operations:Amplitude Functions', + description: 'Returns the amplitude equivalent of the decibel value x. Thus:', + example: '--8<-- "examples/ampdb-modern.csd"', + seeAlso: ['Amplitude Converters'] +}, +{ + name: 'ampdbfs', + type: 'opcode', + category: 'Mathematical Operations:Amplitude Functions', + description: 'Returns the amplitude equivalent (in 16-bit signed integer scale) of the full scale decibel (dB FS) value _x_.', + example: '--8<-- "examples/ampdbfs-modern.csd"', + seeAlso: ['Amplitude Converters'] +}, +{ + name: 'db', + type: 'opcode', + category: 'Mathematical Operations:Amplitude Functions', + description: 'Returns the amplitude equivalent for a given decibel amount.', + example: '--8<-- "examples/db.csd"', + parameters: [ + { + name: 'x', + description: 'a value expressed in decibels.', + type: 'initialization' + }, + ], + seeAlso: ['Amplitude Converters'] +}, +{ + name: 'dbamp', + type: 'opcode', + category: 'Mathematical Operations:Amplitude Functions', + description: 'Returns the decibel equivalent of the raw amplitude _x_.', + example: '--8<-- "examples/dbamp.csd"', + seeAlso: ['Amplitude Converters'] +}, +{ + name: 'dbfsamp', + type: 'opcode', + category: 'Mathematical Operations:Amplitude Functions', + description: 'Returns the decibel equivalent of the raw amplitude _x_, relative to full scale amplitude.', + example: '--8<-- "examples/dbfsamp.csd"', + seeAlso: ['Amplitude Converters'] +}, +] diff --git a/src/lib/csound-reference/mathematical-operations-arithmetic-and-logic-operations.ts b/src/lib/csound-reference/mathematical-operations-arithmetic-and-logic-operations.ts new file mode 100644 index 0000000..4e912ad --- /dev/null +++ b/src/lib/csound-reference/mathematical-operations-arithmetic-and-logic-operations.ts @@ -0,0 +1,116 @@ +import type { CsoundReference } from './types' + +// Mathematical Operations:Arithmetic and Logic Operations +export const mathematicalOperationsArithmeticAndLogicOperations: CsoundReference[] = [ +{ + name: 'adds', + type: 'opcode', + category: 'Mathematical Operations:Arithmetic and Logic Operations', + description: 'Addition operator.', + example: '--8<-- "examples/adds-modern.csd"', + seeAlso: ['Arithmetic and Logic Operations'] +}, +{ + name: 'divides', + type: 'opcode', + category: 'Mathematical Operations:Arithmetic and Logic Operations', + description: 'Division operator.', + example: '--8<-- "examples/divides.csd"', + seeAlso: ['Arithmetic and Logic Operations'] +}, +{ + name: 'modulus', + type: 'opcode', + category: 'Mathematical Operations:Arithmetic and Logic Operations', + description: 'Modulus operator.', + example: '--8<-- "examples/modulus.csd"', + seeAlso: ['Arithmetic and Logic Operations'] +}, +{ + name: 'multiplies', + type: 'opcode', + category: 'Mathematical Operations:Arithmetic and Logic Operations', + description: 'Multiplication operator.', + example: '--8<-- "examples/multiplies.csd"', + seeAlso: ['Arithmetic and Logic Operations'] +}, +{ + name: 'opand', + type: 'opcode', + category: 'Mathematical Operations:Arithmetic and Logic Operations', + description: 'Logical AND operator.', + example: '--8<-- "examples/opand.csd"', + seeAlso: ['Arithmetic and Logic Operations'] +}, +{ + name: 'opbitand', + type: 'opcode', + category: 'Mathematical Operations:Arithmetic and Logic Operations', + description: 'Bitwise AND operator.', + example: '--8<-- "examples/bitwise-modern.csd"', + seeAlso: ['Arithmetic and Logic Operations'] +}, +{ + name: 'opbitnot', + type: 'opcode', + category: 'Mathematical Operations:Arithmetic and Logic Operations', + description: 'Bitwise NOT operator.', + example: '--8<-- "examples/bitwise-group-modern.csd"', + seeAlso: ['Arithmetic and Logic Operations'] +}, +{ + name: 'opbitor', + type: 'opcode', + category: 'Mathematical Operations:Arithmetic and Logic Operations', + description: 'Bitwise OR operator.', + example: '--8<-- "examples/bitwise-modern.csd"', + seeAlso: ['Arithmetic and Logic Operations'] +}, +{ + name: 'opbitshl', + type: 'opcode', + category: 'Mathematical Operations:Arithmetic and Logic Operations', + description: 'Bitshift left operator.', + example: '--8<-- "examples/bitshift-modern.csd"', + seeAlso: ['Arithmetic and Logic Operations'] +}, +{ + name: 'opbitshr', + type: 'opcode', + category: 'Mathematical Operations:Arithmetic and Logic Operations', + description: 'Bitshift right operator.', + seeAlso: ['Arithmetic and Logic Operations'] +}, +{ + name: 'opnonequiv', + type: 'opcode', + category: 'Mathematical Operations:Arithmetic and Logic Operations', + description: 'Bitwise NON EQUIVALENCE operator.', + example: '--8<-- "examples/bitwise-group-modern.csd"', + seeAlso: ['Arithmetic and Logic Operations'] +}, +{ + name: 'opnot', + type: 'opcode', + category: 'Mathematical Operations:Arithmetic and Logic Operations', + description: 'Logical NOT operator.', + example: '--8<-- "examples/opnot.csd"', + seeAlso: ['Arithmetic and Logic Operations'] +}, +{ + name: 'opor', + type: 'opcode', + category: 'Mathematical Operations:Arithmetic and Logic Operations', + description: 'Logical OR operator.', + example: '--8<-- "examples/logicOR.csd"', + seeAlso: ['Arithmetic and Logic Operations'] +}, +{ + name: 'raises', + type: 'opcode', + category: 'Mathematical Operations:Arithmetic and Logic Operations', + description: '“Power of” operator.', + example: '--8<-- "examples/raises.csd"', + seeAlso: ['Arithmetic and Logic Operations'] +}, +] diff --git a/src/lib/csound-reference/mathematical-operations-arrays.ts b/src/lib/csound-reference/mathematical-operations-arrays.ts new file mode 100644 index 0000000..8d9e7d0 --- /dev/null +++ b/src/lib/csound-reference/mathematical-operations-arrays.ts @@ -0,0 +1,65 @@ +import type { CsoundReference } from './types' + +// Mathematical Operations:Arrays +export const mathematicalOperationsArrays: CsoundReference[] = [ +{ + name: 'cbrt', + type: 'opcode', + category: 'Mathematical Operations:Arrays', + description: 'Cubic root function.', + syntax: 'ires[] = cbrt(iarg)\n kres[] = cbrt(karg)', + example: '--8<-- "examples/cbrt-modern.csd"', + rates: ['k-rate', 'i-rate'], + seeAlso: ['Array opcodes'] +}, +{ + name: 'fmax', + type: 'opcode', + category: 'Mathematical Operations:Arrays', + description: 'Returns the maximum of its two arguments.', + syntax: 'ires[] = fmax(iarg1[], iarg2[])\n kres[] = fmax(karg1[], karg2[])\n ires[] = fmax(iarg1[], iarg2)\n kres[] = fmax(karg[], karg2)', + example: '--8<-- "examples/fmax.csd"', + rates: ['k-rate', 'i-rate'], + seeAlso: ['Array opcodes'] +}, +{ + name: 'fmin', + type: 'opcode', + category: 'Mathematical Operations:Arrays', + description: 'Returns the minimum of its two arguments.', + syntax: 'ires[] = fmin(iarg1[], iarg2[])\n kres[] = fmin(karg1[], karg2[])\n ires[] = fmin(iarg1[], iarg2)\n kres[] = fmin(karg[], karg2)', + example: '--8<-- "examples/fmin.csd"', + rates: ['k-rate', 'i-rate'], + seeAlso: ['Array opcodes'] +}, +{ + name: 'fmod', + type: 'opcode', + category: 'Mathematical Operations:Arrays', + description: 'Computes the remainder of the division of its first argument by the second.', + syntax: 'ires[] = fmod(iarg1[], iarg2[])\n kres[] = fmod(karg1[], karg2[])\n ires[] = fmod(iarg1[], iarg2)\n kres[] = fmod(karg[], karg2)', + example: '--8<-- "examples/fmod.csd"', + rates: ['k-rate', 'i-rate'], + seeAlso: ['Array opcodes'] +}, +{ + name: 'hypot', + type: 'opcode', + category: 'Mathematical Operations:Arrays', + description: 'Euclidean distance function.', + syntax: 'ires[] = hypot(iarg1[], iarg2[])\n kres[] = hypot(karg1[], karg2[])', + example: '--8<-- "examples/hypot.csd"', + rates: ['k-rate', 'i-rate'], + seeAlso: ['Array opcodes'] +}, +{ + name: 'limit1', + type: 'opcode', + category: 'Mathematical Operations:Arrays', + description: 'Limits the value of an argument to the range [0,1].', + syntax: 'ires[] = limit1(iarg)\n kres[] = limit1(karg)', + example: '--8<-- "examples/limit1.csd"', + rates: ['k-rate', 'i-rate'], + seeAlso: ['Array opcodes'] +}, +] diff --git a/src/lib/csound-reference/mathematical-operations-comparators-and-accumulators.ts b/src/lib/csound-reference/mathematical-operations-comparators-and-accumulators.ts new file mode 100644 index 0000000..323a2d8 --- /dev/null +++ b/src/lib/csound-reference/mathematical-operations-comparators-and-accumulators.ts @@ -0,0 +1,14 @@ +import type { CsoundReference } from './types' + +// Mathematical Operations:Comparators and Accumulators +export const mathematicalOperationsComparatorsAndAccumulators: CsoundReference[] = [ +{ + name: 'clear', + type: 'opcode', + category: 'Mathematical Operations:Comparators and Accumulators', + description: 'Zeroes a list of audio signals.', + syntax: 'clear(avar1 [, avar2] [, avar3] [...])\n clear(avar[])', + example: '--8<-- "examples/clear-modern.csd"', + seeAlso: ['File Input and Output', 'Comparators and Accumulators'] +}, +] diff --git a/src/lib/csound-reference/mathematical-operations-mathematical-functions.ts b/src/lib/csound-reference/mathematical-operations-mathematical-functions.ts new file mode 100644 index 0000000..e84735f --- /dev/null +++ b/src/lib/csound-reference/mathematical-operations-mathematical-functions.ts @@ -0,0 +1,167 @@ +import type { CsoundReference } from './types' + +// Mathematical Operations:Mathematical Functions +export const mathematicalOperationsMathematicalFunctions: CsoundReference[] = [ +{ + name: 'abs', + type: 'opcode', + category: 'Mathematical Operations:Mathematical Functions', + description: 'Returns the absolute value of its input.', + example: '--8<-- "examples/abs-modern.csd"', + seeAlso: ['Mathematical Functions'] +}, +{ + name: 'arg', + type: 'opcode', + category: 'Mathematical Operations:Mathematical Functions', + description: 'Returns the argument of a complex number.', + seeAlso: ['Mathematical Functions'] +}, +{ + name: 'ceil', + type: 'opcode', + category: 'Mathematical Operations:Mathematical Functions', + description: 'Returns the smallest integer not less than *x*.', + example: '--8<-- "examples/ceil-modern.csd"', + seeAlso: ['Mathematical Functions'] +}, +{ + name: 'complex', + type: 'opcode', + category: 'Mathematical Operations:Mathematical Functions', + description: 'Returns a complex number, optionally in polar form.', + seeAlso: ['Mathematical Functions'] +}, +{ + name: 'conj', + type: 'opcode', + category: 'Mathematical Operations:Mathematical Functions', + description: 'Returns the conjugate of a complex number.', + seeAlso: ['Mathematical Functions'] +}, +{ + name: 'exp', + type: 'opcode', + category: 'Mathematical Operations:Mathematical Functions', + description: 'Returns e raised to the xth power.', + example: '--8<-- "examples/exp.csd"', + seeAlso: ['Mathematical Functions'] +}, +{ + name: 'floor', + type: 'opcode', + category: 'Mathematical Operations:Mathematical Functions', + description: 'Returns the largest integer not greater than *x*.', + example: '--8<-- "examples/floor.csd"', + seeAlso: ['Mathematical Functions'] +}, +{ + name: 'frac', + type: 'opcode', + category: 'Mathematical Operations:Mathematical Functions', + description: 'Returns the fractional part of a decimal number.', + example: '--8<-- "examples/frac.csd"', + seeAlso: ['Mathematical Functions'] +}, +{ + name: 'imag', + type: 'opcode', + category: 'Mathematical Operations:Mathematical Functions', + description: 'Returns the imaginary part of a complex number.', + seeAlso: ['Mathematical Functions'] +}, +{ + name: 'int', + type: 'opcode', + category: 'Mathematical Operations:Mathematical Functions', + description: 'Extracts an integer from a decimal number.', + example: '--8<-- "examples/int.csd"', + seeAlso: ['Mathematical Functions'] +}, +{ + name: 'log', + type: 'opcode', + category: 'Mathematical Operations:Mathematical Functions', + description: 'Returns the natural log of _x_ (_x_ positive only).', + example: '--8<-- "examples/log.csd"', + seeAlso: ['Mathematical Functions'] +}, +{ + name: 'log10', + type: 'opcode', + category: 'Mathematical Operations:Mathematical Functions', + description: 'Returns the base 10 log of _x_ (_x_ positive only).', + example: '--8<-- "examples/log10.csd"', + seeAlso: ['Mathematical Functions'] +}, +{ + name: 'log2', + type: 'opcode', + category: 'Mathematical Operations:Mathematical Functions', + description: 'Returns the base 2 log of _x_ (_x_ positive only).', + example: '--8<-- "examples/log2.csd"', + seeAlso: ['Mathematical Functions'] +}, +{ + name: 'logbtwo', + type: 'opcode', + category: 'Mathematical Operations:Mathematical Functions', + description: 'Performs a logarithmic base two calculation.', + example: '--8<-- "examples/logbtwo.csd"', + seeAlso: ['Mathematical Functions'] +}, +{ + name: 'polar', + type: 'opcode', + category: 'Mathematical Operations:Mathematical Functions', + description: 'Returns a complex number in polar format.', + seeAlso: ['Mathematical Functions'] +}, +{ + name: 'powoftwo', + type: 'opcode', + category: 'Mathematical Operations:Mathematical Functions', + description: 'Performs a power-of-two calculation.', + example: '--8<-- "examples/powoftwo.csd"', + seeAlso: ['Mathematical Functions'] +}, +{ + name: 'qinf', + type: 'opcode', + category: 'Mathematical Operations:Mathematical Functions', + description: 'Returns the number of times the argument is not a number, with the sign of the first infinity.', + example: '--8<-- "examples/qinf.csd"', + seeAlso: ['Mathematical Functions'] +}, +{ + name: 'qnan', + type: 'opcode', + category: 'Mathematical Operations:Mathematical Functions', + description: 'Returns the number of times the argument is not a number.', + example: '--8<-- "examples/qnan.csd"', + seeAlso: ['Mathematical Functions'] +}, +{ + name: 'real', + type: 'opcode', + category: 'Mathematical Operations:Mathematical Functions', + description: 'Returns the real part of a complex number.', + seeAlso: ['Mathematical Functions'] +}, +{ + name: 'round', + type: 'opcode', + category: 'Mathematical Operations:Mathematical Functions', + description: 'Returns the integer value nearest to _x_.', + example: '--8<-- "examples/round.csd"', + seeAlso: ['Mathematical Functions'] +}, +{ + name: 'sqrt', + type: 'opcode', + category: 'Mathematical Operations:Mathematical Functions', + description: 'Returns the square root of _x_ (_x_ non-negative).', + example: '--8<-- "examples/sqrt.csd"', + seeAlso: ['Mathematical Functions'] +}, +] diff --git a/src/lib/csound-reference/mathematical-operations-opcode-equivalents-of-functions.ts b/src/lib/csound-reference/mathematical-operations-opcode-equivalents-of-functions.ts new file mode 100644 index 0000000..8e507bb --- /dev/null +++ b/src/lib/csound-reference/mathematical-operations-opcode-equivalents-of-functions.ts @@ -0,0 +1,101 @@ +import type { CsoundReference } from './types' + +// Mathematical Operations:Opcode Equivalents of Functions +export const mathematicalOperationsOpcodeEquivalentsOfFunctions: CsoundReference[] = [ +{ + name: 'divz', + type: 'opcode', + category: 'Mathematical Operations:Opcode Equivalents of Functions', + description: 'Safely divides two numbers.', + example: '--8<-- "examples/divz.csd"', + seeAlso: ['Opcode Equivalents of Functions'] +}, +{ + name: 'mac', + type: 'opcode', + category: 'Mathematical Operations:Opcode Equivalents of Functions', + description: 'Multiplies and accumulates a- and k-rate signals.', + syntax: 'ares = mac(ksig1, asig1 [, ksig2] [, asig2] [, ksig3] [, asig3] [...])', + example: '--8<-- "examples/mac.csd"', + rates: ['a-rate'], + seeAlso: ['Opcode Equivalents of Functions'] +}, +{ + name: 'maca', + type: 'opcode', + category: 'Mathematical Operations:Opcode Equivalents of Functions', + description: 'Multiply and accumulate a-rate signals only.', + syntax: 'ares = maca(asig1 , asig2 [, asig3] [, asig4] [, asig5] [...])', + example: '--8<-- "examples/maca.csd"', + rates: ['a-rate'], + seeAlso: ['Opcode Equivalents of Functions'] +}, +{ + name: 'polynomial', + type: 'opcode', + category: 'Mathematical Operations:Opcode Equivalents of Functions', + description: 'Efficiently evaluates a polynomial of arbitrary order.', + syntax: 'aout = polynomial(ain, k0 [, k1 [, k2 [...]]])', + example: '--8<-- "examples/polynomial.csd"', + parameters: [ + { + name: 'ain', + description: 'the input signal used as the independent variable of the polynomial ("x").', + type: 'performance' + }, + { + name: 'aout', + description: 'the output signal ("y").', + type: 'performance' + }, + ], + seeAlso: ['Waveshaping', 'Opcode Equivalents of Functions'] +}, +{ + name: 'pow', + type: 'opcode', + category: 'Mathematical Operations:Opcode Equivalents of Functions', + description: 'Computes one argument to the power of another argument and scales the result.', + syntax: 'ares = pow(aarg, k= pow([, inorm])\n ires = pow(iarg, i= pow([, inorm])\n kres = pow(karg, k= pow([, inorm])\n ires[] = pow(iarg[], ipow[])\n kres[] = pow(karg[], kpow[])\n ires[] = pow(iarg[], ipow)\n kres[] = pow(karg[], kpow)', + example: '--8<-- "examples/pow.csd"', + rates: ['a-rate', 'k-rate', 'i-rate'], + parameters: [ + { + name: 'aarg', + description: 'the base.', + type: 'performance' + }, + { + name: 'iarg', + description: 'the base.', + type: 'performance' + }, + { + name: 'karg', + description: 'the base.', + type: 'performance' + }, + { + name: 'ipow', + description: 'the exponent.', + type: 'performance' + }, + { + name: 'kpow', + description: 'the exponent.', + type: 'performance' + }, + ], + seeAlso: ['Mathematical Functions', 'Opcode Equivalents of Functions'] +}, +{ + name: 'product', + type: 'opcode', + category: 'Mathematical Operations:Opcode Equivalents of Functions', + description: 'Multiplies any number of a-rate signals.', + syntax: 'ares = product(asig1, asig2 [, asig3] [...])', + example: '--8<-- "examples/product.csd"', + rates: ['a-rate'], + seeAlso: ['Opcode Equivalents of Functions'] +}, +] diff --git a/src/lib/csound-reference/mathematical-operations-random-functions.ts b/src/lib/csound-reference/mathematical-operations-random-functions.ts new file mode 100644 index 0000000..8809715 --- /dev/null +++ b/src/lib/csound-reference/mathematical-operations-random-functions.ts @@ -0,0 +1,21 @@ +import type { CsoundReference } from './types' + +// Mathematical Operations:Random Functions +export const mathematicalOperationsRandomFunctions: CsoundReference[] = [ +{ + name: 'birnd', + type: 'opcode', + category: 'Mathematical Operations:Random Functions', + description: 'Returns a random number in a bi-polar range.', + example: '--8<-- "examples/birnd-modern.csd"', + seeAlso: ['Random Functions'] +}, +{ + name: 'rnd', + type: 'opcode', + category: 'Mathematical Operations:Random Functions', + description: 'Returns a random number in a unipolar range at the rate given by the input argument.', + example: '--8<-- "examples/rnd.csd"', + seeAlso: ['Random Functions'] +}, +] diff --git a/src/lib/csound-reference/mathematical-operations-trigonometric-functions.ts b/src/lib/csound-reference/mathematical-operations-trigonometric-functions.ts new file mode 100644 index 0000000..6633c5f --- /dev/null +++ b/src/lib/csound-reference/mathematical-operations-trigonometric-functions.ts @@ -0,0 +1,61 @@ +import type { CsoundReference } from './types' + +// Mathematical Operations:Trigonometric Functions +export const mathematicalOperationsTrigonometricFunctions: CsoundReference[] = [ +{ + name: 'cos', + type: 'opcode', + category: 'Mathematical Operations:Trigonometric Functions', + description: 'Returns the cosine of _x_ (_x_ in radians).', + example: '--8<-- "examples/cos.csd"', + seeAlso: ['Trigonometric Functions'] +}, +{ + name: 'cosh', + type: 'opcode', + category: 'Mathematical Operations:Trigonometric Functions', + description: 'Returns the hyperbolic cosine of _x_ (_x_ in radians).', + example: '--8<-- "examples/cosh.csd"', + seeAlso: ['Trigonometric Functions'] +}, +{ + name: 'cosinv', + type: 'opcode', + category: 'Mathematical Operations:Trigonometric Functions', + description: 'Returns the arccosine of _x_ (_x_ in radians).', + example: '--8<-- "examples/cosinv.csd"', + seeAlso: ['Trigonometric Functions'] +}, +{ + name: 'signum', + type: 'opcode', + category: 'Mathematical Operations:Trigonometric Functions', + description: 'Returns the signum of _x_ returning -1, 0 or 1.', + example: '--8<-- "examples/signum.csd"', + seeAlso: ['Trigonometric Functions'] +}, +{ + name: 'sin', + type: 'opcode', + category: 'Mathematical Operations:Trigonometric Functions', + description: 'Returns the sine of _x_ (_x_ in radians).', + example: '--8<-- "examples/sin.csd"', + seeAlso: ['Trigonometric Functions'] +}, +{ + name: 'sinh', + type: 'opcode', + category: 'Mathematical Operations:Trigonometric Functions', + description: 'Returns the hyperbolic sine of _x_ (_x_ in radians).', + example: '--8<-- "examples/sinh.csd"', + seeAlso: ['Trigonometric Functions'] +}, +{ + name: 'sininv', + type: 'opcode', + category: 'Mathematical Operations:Trigonometric Functions', + description: 'Returns the arcsine of _x_ (_x_ in radians).', + example: '--8<-- "examples/sininv.csd"', + seeAlso: ['Trigonometric Functions'] +}, +] diff --git a/src/lib/csound-reference/midi-files-midi-input-and-initialization.ts b/src/lib/csound-reference/midi-files-midi-input-and-initialization.ts new file mode 100644 index 0000000..246768f --- /dev/null +++ b/src/lib/csound-reference/midi-files-midi-input-and-initialization.ts @@ -0,0 +1,21 @@ +import type { CsoundReference } from './types' + +// MIDI files:MIDI input and Initialization +export const midiFilesMidiInputAndInitialization: CsoundReference[] = [ +{ + name: 'eventtype', + type: 'opcode', + category: 'MIDI files:MIDI input and Initialization', + description: 'Returns the event type for an instrument.', + syntax: 'type:i = eventtype()', + seeAlso: ['MIDI input and Initialization'] +}, +{ + name: 'midifilestatus', + type: 'opcode', + category: 'MIDI files:MIDI input and Initialization', + description: 'Returns the playback status of MIDI file input.', + syntax: 'status:k = midifilestatus([id:k])', + seeAlso: ['MIDI input and Initialization'] +}, +] diff --git a/src/lib/csound-reference/miscellaneous.ts b/src/lib/csound-reference/miscellaneous.ts new file mode 100644 index 0000000..86c21c7 --- /dev/null +++ b/src/lib/csound-reference/miscellaneous.ts @@ -0,0 +1,187 @@ +import type { CsoundReference } from './types' + +// Miscellaneous +export const miscellaneous: CsoundReference[] = [ +{ + name: 'directory', + type: 'opcode', + category: 'Miscellaneous', + description: 'Reads a directory and outputs to a string array a list of file names.', + syntax: 'SFiles[] = directory(SDirectory [, SExtention])', + example: '--8<-- "examples/directory.csd"', + parameters: [ + { + name: 'SDirectory', + description: 'a string that identifies the directory to browse for files', + type: 'initialization' + }, + { + name: 'SExtention', + description: 'Optional. Sets the desired file type. If left out, all files names will be retrieved.', + type: 'initialization' + }, + ], + seeAlso: ['Miscellaneous opcodes'] +}, +{ + name: 'framebuffer', + type: 'opcode', + category: 'Miscellaneous', + description: 'Read audio signals into 1 dimensional k-rate arrays and vice-versa with a specified buffer size.', + syntax: 'kout[] = framebuffer(ain, isize)\n aout = framebuffer(kin, isize)', + example: '--8<-- "examples/framebuffer.csd"', + rates: ['k-rate'], + parameters: [ + { + name: 'isize', + description: 'The amount of samples that the buffer will contain.', + type: 'initialization' + }, + { + name: 'ain', + description: 'The audio signal input to the framebuffer.', + type: 'performance' + }, + { + name: 'aout', + description: 'The audio signal output from the framebuffer. _kin_ -- The k-rate array input to the framebuffer.', + type: 'performance' + }, + ], + seeAlso: ['Array-based spectral opcodes'] +}, +{ + name: 'modmatrix', + type: 'opcode', + category: 'Miscellaneous', + description: 'Modulation matrix opcode with optimizations for sparse matrices.', + syntax: 'modmatrix(iresfn, isrcmodfn, isrcparmfn, imodscale, inum_mod, \\\n inum_parm, kupdate)', + example: '--8<-- "examples/modmatrix.csd"', + parameters: [ + { + name: 'iresfn', + description: 'ftable number for the parameter output variables', + type: 'initialization' + }, + { + name: 'isrcmodfn', + description: 'ftable number for the modulation source variables', + type: 'initialization' + }, + { + name: 'isrcparmfn', + description: 'ftable number for the parameter input variables', + type: 'initialization' + }, + { + name: 'imodscale', + description: 'scaling/routing coefficient matrix. This is also a csound ftable, used as a matrix of inum_mod rows and inum_parm columns.', + type: 'initialization' + }, + { + name: 'inum_mod', + description: 'number of modulation variables', + type: 'initialization' + }, + { + name: 'inum_parm', + description: 'number of parmeter (input and output) variables.', + type: 'initialization' + }, + { + name: 'kupdate', + description: 'flag to update the scaling coefficients. When the flag is set to a nonzero value, the scaling coefficients are read directly from the imodscale ftable. When the flag is set to zero, the scaling coefficients are scanned, and an optimized scaling matrix stored internally in the opcode.', + type: 'performance' + }, + ], + seeAlso: ['Miscellaneous opcodes'] +}, +{ + name: 'nchnls_hw', + type: 'opcode', + category: 'Miscellaneous', + description: 'Returns the number of audio channels in the underlying hardware.', + syntax: 'idacc, iadcc = nchnls_hw()', + example: '--8<-- "examples/nchnls_hw.csd"', + seeAlso: ['Miscellaneous opcodes'] +}, +{ + name: 'olabuffer', + type: 'opcode', + category: 'Miscellaneous', + description: 'Sum overlapping frames of audio as k-rate arrays and read as an audio signal.', + syntax: 'aout = olabuffer(kin, ioverlap)', + example: '--8<-- "examples/framebuffer.csd"', + rates: ['k-rate'], + parameters: [ + { + name: 'ioverlap', + description: 'The amount of overlaps per k-array input frame sample size. For example for an input window size of 1024, and a hop size of 256 the overlap factor would be 4. The overlap factor must be larger than or equal to ksmps and must also be an integer multiple of the input k-rate array sample count.', + type: 'initialization' + }, + { + name: 'aout', + description: 'The resulting audio signal from the added input frames.', + type: 'performance' + }, + { + name: 'kin', + description: 'A k-rate array containing sequential frames of audio.', + type: 'performance' + }, + ], + seeAlso: ['Array-based spectral opcodes'] +}, +{ + name: 'pwd', + type: 'opcode', + category: 'Miscellaneous', + description: 'Asks the underlying operating system for the current directory (folder) name as a string.', + syntax: 'Sres = pwd()', + example: '--8<-- "examples/pwd.csd"', + parameters: [ + { + name: 'Sres', + description: 'the returned string.', + type: 'performance' + }, + ], + seeAlso: ['Miscellaneous opcodes'] +}, +{ + name: 'select', + type: 'opcode', + category: 'Miscellaneous', + description: 'Select sample value from three based on audio-rate comparisons of two signals.', + syntax: 'aout = select(a1, a2, aless, aequal, amore)', + example: '--8<-- "examples/select.csd"', + parameters: [ + { + name: 'a1', + description: 'audio signals that are compared.', + type: 'performance' + }, + { + name: 'a2', + description: 'audio signals that are compared.', + type: 'performance' + }, + { + name: 'aless', + description: 'audio signal selected if a1[n]<a2[n]', + type: 'performance' + }, + { + name: 'aequal', + description: 'audio signal selected if a1[n]=a2[n]', + type: 'performance' + }, + { + name: 'asig', + description: 'audio signal selected if a1[n]>a2[n]', + type: 'performance' + }, + ], + seeAlso: ['Miscellaneous opcodes'] +}, +] diff --git a/src/lib/csound-reference/mixer-opcodes.ts b/src/lib/csound-reference/mixer-opcodes.ts new file mode 100644 index 0000000..b36ac22 --- /dev/null +++ b/src/lib/csound-reference/mixer-opcodes.ts @@ -0,0 +1,149 @@ +import type { CsoundReference } from './types' + +// Mixer Opcodes +export const mixerOpcodes: CsoundReference[] = [ +{ + name: 'MixerClear', + type: 'opcode', + category: 'Mixer Opcodes', + description: 'Resets all channels of a buss to 0.', + syntax: 'MixerClear()', + example: 'instr 220 ; Master output\n ; It applies a bass enhancement, compression and fadeout\n ; to the whole piece, outputs signals, and clears the mixer.\n a1 MixerReceive 220, 0\n a2 MixerReceive 220, 1\n ; Bass enhancement\n al1 butterlp a1, 100\n al2 butterlp a2, 100\n a1 = al1*1.5 + a1\n a2 = al2*1.5 + a2 \n\n ; Global amplitude shape\n kenv linseg 0., p5 / 2.0, p4, p3 - p5, p4, p5 / 2.0, 0.\n a1=a1*kenv\n a2=a2*kenv \n \n ; Compression\n a1 dam a1, 5000, 0.5, 1, 0.2, 0.1 \n a2 dam a2, 5000, 0.5, 1, 0.2, 0.1 \n \n ; Remove DC bias\n a1blocked dcblock\t\ta1\n a2blocked\tdcblock\t\ta2\n \n ; Output signals\n outs a1blocked, a2blocked\n MixerClear\nendin', + seeAlso: ['Mixer Opcodes'] +}, +{ + name: 'MixerGetLevel', + type: 'opcode', + category: 'Mixer Opcodes', + description: 'Gets the level at which signals from the send are being added to the buss.', + syntax: 'kgain = MixerGetLevel(isend, ibuss)', + example: '--8<-- "examples/Mixer.csd"', + parameters: [ + { + name: 'isend', + description: 'The number of the send, for example the number of the instrument sending the signal.', + type: 'initialization' + }, + { + name: 'ibuss', + description: 'The number of the buss, for example the number of the instrument receiving the signal.', + type: 'initialization' + }, + { + name: 'kgain', + description: 'The level (any real number) at which the signal from the send will be mixed onto the buss.', + type: 'performance' + }, + ], + seeAlso: ['Mixer Opcodes'] +}, +{ + name: 'MixerReceive', + type: 'opcode', + category: 'Mixer Opcodes', + description: 'Receives an arate signal that has been mixed onto a channel of a buss.', + syntax: 'asignal = MixerReceive(ibuss, ichannel)', + example: 'instr 220 ; Master output\n ; It applies a bass enhancement, compression and fadeout\n ; to the whole piece, outputs signals, and clears the mixer.\n a1 MixerReceive 220, 0\n a2 MixerReceive 220, 1\n ; Bass enhancement\n al1 butterlp a1, 100\n al2 butterlp a2, 100\n a1 = al1*1.5 + a1\n a2 = al2*1.5 + a2 \n\n ; Global amplitude shape\n kenv linseg 0., p5 / 2.0, p4, p3 - p5, p4, p5 / 2.0, 0.\n a1=a1*kenv\n a2=a2*kenv \n \n ; Compression\n a1 dam a1, 5000, 0.5, 1, 0.2, 0.1 \n a2 dam a2, 5000, 0.5, 1, 0.2, 0.1 \n \n ; Remove DC bias\n a1blocked dcblock\t\ta1\n a2blocked\tdcblock\t\ta2\n \n ; Output signals\n outs a1blocked, a2blocked\n MixerClear\nendin', + parameters: [ + { + name: 'ibuss', + description: 'The number of the buss, for example the number of the instrument receiving the signal.', + type: 'initialization' + }, + { + name: 'ichannel', + description: 'The number of the channel. Each buss has _nchnls_ channels.', + type: 'initialization' + }, + { + name: 'asignal', + description: 'The signal that has been mixed onto the indicated channel of the buss.', + type: 'performance' + }, + ], + seeAlso: ['Mixer Opcodes'] +}, +{ + name: 'MixerSend', + type: 'opcode', + category: 'Mixer Opcodes', + description: 'Mixes an arate signal into a channel of a buss.', + syntax: 'MixerSend(asignal, isend, ibuss, ichannel)', + example: 'instr 100 ; Fluidsynth output\n; INITIALIZATION\n; Normalize so iamplitude for p5 of 80 == ampdb(80).\niamplitude \t\t= \t\t\tampdb(p5) * 2.0\n; AUDIO\naleft, aright \t\tfluidAllOut\t\tgiFluidsynth\nasig1 \t\t\t= \t\t\taleft * iamplitude\nasig2 \t\t\t= \t\t\taright * iamplitude\n\t\t\t; To the chorus.\n\t\t\tMixerSend\t\tasig1, 100, 200, 0\n\t\t\tMixerSend\t\tasig2, 100, 200, 1\n\t\t\t; To the reverb.\n\t\t\tMixerSend\t\tasig1, 100, 210, 0\n\t\t\tMixerSend\t\tasig2, 100, 210, 1\n\t\t\t; To the output.\n\t\t\tMixerSend\t\tasig1, 100, 220, 0\n\t\t\tMixerSend\t\tasig2, 100, 220, 1\nendin', + parameters: [ + { + name: 'isend', + description: 'The number of the send, for example the number of the instrument sending the signal. The gain of the send is controlled by the [MixerSetLevel](../opcodes/mixersetlevel.md) opcode. The reason that the sends are numbered is to enable different levels for different sends to be set independently of the actual level of the signals.', + type: 'initialization' + }, + { + name: 'ibuss', + description: 'The number of the buss, for example the number of the instrument receiving the signal.', + type: 'initialization' + }, + { + name: 'ichannel', + description: 'The number of the channel. Each buss has nchnls channels.', + type: 'initialization' + }, + { + name: 'asignal', + description: 'The signal that will be mixed into the indicated channel of the buss.', + type: 'performance' + }, + ], + seeAlso: ['Mixer Opcodes'] +}, +{ + name: 'MixerSetLevel', + type: 'opcode', + category: 'Mixer Opcodes', + description: 'Sets the level at which signals from the send are added to the buss. Plugin opcode in mixer', + syntax: 'MixerSetLevel(isend, ibuss, kgain)', + example: 'instr 1\n\tMixerSetLevel\t\tp4, p5, p6\nendin', + parameters: [ + { + name: 'isend', + description: 'The number of the send, for example the number of the instrument sending the signal (but any integer can be used).', + type: 'initialization' + }, + { + name: 'ibuss', + description: 'The number of the buss, for example the number of the instrument receiving the signal (but any integer can be used).', + type: 'initialization' + }, + { + name: 'kgain', + description: 'The level (any real number) at which the signal from the send will be mixed onto the buss. The default is 0.', + type: 'performance' + }, + ], + seeAlso: ['Mixer Opcodes'] +}, +{ + name: 'MixerSetLevel_i', + type: 'opcode', + category: 'Mixer Opcodes', + description: 'Sets the level at which signals from the send are added to the buss.', + syntax: 'MixerSetLevel_i(isend, ibuss, igain)', + example: 'MixerSetLevel_i\t\t3, 4, 0.76', + parameters: [ + { + name: 'isend', + description: 'The number of the send, for example the number of the instrument sending the signal (but any integer can be used).', + type: 'initialization' + }, + { + name: 'ibuss', + description: 'The number of the buss, for example the number of the instrument receiving the signal (but any integer can be used).', + type: 'initialization' + }, + { + name: 'igain', + description: 'The level (any real number) at which the signal from the send will be mixed onto the buss. The default is 0.', + type: 'initialization' + }, + ], + seeAlso: ['Mixer Opcodes'] +}, +] diff --git a/src/lib/csound-reference/network.ts b/src/lib/csound-reference/network.ts new file mode 100644 index 0000000..5c8009b --- /dev/null +++ b/src/lib/csound-reference/network.ts @@ -0,0 +1,124 @@ +import type { CsoundReference } from './types' + +// Network +export const network: CsoundReference[] = [ +{ + name: 'remoteport', + type: 'opcode', + category: 'Network', + description: 'Defines the port for use with the _insremot_, _midremot_, _insglobal_ and _midglobal_ opcodes.', + syntax: 'remoteport(iportnum)', + parameters: [ + { + name: 'iportnum', + description: 'number of the port to be used. If zero or negative the default port 40002 is selected.', + type: 'initialization' + }, + ], + seeAlso: ['Remote Opcodes'] +}, +{ + name: 'sockrecv', + type: 'opcode', + category: 'Network', + description: 'Receives data from other processes using the low-level UDP or TCP protocols.', + syntax: 'asig = sockrecv(iport, ilength)\n ksig = sockrecv(iport, ilength)\n asigl, asigr = sockrecvs(iport, ilength)\n String = sockrecv(iport, ilength)\n asig [,kstate] = strecv(Sipaddr, iport)', + example: 'sr = 44100\n ksmps = 100\n nchnls = 1\n\n\n instr 1\n a1 sockrecv 7777, 200\n out a1\n endin', + rates: ['a-rate'], + parameters: [ + { + name: 'Sipaddr', + description: 'a string that is the IP address of the sender in standard 4-octet dotted form.', + type: 'initialization' + }, + { + name: 'iport', + description: 'the number of the port that is used for the communication.', + type: 'initialization' + }, + { + name: 'ilength', + description: 'the length of the individual packets in UDP transmission. This number must be sufficiently small to fit a single MTU, which is set to the save value of 1456. In UDP transmissions the sender and receiver needs agree on this value', + type: 'initialization' + }, + { + name: 'asig', + description: 'audio data to be received.', + type: 'performance' + }, + { + name: 'asigl', + description: 'audio data to be received.', + type: 'performance' + }, + { + name: 'asigr', + description: 'audio data to be received.', + type: 'performance' + }, + { + name: 'ksig', + description: 'control data to be received.', + type: 'performance' + }, + { + name: 'String', + description: 'string data to be received.', + type: 'performance' + }, + { + name: 'kstate', + description: 'optional output to give the state of the receipt. Gives the number of bytes transferred in the current performance cycle or -1 if the sender has ceased writing.', + type: 'performance' + }, + ], + seeAlso: ['Network'] +}, +{ + name: 'socksend', + type: 'opcode', + category: 'Network', + description: 'Sends data to other processes using the low-level UDP or TCP protocols.', + syntax: 'socksend(asig, Sipaddr, iport, ilength)\n socksend(ksig, Sipaddr, iport, ilength)\n socksends(asigl, asigr, Sipaddr, iport, ilength)\n stsend(asig, Sipaddr, iport)', + example: 'sr = 44100\n ksmps = 100\n nchnls = 1\n\n\n instr 1\n a1 oscil 20000,441,1\n socksend a1, "172.16.0.255",7777, 200\n endin', + rates: ['a-rate'], + parameters: [ + { + name: 'Sipaddr', + description: 'a string that is the IP address of the receiver in standard 4-octet dotted form.', + type: 'initialization' + }, + { + name: 'iport', + description: 'the number of the port that is used for the communication.', + type: 'initialization' + }, + { + name: 'ilength', + description: 'the length of the individual packets in UDP transmission. This number must be sufficiently small to fit a single MTU, which is set to the save value of 1456. In UDP transmissions the receiver needs to know this value', + type: 'initialization' + }, + { + name: 'asig', + description: 'data to be transmitted.', + type: 'performance' + }, + { + name: 'ksig', + description: 'data to be transmitted.', + type: 'performance' + }, + { + name: 'asigl', + description: 'data to be transmitted.', + type: 'performance' + }, + { + name: 'asigr', + description: 'data to be transmitted.', + type: 'performance' + }, + ], + seeAlso: ['Network'] +}, +] diff --git a/src/lib/csound-reference/orchestra-syntax-block-statements.ts b/src/lib/csound-reference/orchestra-syntax-block-statements.ts new file mode 100644 index 0000000..73ef180 --- /dev/null +++ b/src/lib/csound-reference/orchestra-syntax-block-statements.ts @@ -0,0 +1,54 @@ +import type { CsoundReference } from './types' + +// Orchestra Syntax:Block Statements +export const orchestraSyntaxBlockStatements: CsoundReference[] = [ +{ + name: 'endin', + type: 'opcode', + category: 'Orchestra Syntax:Block Statements', + description: 'Ends the current instrument block.', + example: '--8<-- "examples/endin.csd"', + seeAlso: ['Instrument Statements'] +}, +{ + name: 'endop', + type: 'opcode', + category: 'Orchestra Syntax:Block Statements', + description: 'Marks the end of an user-defined opcode block.', + example: '--8<-- "examples/endop.csd"', + seeAlso: ['User Defined Opcodes (UDO)', 'http://www.csoundjournal.com/2006summer/controlFlow_part2.html', 'http://www.csounds.com/udo/'] +}, +{ + name: 'instr', + type: 'opcode', + category: 'Orchestra Syntax:Block Statements', + description: 'Starts an instrument block.', + example: '--8<-- "examples/instr.csd"', + seeAlso: ['Instrument Statements'] +}, +{ + name: 'opcode', + type: 'opcode', + category: 'Orchestra Syntax:Block Statements', + description: 'Defines the start of user-defined opcode block.', + example: '--8<-- "examples/opcode.csd"', + parameters: [ + { + name: 'name', + description: 'name of the opcode. It may consist of any combination of letters, digits, and underscore but should not begin with a digit. If an opcode with the specified name already exists, it is redefined (a warning is printed in such cases). Some reserved words (like _instr_ and _endin_) cannot be redefined.', + type: 'initialization' + }, + { + name: 'intypes', + description: 'list of input types, any combination of the characters: a, f, k, O, P, V, K, i, o, p, and j. A single 0 character can be used if there are no input arguments. Double quotes and delimiter characters (e.g. comma) are _not_ needed.', + type: 'initialization' + }, + { + name: 'outtypes', + description: 'list of output types. The format is the same as in the case of _intypes_.', + type: 'initialization' + }, + ], + seeAlso: ['User Defined Opcodes (UDO)'] +}, +] diff --git a/src/lib/csound-reference/orchestra-syntax-header.ts b/src/lib/csound-reference/orchestra-syntax-header.ts new file mode 100644 index 0000000..397f756 --- /dev/null +++ b/src/lib/csound-reference/orchestra-syntax-header.ts @@ -0,0 +1,68 @@ +import type { CsoundReference } from './types' + +// Orchestra Syntax:Header +export const orchestraSyntaxHeader: CsoundReference[] = [ +{ + name: 'Zerodbfs', + type: 'opcode', + category: 'Orchestra Syntax:Header', + description: 'Sets the value of 0 decibels using full scale amplitude.', + example: '--8<-- "examples/0dbfs-modern.csd"', + parameters: [ + { + name: 'iarg', + description: 'the value of 0 decibels using full scale amplitude.', + type: 'initialization' + }, + ], + seeAlso: ['Orchestra Header Statements'] +}, +{ + name: 'A4', + type: 'opcode', + category: 'Orchestra Syntax:Header', + description: 'Sets the base frequency for pitch A4.', + example: '--8<-- "examples/A4-modern.csd"', + seeAlso: ['Orchestra Header Statements'] +}, +{ + name: 'kr', + type: 'opcode', + category: 'Orchestra Syntax:Header', + description: 'Sets the control rate.', + example: 'sr = 10000\nkr = 500\nksmps = 20\ngi1 = sr/2.\nga init 0\nitranspose = octpch(.0l)', + seeAlso: ['Orchestra Header Statements'] +}, +{ + name: 'ksmps', + type: 'opcode', + category: 'Orchestra Syntax:Header', + description: 'Sets the number of samples in a control period.', + example: '--8<-- "examples/ksmps.csd"', + seeAlso: ['Orchestra Header Statements'] +}, +{ + name: 'nchnls', + type: 'opcode', + category: 'Orchestra Syntax:Header', + description: 'Sets the number of channels of audio output.', + example: '--8<-- "examples/nchnls.csd"', + seeAlso: ['Orchestra Header Statements'] +}, +{ + name: 'nchnls_i', + type: 'opcode', + category: 'Orchestra Syntax:Header', + description: 'Sets the number of channels of audio input.', + example: '--8<-- "examples/nchnls_i.csd"', + seeAlso: ['Orchestra Header Statements'] +}, +{ + name: 'sr', + type: 'opcode', + category: 'Orchestra Syntax:Header', + description: 'Sets the audio sampling rate.', + example: 'sr = 10000\nkr = 500\nksmps = 20\ngi1 = sr/2.\nga init 0\nitranspose = octpch(.0l)', + seeAlso: ['Orchestra Header Statements'] +}, +] diff --git a/src/lib/csound-reference/orchestra-syntax-macros.ts b/src/lib/csound-reference/orchestra-syntax-macros.ts new file mode 100644 index 0000000..8fbb38f --- /dev/null +++ b/src/lib/csound-reference/orchestra-syntax-macros.ts @@ -0,0 +1,45 @@ +import type { CsoundReference } from './types' + +// Orchestra Syntax:Macros +export const orchestraSyntaxMacros: CsoundReference[] = [ +{ + name: 'define', + type: 'opcode', + category: 'Orchestra Syntax:Macros', + description: 'Defines a macro.', + example: '--8<-- "examples/define.csd"', + seeAlso: ['Orchestra Macros'] +}, +{ + name: 'dollar', + type: 'opcode', + category: 'Orchestra Syntax:Macros', + description: 'Calls a defined macro.', + example: '--8<-- "examples/define.csd"', + seeAlso: ['Orchestra Macros'] +}, +{ + name: 'ifdef', + type: 'opcode', + category: 'Orchestra Syntax:Macros', + description: 'Conditional reading of code.', + example: '#define debug ##\n instr 1\n#ifdef debug\n print "calling oscil"\n#end\n a1 oscil 32000,440,1\n out a1\n endin', + seeAlso: ['Orchestra Macros'] +}, +{ + name: 'ifndef', + type: 'opcode', + category: 'Orchestra Syntax:Macros', + description: 'Conditional reading of code.', + example: '#define final ##\n instr 1\n#ifndef final\n print "calling oscil"\n#end\n a1 oscil 32000,440,1\n out a1\n endin', + seeAlso: ['Orchestra Macros'] +}, +{ + name: 'include', + type: 'opcode', + category: 'Orchestra Syntax:Macros', + description: 'Includes an external file for processing.', + example: '/* table1.inc */\n; Table #1, a sine wave.\nf 1 0 16384 10 1\n/* table1.inc */', + seeAlso: ['Orchestra Macros'] +}, +] diff --git a/src/lib/csound-reference/osc.ts b/src/lib/csound-reference/osc.ts new file mode 100644 index 0000000..0d62765 --- /dev/null +++ b/src/lib/csound-reference/osc.ts @@ -0,0 +1,187 @@ +import type { CsoundReference } from './types' + +// OSC +export const osc: CsoundReference[] = [ +{ + name: 'OSCbundle', + type: 'opcode', + category: 'OSC', + description: 'Sends data to other processes using the OSC protocol by packing messages in a bundle.', + syntax: 'OSCbundle(kwhen, ihost, iport, Sdest[], Stype[], kArgs[][] [, isize])', + example: '--8<-- "examples/oscbundle.csd"', + parameters: [ + { + name: 'ihost', + description: 'a string that is the intended host computer domain name. An empty string is interpreted as the current computer.', + type: 'initialization' + }, + { + name: 'iport', + description: 'the number of the port that is used for the communication.', + type: 'initialization' + }, + { + name: 'isize', + description: 'maximum packet size in bytes, defaults to 65536.', + type: 'initialization' + }, + { + name: 'kwhen', + description: 'a bundle of messages is sent whenever this value changes. A message will always be sent on the first call.', + type: 'performance' + }, + ], + seeAlso: ['OSC (Open Sound Control)', 'http://www.youtube.com/watch?v=JX1C3TqP_9Y'] +}, +{ + name: 'OSCcount', + type: 'opcode', + category: 'OSC', + description: 'Gives the Count of OSC messages currently unread but received by the current listeners.', + syntax: 'kans = OSCcount()', + example: 'sr = 44100\n ksmps = 100\n nchnls = 2\n\n gihandle OSCinit 7770\n\n instr 1\n kf1 init 0\n kf2 init 0\n kk OSCcount\nnxtmsg:\n\nif (kk == 0) goto ex\n kr OSClisten gihandle, "/foo/bar", "ff", kf1, kf2\n printk 0,kf1\n printk 0,kf2\n kk -= 1\n kgoto nxtmsg\nex:\n endin', + parameters: [ + { + name: 'kans', + description: 'set to the number of messages accepted by this Csound process to any address but not yet presented to a call of OSClisten.', + type: 'performance' + }, + ], + seeAlso: ['OSC (Open Sound Control)', 'http://www.youtube.com/watch?v=JX1C3TqP_9Y'] +}, +{ + name: 'OSCinit', + type: 'opcode', + category: 'OSC', + description: 'Start a listening process for OSC messages to a particular port.', + syntax: 'ihandle = OSCinit(iport)', + example: 'sr = 44100\nksmps = 100\nnchnls = 2\n\ngihandle OSCinit 7770\n\n instr 1\n kf1 init 0\n kf2 init 0\nnxtmsg:\n kk OSClisten gihandle, "/foo/bar", "ff", kf1, kf2\nif (kk == 0) goto ex\n printk 0,kf1\n printk 0,kf2\n kgoto nxtmsg\nex:\n endin', + parameters: [ + { + name: 'ihandle', + description: 'handle returned that can be passed to any number of OSClisten opcodes to receive messages on this port.', + type: 'initialization' + }, + { + name: 'iport', + description: 'the port on which to listen.', + type: 'initialization' + }, + ], + seeAlso: ['OSC (Open Sound Control)', 'http://www.youtube.com/watch?v=JX1C3TqP_9Y'] +}, +{ + name: 'OSCinitM', + type: 'opcode', + category: 'OSC', + description: 'Start a multicast listening process to a particular port, which can be used by OSClisten.', + syntax: 'ihandle = OSCinitM(Sgroup, iport)', + example: 'sr = 44100\nksmps = 100\nnchnls = 2\n\ngihandle OSCinitM "225.0.0.1", 7770\n\n instr 1\n kf1 init 0\n kf2 init 0\nnxtmsg:\n kk OSClisten gihandle, "/foo/bar", "ff", kf1, kf2\nif (kk == 0) goto ex\n printk 0,kf1\n printk 0,kf2\n kgoto nxtmsg\nex:\n endin', + parameters: [ + { + name: 'Sgroup', + description: 'string giving the IP address of the multicast group.', + type: 'initialization' + }, + { + name: 'ihandle', + description: 'handle returned that can be passed to any number of OSClisten opcodes to receive messages on this port.', + type: 'initialization' + }, + { + name: 'iport', + description: 'the port on which to listen.', + type: 'initialization' + }, + ], + seeAlso: ['OSC (Open Sound Control)', 'http://www.youtube.com/watch?v=JX1C3TqP_9Y'] +}, +{ + name: 'OSClisten', + type: 'opcode', + category: 'OSC', + description: 'Listen for OSC messages to a particular path, either from a custom-defined OSC server or from the Csound UDP server.', + syntax: 'kans = OSClisten(ihandle, idest, itype [, xdata1, xdata2, ...])\n kans, kdata[] = OSClisten(ihandle, idest, itype)\n kans, ... = OSClisten(idest, itype)', + example: 'sr = 44100\n ksmps = 100\n nchnls = 2\n\n gihandle OSCinit 7770\n\n instr 1\n kf1 init 0\n kf2 init 0\nnxtmsg:\n kk OSClisten gihandle, "/foo/bar", "ff", kf1, kf2\nif (kk == 0) goto ex\n printk 0,kf1\n printk 0,kf2\n kgoto nxtmsg\nex:\n endin', + parameters: [ + { + name: 'ihandle', + description: 'In the first two versions (overloads) of the opcode, a handle returned by an earlier call to OSCinit, to associate OSClisten with a particular port number. The third overload does not take a handle as it will listen for messages sent to the Csound [UDP server](../overview/udp-server.md).', + type: 'initialization' + }, + { + name: 'idest', + description: 'a string that is the destination address. This takes the form of a path prefixed with a forward slash, with optional subdirectories separated by forward slashes. Csound processes incoming messages that match this address.', + type: 'initialization' + }, + { + name: 'itype', + description: 'a string that indicates the types of the optional arguments that are to be read. The string can contain the characters "acdfhisAG" which stand for audio, character, double, float, 64-bit integer, 32-bit integer, string, scalar array and f-table. All types other than \'asA\' require a k-rate variable; \'s\' requires a string variable, \'a\' an audio variable and \'A\' an i- or k- rate array. For type \'G\', a variable or constant can be used.', + type: 'initialization' + }, + { + name: 'kans', + description: 'set to 1 if a new message was received, or 0 if not. If multiple messages are received in a single control period, the messages are buffered, and OSClisten can be called again until zero is returned.', + type: 'performance' + }, + ], + seeAlso: ['OSC (Open Sound Control)', 'http://www.youtube.com/watch?v=JX1C3TqP_9Y'] +}, +{ + name: 'OSCraw', + type: 'opcode', + category: 'OSC', + description: 'Listen for all OSC messages at a given port.', + syntax: 'Smess[], klen = OSCraw(iport)', + example: '--8<-- "examples/OSCraw.csd"', + parameters: [ + { + name: 'iport', + description: 'a port where messages are going to be received from.', + type: 'initialization' + }, + { + name: 'klen', + description: 'number of items placed in the output array. It is 0 if no message has been received, and at least 2 if a message has been received (address, types are the minimum items).', + type: 'performance' + }, + ], + seeAlso: ['OSC (Open Sound Control)', 'http://www.youtube.com/watch?v=JX1C3TqP_9Y'] +}, +{ + name: 'OSCsend', + type: 'opcode', + category: 'OSC', + description: 'Sends data to other listening processes using the OSC protocol.', + syntax: 'OSCsend(kwhen, ihost, iport, idestination [, itype , xdata1, xdata2, ...])', + example: 'instr 1\n OSCsend 1, "xenakis.cs.bath.ac.uk",7770, "/foo/bar", "sis", "FOO", 42, "bar"\n endin', + parameters: [ + { + name: 'ihost', + description: 'a string that is the intended host computer domain name. An empty string is interpreted as the current computer.', + type: 'initialization' + }, + { + name: 'iport', + description: 'the number of the port that is used for the communication.', + type: 'initialization' + }, + { + name: 'idestination', + description: 'a string that is the destination address. This takes the form of a file name with directories. Csound just passes this string to the raw sending code and makes no interpretation.', + type: 'initialization' + }, + { + name: 'itype', + description: 'a string that indicates the types of the optional arguments that are read at k-rate. The string can contain the characters "abcdfilmstAG" which stand for audio, Boolean, character, double, float, 32-bit integer, 64-bit integer, MIDI, string, timestamp, k-rate array and ftable. The OSC message may not have any types, in which case, it will consist only of the destination address.', + type: 'initialization' + }, + { + name: 'kwhen', + description: 'a message is sent whenever this value changes. A message will always be sent on the first call.', + type: 'performance' + }, + ], + seeAlso: ['OSC (Open Sound Control)', 'http://www.youtube.com/watch?v=JX1C3TqP_9Y'] +}, +] diff --git a/src/lib/csound-reference/pitch-converters-functions.ts b/src/lib/csound-reference/pitch-converters-functions.ts new file mode 100644 index 0000000..83e1232 --- /dev/null +++ b/src/lib/csound-reference/pitch-converters-functions.ts @@ -0,0 +1,280 @@ +import type { CsoundReference } from './types' + +// Pitch Converters:Functions +export const pitchConvertersFunctions: CsoundReference[] = [ +{ + name: 'cent', + type: 'opcode', + category: 'Pitch Converters:Functions', + description: 'Calculates a factor to raise/lower a frequency by a given amount of cents.', + example: '--8<-- "examples/cent-modern.csd"', + parameters: [ + { + name: 'x', + description: 'a value expressed in cents.', + type: 'initialization' + }, + ], + seeAlso: ['Pitch Converters: Functions'] +}, +{ + name: 'cpsmidinn', + type: 'opcode', + category: 'Pitch Converters:Functions', + description: 'Converts a Midi note number value to cycles-per-second.', + example: '--8<-- "examples/cpsmidinn.csd"', + seeAlso: ['Pitch Converters: Functions', 'Midi Converters'] +}, +{ + name: 'cpsoct', + type: 'opcode', + category: 'Pitch Converters:Functions', + description: 'Converts an octave-point-decimal value to cycles-per-second.', + example: '--8<-- "examples/cpsoct.csd"', + seeAlso: ['Pitch Converters: Functions'] +}, +{ + name: 'cpspch', + type: 'opcode', + category: 'Pitch Converters:Functions', + description: 'Converts a pitch-class value to cycles-per-second.', + example: '--8<-- "examples/cpspch.csd"', + seeAlso: ['Pitch Converters: Functions'] +}, +{ + name: 'ftom', + type: 'opcode', + category: 'Pitch Converters:Functions', + description: 'Convert frequency to midi note number, taking global value of A4 into account.', + syntax: 'imidi = ftom(ifreq [,irnd])\n kmidi = ftom(kfreq [,irnd])\n imidis[] = ftom(ifreqs[] [,irnd])\n kmidis[] = ftom(kfreqs[] [,irnd])', + example: '--8<-- "examples/mtof-ftom.csd"', + parameters: [ + { + name: 'kfreq', + description: 'Frequency', + type: 'performance' + }, + { + name: 'ifreq', + description: 'Frequency', + type: 'performance' + }, + { + name: 'irnd', + description: 'Optional, if non-zero the result is rounded to the nearest integer (default zero).', + type: 'performance' + }, + { + name: 'kmidi', + description: 'Corresponding midi note number', + type: 'performance' + }, + { + name: 'imidi', + description: 'Corresponding midi note number', + type: 'performance' + }, + ], + seeAlso: ['Pitch Converters: Functions', 'Midi Converters'] +}, +{ + name: 'mtof', + type: 'opcode', + category: 'Pitch Converters:Functions', + description: 'Convert a midi note number value to frequency, taking global value of A4 into account.', + syntax: 'ifreq = mtof(imidi)\n kfreq = mtof(kmidi)\n ifreqs[] = mtof(imidis[])\n kfreqs[] = mtof(kmidis[])', + example: '--8<-- "examples/mtof-ftom.csd"', + parameters: [ + { + name: 'kmidi', + description: 'Midi note number (also as array)', + type: 'performance' + }, + { + name: 'imidi', + description: 'Midi note number (also as array)', + type: 'performance' + }, + { + name: 'kfreq', + description: 'Frequency corresponding to midi note value. An array is returned if the input is an array', + type: 'performance' + }, + { + name: 'ifreq', + description: 'Frequency corresponding to midi note value. An array is returned if the input is an array', + type: 'performance' + }, + ], + seeAlso: ['Pitch Converters: Functions', 'Midi Converters'] +}, +{ + name: 'mton', + type: 'opcode', + category: 'Pitch Converters:Functions', + description: 'Convert midi note number to string note name, with an accuracy of 1 cent.', + syntax: 'Snote = mton(kmidi)\n Snote = mton(imidi)', + example: '--8<-- "examples/mton-ntom.csd"', + parameters: [ + { + name: 'kmidi', + description: 'Midi note number', + type: 'performance' + }, + { + name: 'imidi', + description: 'Midi note number', + type: 'performance' + }, + { + name: 'Snote', + description: 'Note name', + type: 'performance' + }, + ], + seeAlso: ['Pitch Converters: Functions', 'Midi Converters'] +}, +{ + name: 'ntof', + type: 'opcode', + category: 'Pitch Converters:Functions', + description: 'Convert note name to frequency.', + syntax: 'kfreq = ntof(Snote)\n ifreq = ntof(Snote)', + example: '--8<-- "examples/ntof.csd"', + parameters: [ + { + name: 'Snote', + description: 'Note name', + type: 'performance' + }, + { + name: 'kfreq', + description: 'Frequency', + type: 'performance' + }, + ], + seeAlso: ['Pitch Converters: Functions', 'Midi Converters'] +}, +{ + name: 'ntom', + type: 'opcode', + category: 'Pitch Converters:Functions', + description: 'Convert note name to midi note number.', + syntax: 'kmidi = ntom(Snote)\n imidi = ntom(Snote)', + example: '--8<-- "examples/mton-ntom.csd"', + parameters: [ + { + name: 'Snote', + description: 'Note name', + type: 'performance' + }, + { + name: 'kmidi', + description: 'Midi note number', + type: 'performance' + }, + ], + seeAlso: ['Pitch Converters: Functions', 'Midi Converters'] +}, +{ + name: 'octave', + type: 'opcode', + category: 'Pitch Converters:Functions', + description: 'Calculates a factor to raise/lower a frequency by a given amount of octaves.', + example: '--8<-- "examples/octave.csd"', + parameters: [ + { + name: 'x', + description: 'a value expressed in octaves.', + type: 'initialization' + }, + ], + seeAlso: ['Pitch Converters: Functions'] +}, +{ + name: 'octcps', + type: 'opcode', + category: 'Pitch Converters:Functions', + description: 'Converts a cycles-per-second value to octave-point-decimal.', + example: '--8<-- "examples/octcps.csd"', + seeAlso: ['Pitch Converters: Functions'] +}, +{ + name: 'octmidinn', + type: 'opcode', + category: 'Pitch Converters:Functions', + description: 'Converts a Midi note number value to octave-point-decimal.', + example: '--8<-- "examples/cpsmidinn.csd"', + seeAlso: ['Pitch Converters: Functions'] +}, +{ + name: 'octpch', + type: 'opcode', + category: 'Pitch Converters:Functions', + description: 'Converts a pitch-class value to octave-point-decimal.', + example: '--8<-- "examples/octpch.csd"', + seeAlso: ['Pitch Converters: Functions'] +}, +{ + name: 'pchmidinn', + type: 'opcode', + category: 'Pitch Converters:Functions', + description: 'Converts a Midi note number value to octave point pitch-class units.', + example: '--8<-- "examples/cpsmidinn.csd"', + seeAlso: ['Pitch Converters: Functions'] +}, +{ + name: 'pchoct', + type: 'opcode', + category: 'Pitch Converters:Functions', + description: 'Converts an octave-point-decimal value to pitch-class.', + example: '--8<-- "examples/pchoct.csd"', + seeAlso: ['Pitch Converters: Functions'] +}, +{ + name: 'pchtom', + type: 'opcode', + category: 'Pitch Converters:Functions', + description: 'Convert pch to midi note number.', + syntax: 'imidi = pchtom(ipch)\n kmidi = pchtom(kpch)', + example: '--8<-- "examples/pchtom.csd"', + parameters: [ + { + name: 'kpch', + description: 'pitch represented as Octave.pitchclass', + type: 'performance' + }, + { + name: 'ipch', + description: 'pitch represented as Octave.pitchclass', + type: 'performance' + }, + { + name: 'kmidi', + description: 'midi note number', + type: 'performance' + }, + { + name: 'imidi', + description: 'midi note number', + type: 'performance' + }, + ], + seeAlso: ['Pitch Converters: Functions', 'Midi Converters'] +}, +{ + name: 'semitone', + type: 'opcode', + category: 'Pitch Converters:Functions', + description: 'Calculates a factor to raise/lower a frequency by a given amount of semitones.', + example: '--8<-- "examples/semitone.csd"', + parameters: [ + { + name: 'x', + description: 'a value expressed in semitones.', + type: 'initialization' + }, + ], + seeAlso: ['Pitch Converters: Functions'] +}, +] diff --git a/src/lib/csound-reference/pitch-converters-tuning-opcodes.ts b/src/lib/csound-reference/pitch-converters-tuning-opcodes.ts new file mode 100644 index 0000000..21b5871 --- /dev/null +++ b/src/lib/csound-reference/pitch-converters-tuning-opcodes.ts @@ -0,0 +1,116 @@ +import type { CsoundReference } from './types' + +// Pitch Converters:Tuning Opcodes +export const pitchConvertersTuningOpcodes: CsoundReference[] = [ +{ + name: 'cps2pch', + type: 'opcode', + category: 'Pitch Converters:Tuning Opcodes', + description: 'Converts a pitch-class value into cycles-per-second (Hz) for equal divisions of the octave.', + syntax: 'icps = cps2pch(ipch, iequal)', + example: '--8<-- "examples/cps2pch.csd"', + parameters: [ + { + name: 'ipch', + description: 'Input number of the form 8ve.pc, indicating an \'octave\' and which note in the octave.', + type: 'initialization' + }, + { + name: 'iequal', + description: 'If positive, the number of equal intervals into which the \'octave\' is divided. Must be less than or equal to 100. If negative, is the number of a table of frequency multipliers.', + type: 'initialization' + }, + ], + seeAlso: ['Pitch Converters: Tuning Opcodes'] +}, +{ + name: 'cpstun', + type: 'opcode', + category: 'Pitch Converters:Tuning Opcodes', + description: 'Returns micro-tuning values at k-rate.', + syntax: 'kcps = cpstun(ktrig, kindex, kfn)', + example: '--8<-- "examples/cpstun.csd"', + rates: ['k-rate'], + parameters: [ + { + name: 'kcps', + description: 'Return value in cycles per second.', + type: 'performance' + }, + { + name: 'ktrig', + description: 'A trigger signal used to trigger the evaluation.', + type: 'performance' + }, + { + name: 'kindex', + description: 'An integer number denoting an index of scale.', + type: 'performance' + }, + { + name: 'kfn', + description: 'Function table containing the parameters (numgrades, interval, basefreq, basekeymidi) and the tuning ratios.', + type: 'performance' + }, + ], + seeAlso: ['Pitch Converters: Tuning Opcodes'] +}, +{ + name: 'cpstuni', + type: 'opcode', + category: 'Pitch Converters:Tuning Opcodes', + description: 'Returns micro-tuning values at init-rate.', + syntax: 'icps = cpstuni(index, ifn)', + example: '--8<-- "examples/cpstuni.csd"', + rates: ['i-rate'], + parameters: [ + { + name: 'icps', + description: 'Return value in cycles per second.', + type: 'initialization' + }, + { + name: 'index', + description: 'An integer number denoting an index of scale.', + type: 'initialization' + }, + { + name: 'ifn', + description: 'Function table containing the parameters (numgrades, interval, basefreq, basekeymidi) and the tuning ratios.', + type: 'initialization' + }, + ], + seeAlso: ['Pitch Converters: Tuning Opcodes'] +}, +{ + name: 'cpsxpch', + type: 'opcode', + category: 'Pitch Converters:Tuning Opcodes', + description: 'Converts a pitch-class value into cycles-per-second (Hz) for equal divisions of any interval.', + syntax: 'icps = cpsxpch(ipch, iequal, irepeat, ibase)', + example: '--8<-- "examples/cpsxpch.csd"', + parameters: [ + { + name: 'ipch', + description: 'Input number of the form 8ve.pc, indicating an \'octave\' and which note in the octave.', + type: 'initialization' + }, + { + name: 'iequal', + description: 'if positive, the number of equal intervals into which the \'octave\' is divided. Must be less than or equal to 100. If negative, is the number of a table of frequency multipliers.', + type: 'initialization' + }, + { + name: 'irepeat', + description: 'Number indicating the interval which is the \'octave.\' The integer 2 corresponds to octave divisions, 3 to a twelfth, 4 is two octaves, and so on. This need not be an integer, but must be positive.', + type: 'initialization' + }, + { + name: 'ibase', + description: 'The frequency which corresponds to pitch 0.0', + type: 'initialization' + }, + ], + seeAlso: ['Pitch Converters: Tuning Opcodes'] +}, +] diff --git a/src/lib/csound-reference/real-time-midi-converters.ts b/src/lib/csound-reference/real-time-midi-converters.ts new file mode 100644 index 0000000..4201342 --- /dev/null +++ b/src/lib/csound-reference/real-time-midi-converters.ts @@ -0,0 +1,176 @@ +import type { CsoundReference } from './types' + +// Real-time MIDI:Converters +export const realTimeMidiConverters: CsoundReference[] = [ +{ + name: 'ampmidi', + type: 'opcode', + category: 'Real-time MIDI:Converters', + description: 'Get the velocity of the current MIDI event.', + syntax: 'iamp = ampmidi(iscal [, ifn])', + example: '--8<-- "examples/ampmidi-modern.csd"', + rates: ['i-rate'], + parameters: [ + { + name: 'iscal', + description: 'i-time scaling factor', + type: 'initialization' + }, + ], + seeAlso: ['Midi Converters'] +}, +{ + name: 'ampmidicurve', + type: 'opcode', + category: 'Real-time MIDI:Converters', + description: 'Maps an input MIDI velocity number to an output gain factor with a maximum value of 1, modifying the output gain by a dynamic range and a shaping exponent.', + syntax: 'igain = ampmidicurve(ivelocity, idynamicrange, iexponent)\n kgain = ampmidicurve(kvelocity, kdynamicrange, kexponent)', + example: '--8<-- "examples/ampmidicurve-modern.csd"', + parameters: [ + { + name: 'imidivelocity', + description: 'MIDI velocity number, ranging from 0 through 127.', + type: 'initialization' + }, + { + name: 'idynamicrange', + description: 'Intended dynamic range of gain, from 0 through 1.', + type: 'initialization' + }, + { + name: 'iexponent', + description: 'Exponent applied to shape the gain response curve, 1 or greater.', + type: 'initialization' + }, + { + name: 'kmidivelocity', + description: 'MIDI velocity number, ranging from 0 through 127.', + type: 'performance' + }, + { + name: 'kdynamicrange', + description: 'Intended dynamic range of gain, from 0 through 1.', + type: 'performance' + }, + { + name: 'kexponent', + description: 'Exponent applied to shape the gain response curve, 1 or greater.', + type: 'performance' + }, + ], + seeAlso: ['Midi Converters'] +}, +{ + name: 'ampmidid', + type: 'opcode', + category: 'Real-time MIDI:Converters', + description: 'Musically map MIDI velocity to peak amplitude within a specified dynamic range in decibels.', + syntax: 'iamplitude = ampmidid(ivelocity, idecibels)\n kamplitude = ampmidid(kvelocity, idecibels)', + example: '--8<-- "examples/ampmidid-modern.csd"', + parameters: [ + { + name: 'iamplitude', + description: 'Amplitude.', + type: 'initialization' + }, + { + name: 'ivelocity', + description: 'MIDI velocity number, ranging from 0 through 127.', + type: 'initialization' + }, + { + name: 'idecibels', + description: 'Desired dynamic range in decibels.', + type: 'initialization' + }, + { + name: 'kamplitude', + description: 'Amplitude.', + type: 'performance' + }, + { + name: 'kvelocity', + description: 'MIDI velocity number, ranging from 0 through 127.', + type: 'performance' + }, + ], + seeAlso: ['Midi Converters'] +}, +{ + name: 'cpsmidi', + type: 'opcode', + category: 'Real-time MIDI:Converters', + description: 'Get the note number of the current MIDI event, expressed in cycles-per-second.', + syntax: 'icps = cpsmidi()', + example: '--8<-- "examples/cpsmidi.csd"', + seeAlso: ['Midi Converters'] +}, +{ + name: 'cpsmidib', + type: 'opcode', + category: 'Real-time MIDI:Converters', + description: 'Get the note number of the current MIDI event and modify it by the current pitch-bend value, express it in cycles-per-second.', + syntax: 'icps = cpsmidib([irange])\n kcps = cpsmidib([irange])', + example: '--8<-- "examples/cpsmidib.csd"', + rates: ['k-rate'], + seeAlso: ['Midi Converters'] +}, +{ + name: 'cpstmid', + type: 'opcode', + category: 'Real-time MIDI:Converters', + description: 'Get a MIDI note number (allows customized micro-tuning scales).', + syntax: 'icps = cpstmid(ifn)', + example: '--8<-- "examples/cpstmid.csd"', + rates: ['i-rate'], + parameters: [ + { + name: 'ifn', + description: 'function table containing the parameters (_numgrades_, _interval_, _basefreq_, _basekeymidi_) and the tuning ratios.', + type: 'initialization' + }, + { + name: 'numgrades', + description: 'the number of grades of the micro-tuning scale 2. _interval_ -- the frequency range covered before repeating the grade ratios, for example 2 for one octave, 1.5 for a fifth etc. 3. _basefreq_ -- the base frequency of the scale in Hz 4. _basekeymidi_ -- the MIDI note number to which _basefreq_ is assigned unmodified', + type: 'performance' + }, + ], + seeAlso: ['Midi Converters'] +}, +{ + name: 'octmidi', + type: 'opcode', + category: 'Real-time MIDI:Converters', + description: 'Get the note number, in octave-point-decimal units, of the current MIDI event.', + syntax: 'ioct = octmidi()', + example: '--8<-- "examples/octmidi.csd"', + seeAlso: ['Midi Converters'] +}, +{ + name: 'octmidib', + type: 'opcode', + category: 'Real-time MIDI:Converters', + description: 'Get the note number of the current MIDI event and modify it by the current pitch-bend value, express it in octave-point-decimal.', + syntax: 'ioct = octmidib([irange])\n koct = octmidib([irange])', + example: '--8<-- "examples/octmidib.csd"', + seeAlso: ['Midi Converters'] +}, +{ + name: 'pchmidi', + type: 'opcode', + category: 'Real-time MIDI:Converters', + description: 'Get the note number of the current MIDI event, expressed in pitch-class units.', + syntax: 'ipch = pchmidi()', + example: '--8<-- "examples/pchmidi.csd"', + seeAlso: ['Midi Converters'] +}, +{ + name: 'pchmidib', + type: 'opcode', + category: 'Real-time MIDI:Converters', + description: 'Get the note number of the current MIDI event and modify it by the current pitch-bend value, express it in pitch-class units.', + syntax: 'ipch = pchmidib([irange])\n kpch = pchmidib([irange])', + example: '--8<-- "examples/pchmidib.csd"', + seeAlso: ['Midi Converters'] +}, +] diff --git a/src/lib/csound-reference/real-time-midi-event-extenders.ts b/src/lib/csound-reference/real-time-midi-event-extenders.ts new file mode 100644 index 0000000..8c87ba3 --- /dev/null +++ b/src/lib/csound-reference/real-time-midi-event-extenders.ts @@ -0,0 +1,36 @@ +import type { CsoundReference } from './types' + +// Real-time MIDI:Event Extenders +export const realTimeMidiEventExtenders: CsoundReference[] = [ +{ + name: 'lastcycle', + type: 'opcode', + category: 'Real-time MIDI:Event Extenders', + description: 'Indicates whether an event is in its last performance cycle.', + syntax: 'kflag = lastcycle()', + example: '--8<-- "examples/lastcycle.csd"', + parameters: [ + { + name: 'kflag', + description: 'indicates whether the note is in its _last cycle_. (1 if this the last cycle, otherwise 0)', + type: 'performance' + }, + ], + seeAlso: ['Event Extenders'] +}, +{ + name: 'release', + type: 'opcode', + category: 'Real-time MIDI:Event Extenders', + description: 'Indicates whether a note is in its _release_ stage.', + syntax: 'kflag = release()', + parameters: [ + { + name: 'kflag', + description: 'indicates whether the note is in its _release_ stage. (1 if a note off is received, otherwise 0)', + type: 'performance' + }, + ], + seeAlso: ['Event Extenders'] +}, +] diff --git a/src/lib/csound-reference/real-time-midi-generic-i-o.ts b/src/lib/csound-reference/real-time-midi-generic-i-o.ts new file mode 100644 index 0000000..035ce05 --- /dev/null +++ b/src/lib/csound-reference/real-time-midi-generic-i-o.ts @@ -0,0 +1,76 @@ +import type { CsoundReference } from './types' + +// Real-time MIDI:Generic I/O +export const realTimeMidiGenericIO: CsoundReference[] = [ +{ + name: 'midiin', + type: 'opcode', + category: 'Real-time MIDI:Generic I/O', + description: 'Returns a generic MIDI message received by the MIDI IN port.', + syntax: 'kstatus, kchan, kdata1, kdata2 = midiin()', + example: '--8<-- "examples/midiin.csd"', + parameters: [ + { + name: 'kstatus', + description: 'the type of MIDI message. Can be:', + type: 'performance' + }, + { + name: 'kchan', + description: 'MIDI channel (1-16 if only one input port is used, higher if channel is port mapped.)', + type: 'performance' + }, + { + name: 'kdata1', + description: 'message-dependent data values', + type: 'performance' + }, + { + name: 'kdata2', + description: 'message-dependent data values', + type: 'performance' + }, + ], + seeAlso: ['MIDI input and Initialization', 'Generic Input and Output'] +}, +{ + name: 'midiout', + type: 'opcode', + category: 'Real-time MIDI:Generic I/O', + description: 'Sends a generic MIDI message to the MIDI OUT port.', + syntax: 'midiout(kstatus, kchan, kdata1, kdata2)', + example: '--8<-- "examples/midiout.csd"', + parameters: [ + { + name: 'kstatus', + description: 'the type of MIDI message. Can be:', + type: 'performance' + }, + { + name: 'kchan', + description: 'MIDI channel (1-16)', + type: 'performance' + }, + { + name: 'kdata1', + description: 'message-dependent data values', + type: 'performance' + }, + { + name: 'kdata2', + description: 'message-dependent data values', + type: 'performance' + }, + ], + seeAlso: ['MIDI Message Output', 'Generic Input and Output'] +}, +{ + name: 'midiout_i', + type: 'opcode', + category: 'Real-time MIDI:Generic I/O', + description: 'Sends a generic MIDI message to the MIDI OUT port.', + syntax: 'midiout_i(istatus, ichan, idata1, idata2)', + example: '--8<-- "examples/midiout_i.csd"', + seeAlso: ['MIDI Message Output', 'Generic Input and Output'] +}, +] diff --git a/src/lib/csound-reference/real-time-midi-input.ts b/src/lib/csound-reference/real-time-midi-input.ts new file mode 100644 index 0000000..dce35c6 --- /dev/null +++ b/src/lib/csound-reference/real-time-midi-input.ts @@ -0,0 +1,692 @@ +import type { CsoundReference } from './types' + +// Real-time MIDI:Input +export const realTimeMidiInput: CsoundReference[] = [ +{ + name: 'aftouch', + type: 'opcode', + category: 'Real-time MIDI:Input', + description: 'Get the current after-touch value for this channel.', + syntax: 'kaft = aftouch([imin] [, imax])', + example: '--8<-- "examples/aftouch-modern.csd"', + seeAlso: ['MIDI input and Initialization'] +}, +{ + name: 'chanctrl', + type: 'opcode', + category: 'Real-time MIDI:Input', + description: 'Get the current value of a MIDI channel controller and optionally map it onto specified range.', + syntax: 'ival = chanctrl(ichnl, ictlno [, ilow] [, ihigh])\n kval = chanctrl(ichnl, ictlno [, ilow] [, ihigh])', + example: '--8<-- "examples/chanctrl-modern.csd"', + parameters: [ + { + name: 'ichnl', + description: 'the MIDI channel (1-16).', + type: 'initialization' + }, + { + name: 'ictlno', + description: 'the MIDI controller number (0-127).', + type: 'initialization' + }, + { + name: 'ilow', + description: 'low and high ranges for mapping', + type: 'initialization' + }, + { + name: 'ihigh', + description: 'low and high ranges for mapping', + type: 'initialization' + }, + ], + seeAlso: ['MIDI input and Initialization'] +}, +{ + name: 'ctrl14', + type: 'opcode', + category: 'Real-time MIDI:Input', + description: 'Allows a floating-point 14-bit MIDI signal scaled with a minimum and a maximum range.', + syntax: 'idest = ctrl14(ichan, ictlno1, ictlno2, imin, imax [, ifn])\n kdest = ctrl14(ichan, ictlno1, ictlno2, kmin, kmax [, ifn])', + example: '--8<-- "examples/ctrl14.csd"', + rates: ['i-rate'], + parameters: [ + { + name: 'idest', + description: 'output signal', + type: 'initialization' + }, + { + name: 'ichan', + description: 'MIDI channel number (1-16)', + type: 'initialization' + }, + { + name: 'ictln1o', + description: 'most-significant byte controller number (0-127)', + type: 'initialization' + }, + { + name: 'ictlno2', + description: 'least-significant byte controller number (0-127)', + type: 'initialization' + }, + { + name: 'imin', + description: 'user-defined minimum floating-point value of output', + type: 'initialization' + }, + { + name: 'imax', + description: 'user-defined maximum floating-point value of output', + type: 'initialization' + }, + { + name: 'kdest', + description: 'output signal', + type: 'performance' + }, + { + name: 'kmin', + description: 'user-defined minimum floating-point value of output', + type: 'performance' + }, + { + name: 'kmax', + description: 'user-defined maximum floating-point value of output', + type: 'performance' + }, + ], + seeAlso: ['MIDI input and Initialization'] +}, +{ + name: 'ctrl21', + type: 'opcode', + category: 'Real-time MIDI:Input', + description: 'Allows a floating-point 21-bit MIDI signal scaled with a minimum and a maximum range.', + syntax: 'idest = ctrl21(ichan, ictlno1, ictlno2, ictlno3, imin, imax [, ifn])\n kdest = ctrl21(ichan, ictlno1, ictlno2, ictlno3, kmin, kmax [, ifn])', + example: '--8<-- "examples/ctrl21.csd"', + rates: ['i-rate'], + parameters: [ + { + name: 'idest', + description: 'output signal', + type: 'initialization' + }, + { + name: 'ichan', + description: 'MIDI channel number (1-16)', + type: 'initialization' + }, + { + name: 'ictlno1', + description: 'most-significant byte controller number (0-127)', + type: 'initialization' + }, + { + name: 'ictlno2', + description: 'mid-significant byte controller number (0-127)', + type: 'initialization' + }, + { + name: 'ictlno3', + description: 'least-significant byte controller number (0-127)', + type: 'initialization' + }, + { + name: 'imin', + description: 'user-defined minimum floating-point value of output', + type: 'initialization' + }, + { + name: 'imax', + description: 'user-defined maximum floating-point value of output', + type: 'initialization' + }, + { + name: 'kdest', + description: 'output signal', + type: 'performance' + }, + { + name: 'kmin', + description: 'user-defined minimum floating-point value of output', + type: 'performance' + }, + { + name: 'kmax', + description: 'user-defined maximum floating-point value of output', + type: 'performance' + }, + ], + seeAlso: ['MIDI input and Initialization'] +}, +{ + name: 'ctrl7', + type: 'opcode', + category: 'Real-time MIDI:Input', + description: 'Allows a floating-point 7-bit MIDI signal scaled with a minimum and a maximum range.', + syntax: 'idest = ctrl7(ichan, ictlno, imin, imax [, ifn])\n kdest = ctrl7(ichan, ictlno, kmin, kmax [, ifn])\n adest = ctrl7(ichan, ictlno, kmin, kmax [, ifn] [, icutoff])', + example: '--8<-- "examples/ctrl7.csd"', + rates: ['i-rate'], + parameters: [ + { + name: 'idest', + description: 'output signal', + type: 'initialization' + }, + { + name: 'ichan', + description: 'MIDI channel (1-16)', + type: 'initialization' + }, + { + name: 'ictlno', + description: 'MIDI controller number (0-127)', + type: 'initialization' + }, + { + name: 'imin', + description: 'user-defined minimum floating-point value of output', + type: 'initialization' + }, + { + name: 'imax', + description: 'user-defined maximum floating-point value of output', + type: 'initialization' + }, + { + name: 'kdest', + description: 'output signal', + type: 'performance' + }, + { + name: 'adest', + description: 'output signal', + type: 'performance' + }, + { + name: 'kmin', + description: 'user-defined minimum floating-point value of output', + type: 'performance' + }, + { + name: 'kmax', + description: 'user-defined maximum floating-point value of output', + type: 'performance' + }, + ], + seeAlso: ['MIDI input and Initialization'] +}, +{ + name: 'ctrlinit', + type: 'opcode', + category: 'Real-time MIDI:Input', + description: 'Sets the initial values for a set of MIDI controllers.', + syntax: 'ctrlinit(ichnl, ictlno1, ival1 [, ictlno2] [, ival2] [, ictlno3] \\\n [, ival3] [,...ival32])', + example: '--8<-- "examples/ctrlinit.csd"', + parameters: [ + { + name: 'ichnl', + description: 'MIDI channel number (1-16)', + type: 'initialization' + }, + ], + seeAlso: ['MIDI input and Initialization', 'Orchestra Header Statements'] +}, +{ + name: 'ctrlpreset', + type: 'opcode', + category: 'Real-time MIDI:Input', + description: 'Defines a preset for MIDI controllers.', + syntax: 'kpreset = ctrlpreset(ktag, kchnl, kctlno1, [kctlno2] [, kctlno3] ...)', + example: '--8<-- "examples/ctrls.csd"', + parameters: [ + { + name: 'kpreset', + description: 'the numeric tag for where the preset it stored. If ktag is not zero kpreset will be the same as ktag.', + type: 'performance' + }, + { + name: 'ktag', + description: 'the tag for this preset; either a strictly positive integer or zero if the system is to allocate an unused preset.', + type: 'performance' + }, + { + name: 'kchanl', + description: 'the MIDI channel to which the preset refers.', + type: 'performance' + }, + ], + seeAlso: ['MIDI input and Initialization'] +}, +{ + name: 'ctrlprint', + type: 'opcode', + category: 'Real-time MIDI:Input', + description: 'Print the saved values of MIDI controllers from an array to the console or a file.', + syntax: 'ctrlprint(kcont[][, Sfile])', + example: '--8<-- "examples/ctrls.csd"', + parameters: [ + { + name: 'Sfile', + description: 'File name to receive the values. If omitted it writes to the console.', + type: 'initialization' + }, + { + name: 'kcont', + description: 'the array of controls as saved by _ctrlsave_.', + type: 'performance' + }, + ], + seeAlso: ['MIDI input and Initialization'] +}, +{ + name: 'ctrlprintpresets', + type: 'opcode', + category: 'Real-time MIDI:Input', + description: 'Prints the current collection of presets for MIDI controllers in a format that can be used in an orchestra, to the console or a file.', + syntax: 'ctrlprintpresets([Sfilenam])', + example: '--8<-- "examples/ctrls.csd"', + parameters: [ + { + name: 'Sfilename', + description: '(optional) file to which to print. If omitted it uses the current output.', + type: 'performance' + }, + ], + seeAlso: ['MIDI input and Initialization'] +}, +{ + name: 'ctrlsave', + type: 'opcode', + category: 'Real-time MIDI:Input', + description: 'Recovers the current values of MIDI controllers to a k-array.', + syntax: 'kconnt[] = ctrlsave(ichnl, ictlno1, [ictlno2] [, ictlno3] ...)', + example: '--8<-- "examples/ctrls.csd"', + parameters: [ + { + name: 'ichnl', + description: 'MIDI channel number (1-16)', + type: 'initialization' + }, + ], + seeAlso: ['MIDI input and Initialization'] +}, +{ + name: 'ctrlselect', + type: 'opcode', + category: 'Real-time MIDI:Input', + description: 'Loads a preset of values for MIDI controllers from a previous ctrlpreset call.', + syntax: 'ctrlselect(kpre)', + example: '--8<-- "examples/ctrls.csd"', + parameters: [ + { + name: 'kpre', + description: 'the numeric tag for the preset, as returned by ctrlpreset.', + type: 'performance' + }, + ], + seeAlso: ['MIDI input and Initialization'] +}, +{ + name: 'initc14', + type: 'opcode', + category: 'Real-time MIDI:Input', + description: 'Initializes the controllers used to create a 14-bit MIDI value.', + syntax: 'initc14(ichan, ictlno1, ictlno2, ivalue)', + parameters: [ + { + name: 'ichan', + description: 'MIDI channel (1-16)', + type: 'initialization' + }, + { + name: 'ictlno1', + description: 'most significant byte controller number (0-127)', + type: 'initialization' + }, + { + name: 'ictlno2', + description: 'least significant byte controller number (0-127)', + type: 'initialization' + }, + { + name: 'ivalue', + description: 'floating point value (must be within 0 to 1)', + type: 'initialization' + }, + ], + seeAlso: ['MIDI input and Initialization'] +}, +{ + name: 'initc21', + type: 'opcode', + category: 'Real-time MIDI:Input', + description: 'Initializes the controllers used to create a 21-bit MIDI value.', + syntax: 'initc21(ichan, ictlno1, ictlno2, ictlno3, ivalue)', + parameters: [ + { + name: 'ichan', + description: 'MIDI channel (1-16)', + type: 'initialization' + }, + { + name: 'ictlno1', + description: 'most significant byte controller number (0-127)', + type: 'initialization' + }, + { + name: 'ictlno2', + description: 'medium significant byte controller number (0-127)', + type: 'initialization' + }, + { + name: 'ictlno3', + description: 'least significant byte controller number (0-127)', + type: 'initialization' + }, + { + name: 'ivalue', + description: 'floating point value (must be within 0 to 1)', + type: 'initialization' + }, + ], + seeAlso: ['MIDI input and Initialization'] +}, +{ + name: 'initc7', + type: 'opcode', + category: 'Real-time MIDI:Input', + description: 'Initializes the controller used to create a 7-bit MIDI value.', + syntax: 'initc7(ichan, ictlno, ivalue)', + example: '--8<-- "examples/initc7.csd"', + parameters: [ + { + name: 'ichan', + description: 'MIDI channel (1-16)', + type: 'initialization' + }, + { + name: 'ictlno', + description: 'controller number (0-127)', + type: 'initialization' + }, + { + name: 'ivalue', + description: 'floating point value (must be within 0 to 1)', + type: 'initialization' + }, + ], + seeAlso: ['MIDI input and Initialization'] +}, +{ + name: 'massign', + type: 'opcode', + category: 'Real-time MIDI:Input', + description: 'Assigns a MIDI channel number to a Csound instrument.', + syntax: 'massign(ichnl, insnum[, ireset])\n massign(ichnl, "insname"[, ireset])', + example: '--8<-- "examples/massign.csd"', + parameters: [ + { + name: 'ichnl', + description: 'MIDI channel number (1-16).', + type: 'initialization' + }, + { + name: 'insnum', + description: 'Csound orchestra instrument number. If zero or negative, the channel is muted (i.e. it does not trigger a csound instrument, though information will still be received by opcodes like [midiin](../opcodes/midiin.md)).', + type: 'initialization' + }, + { + name: 'ireset', + description: 'If non-zero resets the controllers; default is to reset.', + type: 'initialization' + }, + ], + seeAlso: ['MIDI input and Initialization', 'Orchestra Header Statements'] +}, +{ + name: 'midic14', + type: 'opcode', + category: 'Real-time MIDI:Input', + description: 'Allows a floating-point 14-bit MIDI signal scaled with a minimum and a maximum range.', + syntax: 'idest = midic14(ictlno1, ictlno2, imin, imax [, ifn])\n kdest = midic14(ictlno1, ictlno2, kmin, kmax [, ifn])', + example: '--8<-- "examples/midic14.csd"', + rates: ['i-rate'], + parameters: [ + { + name: 'idest', + description: 'output signal', + type: 'initialization' + }, + { + name: 'ictln1o', + description: 'most-significant byte controller number (0-127)', + type: 'initialization' + }, + { + name: 'ictlno2', + description: 'least-significant byte controller number (0-127)', + type: 'initialization' + }, + { + name: 'imin', + description: 'user-defined minimum floating-point value of output', + type: 'initialization' + }, + { + name: 'imax', + description: 'user-defined maximum floating-point value of output', + type: 'initialization' + }, + { + name: 'kdest', + description: 'output signal', + type: 'performance' + }, + { + name: 'kmin', + description: 'user-defined minimum floating-point value of output', + type: 'performance' + }, + { + name: 'kmax', + description: 'user-defined maximum floating-point value of output', + type: 'performance' + }, + ], + seeAlso: ['MIDI input and Initialization'] +}, +{ + name: 'midic21', + type: 'opcode', + category: 'Real-time MIDI:Input', + description: 'Allows a floating-point 21-bit MIDI signal scaled with a minimum and a maximum range.', + syntax: 'idest = midic21(ictlno1, ictlno2, ictlno3, imin, imax [, ifn])\n kdest = midic21(ictlno1, ictlno2, ictlno3, kmin, kmax [, ifn])', + example: '--8<-- "examples/midic21.csd"', + rates: ['i-rate'], + parameters: [ + { + name: 'idest', + description: 'output signal', + type: 'initialization' + }, + { + name: 'ictln1o', + description: 'most-significant byte controller number (0-127)', + type: 'initialization' + }, + { + name: 'ictlno2', + description: 'mid-significant byte controller number (0-127)', + type: 'initialization' + }, + { + name: 'ictlno3', + description: 'least-significant byte controller number (0-127)', + type: 'initialization' + }, + { + name: 'imin', + description: 'user-defined minimum floating-point value of output', + type: 'initialization' + }, + { + name: 'imax', + description: 'user-defined maximum floating-point value of output', + type: 'initialization' + }, + { + name: 'kdest', + description: 'output signal', + type: 'performance' + }, + { + name: 'kmin', + description: 'user-defined minimum floating-point value of output', + type: 'performance' + }, + { + name: 'kmax', + description: 'user-defined maximum floating-point value of output', + type: 'performance' + }, + ], + seeAlso: ['MIDI input and Initialization'] +}, +{ + name: 'midic7', + type: 'opcode', + category: 'Real-time MIDI:Input', + description: 'Allows a floating-point 7-bit MIDI signal scaled with a minimum and a maximum range.', + syntax: 'idest = midic7(ictlno, imin, imax [, ifn])\n kdest = midic7(ictlno, kmin, kmax [, ifn])', + example: '--8<-- "examples/midic7.csd"', + rates: ['i-rate'], + parameters: [ + { + name: 'idest', + description: 'output signal', + type: 'initialization' + }, + { + name: 'ictlno', + description: 'MIDI controller number (0-127)', + type: 'initialization' + }, + { + name: 'imin', + description: 'user-defined minimum floating-point value of output', + type: 'initialization' + }, + { + name: 'imax', + description: 'user-defined maximum floating-point value of output', + type: 'initialization' + }, + { + name: 'kdest', + description: 'output signal', + type: 'performance' + }, + { + name: 'kmin', + description: 'user-defined minimum floating-point value of output', + type: 'performance' + }, + { + name: 'kmax', + description: 'user-defined maximum floating-point value of output', + type: 'performance' + }, + ], + seeAlso: ['MIDI input and Initialization'] +}, +{ + name: 'midictrl', + type: 'opcode', + category: 'Real-time MIDI:Input', + description: 'Get the current value (0-127) of a specified MIDI controller.', + syntax: 'ival = midictrl(inum [, imin] [, imax])\n kval = midictrl(inum [, imin] [, imax])', + example: '--8<-- "examples/midictrl.csd"', + parameters: [ + { + name: 'inum', + description: 'MIDI controller number (0-127)', + type: 'initialization' + }, + { + name: 'imin', + description: 'set minimum and maximum limits on values obtained.', + type: 'initialization' + }, + { + name: 'imax', + description: 'set minimum and maximum limits on values obtained.', + type: 'initialization' + }, + ], + seeAlso: ['MIDI input and Initialization'] +}, +{ + name: 'notnum', + type: 'opcode', + category: 'Real-time MIDI:Input', + description: 'Get a note number from a MIDI event.', + syntax: 'ival = notnum()', + example: '--8<-- "examples/notnum.csd"', + seeAlso: ['MIDI input and Initialization'] +}, +{ + name: 'pchbend', + type: 'opcode', + category: 'Real-time MIDI:Input', + description: 'Get the current pitch-bend value for this channel.', + syntax: 'ibend = pchbend([imin] [, imax])\n kbend = pchbend([imin] [, imax])', + example: '--8<-- "examples/pchbend.csd"', + seeAlso: ['MIDI input and Initialization'] +}, +{ + name: 'pgmassign', + type: 'opcode', + category: 'Real-time MIDI:Input', + description: 'Assigns an instrument number to a specified MIDI program.', + syntax: 'pgmassign(ipgm, inst[, ichn])\n pgmassign(ipgm, "insname"[, ichn])', + example: '--8<-- "examples/pgmassign.csd"', + parameters: [ + { + name: 'ipgm', + description: 'MIDI program number (1 to 128). A value of zero selects all programs.', + type: 'initialization' + }, + { + name: 'inst', + description: 'instrument number. If set to zero, or negative, MIDI program changes to _ipgm_ are ignored. Currently, assignment to an instrument that does not exist has the same effect. This may be changed in a later release to print an error message.', + type: 'initialization' + }, + ], + seeAlso: ['MIDI input and Initialization', 'Orchestra Header Statements'] +}, +{ + name: 'polyaft', + type: 'opcode', + category: 'Real-time MIDI:Input', + description: 'Returns the polyphonic after-touch pressure of the selected note number, optionally mapped to an user-specified range.', + syntax: 'ires = polyaft(inote [, ilow] [, ihigh])\n kres = polyaft(inote [, ilow] [, ihigh])', + example: '--8<-- "examples/polyaft.csd"', + rates: ['k-rate', 'i-rate'], + parameters: [ + { + name: 'inote', + description: 'note number. Normally set to the value returned by [notnum](../opcodes/notnum.md)', + type: 'initialization' + }, + { + name: 'kres', + description: 'polyphonic pressure (aftertouch).', + type: 'performance' + }, + ], + seeAlso: ['MIDI input and Initialization'] +}, +] diff --git a/src/lib/csound-reference/real-time-midi-midi-score-interoperability.ts b/src/lib/csound-reference/real-time-midi-midi-score-interoperability.ts new file mode 100644 index 0000000..b8ba4d5 --- /dev/null +++ b/src/lib/csound-reference/real-time-midi-midi-score-interoperability.ts @@ -0,0 +1,237 @@ +import type { CsoundReference } from './types' + +// Real-time MIDI:MIDI/Score Interoperability +export const realTimeMidiMidiScoreInteroperability: CsoundReference[] = [ +{ + name: 'midichannelaftertouch', + type: 'opcode', + category: 'Real-time MIDI:MIDI/Score Interoperability', + description: 'Gets a MIDI channel\'s aftertouch value.', + syntax: 'midichannelaftertouch(xchannelaftertouch [, ilow] [, ihigh])', + example: '--8<-- "examples/midichannelaftertouch.csd"', + parameters: [ + { + name: 'xchannelaftertouch', + description: 'returns the MIDI channel aftertouch during MIDI activation, remains unchanged otherwise.', + type: 'performance' + }, + ], + seeAlso: ['MIDI/Score Interoperability'] +}, +{ + name: 'midichn', + type: 'opcode', + category: 'Real-time MIDI:MIDI/Score Interoperability', + description: 'Returns the MIDI channel number (1 - 16) from which the note was activated.', + syntax: 'ichn = midichn()', + example: '--8<-- "examples/midichn.csd"', + parameters: [ + { + name: 'ichn', + description: 'channel number. If the current note was activated from score, it is set to zero.', + type: 'initialization' + }, + ], + seeAlso: ['MIDI input and Initialization', 'MIDI/Score Interoperability'] +}, +{ + name: 'midicontrolchange', + type: 'opcode', + category: 'Real-time MIDI:MIDI/Score Interoperability', + description: 'Gets a MIDI control change value.', + syntax: 'midicontrolchange(xcontroller, xcontrollervalue [, ilow] [, ihigh])', + example: '--8<-- "examples/midicontrolchange.csd"', + parameters: [ + { + name: 'xcontroller', + description: 'specifies the MIDI controller number (0-127) to read from.', + type: 'performance' + }, + { + name: 'xcontrollervalue', + description: 'returns the value of the MIDI controller during MIDI activation, remains unchanged otherwise.', + type: 'performance' + }, + ], + seeAlso: ['MIDI/Score Interoperability'] +}, +{ + name: 'mididefault', + type: 'opcode', + category: 'Real-time MIDI:MIDI/Score Interoperability', + description: 'Changes values, depending on MIDI activation.', + syntax: 'mididefault(xdefault, xvalue)', + example: '--8<-- "examples/mididefault.csd"', + parameters: [ + { + name: 'xdefault', + description: 'specifies a default value that will be used during MIDI activation.', + type: 'performance' + }, + { + name: 'xvalue', + description: 'overwritten by _xdefault_ during MIDI activation, remains unchanged otherwise.', + type: 'performance' + }, + ], + seeAlso: ['MIDI/Score Interoperability'] +}, +{ + name: 'midinoteoff', + type: 'opcode', + category: 'Real-time MIDI:MIDI/Score Interoperability', + description: 'Gets a MIDI noteoff value.', + syntax: 'midinoteoff(xkey, xvelocity)', + example: '--8<-- "examples/midinoteoff.csd"', + parameters: [ + { + name: 'xkey', + description: 'returns MIDI key during MIDI activation, remains unchanged otherwise.', + type: 'performance' + }, + { + name: 'xvelocity', + description: 'returns MIDI velocity during MIDI activation, remains unchanged otherwise.', + type: 'performance' + }, + ], + seeAlso: ['MIDI/Score Interoperability'] +}, +{ + name: 'midinoteoncps', + type: 'opcode', + category: 'Real-time MIDI:MIDI/Score Interoperability', + description: 'Gets a MIDI note number as a cycles-per-second frequency.', + syntax: 'midinoteoncps(xcps, xvelocity)', + example: '--8<-- "examples/midinoteoncps.csd"', + parameters: [ + { + name: 'xcps', + description: 'returns MIDI key translated to cycles per second during MIDI activation, remains unchanged otherwise.', + type: 'performance' + }, + { + name: 'xvelocity', + description: 'returns MIDI velocity during MIDI activation, remains unchanged otherwise.', + type: 'performance' + }, + ], + seeAlso: ['MIDI/Score Interoperability'] +}, +{ + name: 'midinoteonkey', + type: 'opcode', + category: 'Real-time MIDI:MIDI/Score Interoperability', + description: 'Gets a MIDI note number value.', + syntax: 'midinoteonkey(xkey, xvelocity)', + example: '--8<-- "examples/midinoteonkey.csd"', + parameters: [ + { + name: 'xkey', + description: 'returns MIDI key during MIDI activation, remains unchanged otherwise.', + type: 'performance' + }, + { + name: 'xvelocity', + description: 'returns MIDI velocity during MIDI activation, remains unchanged otherwise.', + type: 'performance' + }, + ], + seeAlso: ['MIDI/Score Interoperability'] +}, +{ + name: 'midinoteonoct', + type: 'opcode', + category: 'Real-time MIDI:MIDI/Score Interoperability', + description: 'Gets a MIDI note number value as octave-point-decimal value.', + syntax: 'midinoteonoct(xoct, xvelocity)', + example: '--8<-- "examples/midinoteonoct.csd"', + parameters: [ + { + name: 'xoct', + description: 'returns MIDI key translated to linear octaves during MIDI activation, remains unchanged otherwise.', + type: 'performance' + }, + { + name: 'xvelocity', + description: 'returns MIDI velocity during MIDI activation, remains unchanged otherwise.', + type: 'performance' + }, + ], + seeAlso: ['MIDI/Score Interoperability'] +}, +{ + name: 'midinoteonpch', + type: 'opcode', + category: 'Real-time MIDI:MIDI/Score Interoperability', + description: 'Gets a MIDI note number as a pitch-class value.', + syntax: 'midinoteonpch(xpch, xvelocity)', + example: '--8<-- "examples/midinoteonpch.csd"', + parameters: [ + { + name: 'xpch', + description: 'returns MIDI key translated to octave.pch during MIDI activation, remains unchanged otherwise.', + type: 'performance' + }, + { + name: 'xvelocity', + description: 'returns MIDI velocity during MIDI activation, remains unchanged otherwise.', + type: 'performance' + }, + ], + seeAlso: ['MIDI/Score Interoperability'] +}, +{ + name: 'midipitchbend', + type: 'opcode', + category: 'Real-time MIDI:MIDI/Score Interoperability', + description: 'Gets a MIDI pitchbend value.', + syntax: 'midipitchbend(xpitchbend [, ilow] [, ihigh])', + example: '--8<-- "examples/midipitchbend.csd"', + parameters: [ + { + name: 'xpitchbend', + description: 'returns the MIDI pitch bend during MIDI activation, remains unchanged otherwise.', + type: 'performance' + }, + ], + seeAlso: ['MIDI/Score Interoperability'] +}, +{ + name: 'midipolyaftertouch', + type: 'opcode', + category: 'Real-time MIDI:MIDI/Score Interoperability', + description: 'Gets a MIDI polyphonic aftertouch value.', + syntax: 'midipolyaftertouch(xpolyaftertouch, xkey [, ilow] [, ihigh])', + example: '--8<-- "examples/midipolyaftertouch.csd"', + parameters: [ + { + name: 'xpolyaftertouch', + description: 'returns MIDI polyphonic aftertouch of the selected note during MIDI activation, remains unchanged otherwise.', + type: 'performance' + }, + { + name: 'xkey', + description: 'specifies the MIDI key to read from. It normally should be set to the note number that the instrument instance is playing.', + type: 'performance' + }, + ], + seeAlso: ['MIDI/Score Interoperability'] +}, +{ + name: 'midiprogramchange', + type: 'opcode', + category: 'Real-time MIDI:MIDI/Score Interoperability', + description: 'Gets a MIDI program change value.', + syntax: 'midiprogramchange(xprogram)', + example: '--8<-- "examples/midiprogramchange.csd"', + parameters: [ + { + name: 'xprogram', + description: 'returns the MIDI program change value during MIDI activation, remains unchanged otherwise.', + type: 'performance' + }, + ], + seeAlso: ['MIDI/Score Interoperability'] +}, +] diff --git a/src/lib/csound-reference/real-time-midi-note-output.ts b/src/lib/csound-reference/real-time-midi-note-output.ts new file mode 100644 index 0000000..0b31035 --- /dev/null +++ b/src/lib/csound-reference/real-time-midi-note-output.ts @@ -0,0 +1,241 @@ +import type { CsoundReference } from './types' + +// Real-time MIDI:Note Output +export const realTimeMidiNoteOutput: CsoundReference[] = [ +{ + name: 'midiarp', + type: 'opcode', + category: 'Real-time MIDI:Note Output', + description: 'Generates arpeggios based on currently held MIDI notes.', + syntax: 'kMidiNoteNum, kTrigger = midiarp(kRate[, kMode])', + example: '--8<-- "examples/midiarp.csd"', + parameters: [ + { + name: 'kRate', + description: 'sets the rate in cycles per second at which new notes will be generated.', + type: 'performance' + }, + { + name: 'kMode', + description: 'Optional. Sets the mode of the arpeggio. 0 for up and down, 1, for up, 2 for down, and 3 for random. If left out, it will default to mode 0, up and down.', + type: 'performance' + }, + { + name: 'kMideNoteNum', + description: 'the current note number in the arpeggio pattern.', + type: 'performance' + }, + { + name: 'kTrigger', + description: 'a metronomic pulse that can be used to trigger playback of the notes in the arpeggio. This signal will output a 1 followed by 0s on each cycle. The frequency is set using the _kRate_ input parameter.', + type: 'performance' + }, + ], + seeAlso: ['Note-on/Note-off Output'] +}, +{ + name: 'midion', + type: 'opcode', + category: 'Real-time MIDI:Note Output', + description: 'Generates MIDI note messages at k-rate.', + syntax: 'midion(kchn, knum, kvel)', + example: '--8<-- "examples/midion_simple.csd"', + parameters: [ + { + name: 'kchn', + description: 'MIDI channel number (1-16)', + type: 'performance' + }, + { + name: 'knum', + description: 'note number (0-127)', + type: 'performance' + }, + { + name: 'kvel', + description: 'velocity (0-127)', + type: 'performance' + }, + ], + seeAlso: ['Note-on/Note-off Output'] +}, +{ + name: 'midion2', + type: 'opcode', + category: 'Real-time MIDI:Note Output', + description: 'Sends noteon and noteoff messages to the MIDI OUT port when triggered by a value different than zero.', + syntax: 'midion2(kchn, knum, kvel, ktrig)', + example: '--8<-- "examples/midion2.csd"', + parameters: [ + { + name: 'kchn', + description: 'MIDI channel (1-16)', + type: 'performance' + }, + { + name: 'knum', + description: 'MIDI note number (0-127)', + type: 'performance' + }, + { + name: 'kvel', + description: 'note velocity (0-127)', + type: 'performance' + }, + { + name: 'ktrig', + description: 'trigger input signal (normally 0)', + type: 'performance' + }, + ], + seeAlso: ['Note-on/Note-off Output'] +}, +{ + name: 'moscil', + type: 'opcode', + category: 'Real-time MIDI:Note Output', + description: 'Sends a stream of the MIDI notes.', + syntax: 'moscil(kchn, knum, kvel, kdur, kpause)', + example: '--8<-- "examples/moscil.csd"', + parameters: [ + { + name: 'kchn', + description: 'MIDI channel number (1-16)', + type: 'performance' + }, + { + name: 'knum', + description: 'note number (0-127)', + type: 'performance' + }, + { + name: 'kvel', + description: 'velocity (0-127)', + type: 'performance' + }, + { + name: 'kdur', + description: 'note duration in seconds', + type: 'performance' + }, + { + name: 'kpause', + description: 'pause duration after each noteoff and before new note in seconds', + type: 'performance' + }, + ], + seeAlso: ['Note-on/Note-off Output'] +}, +{ + name: 'noteoff', + type: 'opcode', + category: 'Real-time MIDI:Note Output', + description: 'Send a noteoff message to the MIDI OUT port.', + syntax: 'noteoff(ichn, inum, ivel)', + parameters: [ + { + name: 'ichn', + description: 'MIDI channel number (1-16)', + type: 'initialization' + }, + { + name: 'inum', + description: 'note number (0-127)', + type: 'initialization' + }, + { + name: 'ivel', + description: 'velocity (0-127)', + type: 'initialization' + }, + ], + seeAlso: ['Note-on/Note-off Output'] +}, +{ + name: 'noteon', + type: 'opcode', + category: 'Real-time MIDI:Note Output', + description: 'Send a noteon message to the MIDI OUT port.', + syntax: 'noteon(ichn, inum, ivel)', + parameters: [ + { + name: 'ichn', + description: 'MIDI channel number (1-16)', + type: 'initialization' + }, + { + name: 'inum', + description: 'note number (0-127)', + type: 'initialization' + }, + { + name: 'ivel', + description: 'velocity (0-127)', + type: 'initialization' + }, + ], + seeAlso: ['Note-on/Note-off Output'] +}, +{ + name: 'noteondur', + type: 'opcode', + category: 'Real-time MIDI:Note Output', + description: 'Sends a noteon and a noteoff MIDI message both with the same channel, number and velocity.', + syntax: 'noteondur(ichn, inum, ivel, idur)', + example: '--8<-- "examples/noteondur.csd"', + parameters: [ + { + name: 'ichn', + description: 'MIDI channel number (1-16)', + type: 'initialization' + }, + { + name: 'inum', + description: 'note number (0-127)', + type: 'initialization' + }, + { + name: 'ivel', + description: 'velocity (0-127)', + type: 'initialization' + }, + { + name: 'idur', + description: 'how long, in seconds, this note should last.', + type: 'initialization' + }, + ], + seeAlso: ['Note-on/Note-off Output'] +}, +{ + name: 'noteondur2', + type: 'opcode', + category: 'Real-time MIDI:Note Output', + description: 'Sends a noteon and a noteoff MIDI message both with the same channel, number and velocity.', + syntax: 'noteondur2(ichn, inum, ivel, idur)', + example: '--8<-- "examples/noteondur2.csd"', + parameters: [ + { + name: 'ichn', + description: 'MIDI channel number (1-16)', + type: 'initialization' + }, + { + name: 'inum', + description: 'note number (0-127)', + type: 'initialization' + }, + { + name: 'ivel', + description: 'velocity (0-127)', + type: 'initialization' + }, + { + name: 'idur', + description: 'how long, in seconds, this note should last.', + type: 'initialization' + }, + ], + seeAlso: ['Note-on/Note-off Output'] +}, +] diff --git a/src/lib/csound-reference/real-time-midi-output.ts b/src/lib/csound-reference/real-time-midi-output.ts new file mode 100644 index 0000000..429710d --- /dev/null +++ b/src/lib/csound-reference/real-time-midi-output.ts @@ -0,0 +1,439 @@ +import type { CsoundReference } from './types' + +// Real-time MIDI:Output +export const realTimeMidiOutput: CsoundReference[] = [ +{ + name: 'nrpn', + type: 'opcode', + category: 'Real-time MIDI:Output', + description: 'Sends a NPRN (Non-Registered Parameter Number) message to the MIDI OUT port each time one of the input arguments changes.', + syntax: 'nrpn(kchan, kparmnum, kparmvalue)', + example: '--8<-- "examples/nrpn.csd"', + parameters: [ + { + name: 'kchan', + description: 'MIDI channel (1-16)', + type: 'performance' + }, + { + name: 'kparmnum', + description: 'number of NRPN parameter', + type: 'performance' + }, + { + name: 'kparmvalue', + description: 'value of NRPN parameter', + type: 'performance' + }, + ], + seeAlso: ['MIDI Message Output'] +}, +{ + name: 'outiat', + type: 'opcode', + category: 'Real-time MIDI:Output', + description: 'Sends MIDI aftertouch messages at i-rate.', + syntax: 'outiat(ichn, ivalue, imin, imax)', + example: '--8<-- "examples/outiat.csd"', + parameters: [ + { + name: 'ichn', + description: 'MIDI channel number (1-16)', + type: 'initialization' + }, + { + name: 'ivalue', + description: 'floating point value', + type: 'initialization' + }, + { + name: 'imin', + description: 'minimum floating point value (converted in MIDI integer value 0)', + type: 'initialization' + }, + { + name: 'imax', + description: 'maximum floating point value (converted in MIDI integer value 127 (7 bit))', + type: 'initialization' + }, + ], + seeAlso: ['MIDI Message Output'] +}, +{ + name: 'outic', + type: 'opcode', + category: 'Real-time MIDI:Output', + description: 'Sends MIDI controller output at i-rate.', + syntax: 'outic(ichn, inum, ivalue, imin, imax)', + example: '--8<-- "examples/outic.csd"', + parameters: [ + { + name: 'ichn', + description: 'MIDI channel number (1-16)', + type: 'initialization' + }, + { + name: 'inum', + description: 'controller number (0-127 for example 1 = ModWheel; 2 = BreathControl etc.)', + type: 'initialization' + }, + { + name: 'ivalue', + description: 'floating point value', + type: 'initialization' + }, + { + name: 'imin', + description: 'minimum floating point value (converted in MIDI integer value 0)', + type: 'initialization' + }, + { + name: 'imax', + description: 'maximum floating point value (converted in MIDI integer value 127 (7 bit))', + type: 'initialization' + }, + ], + seeAlso: ['MIDI Message Output'] +}, +{ + name: 'outic14', + type: 'opcode', + category: 'Real-time MIDI:Output', + description: 'Sends 14-bit MIDI controller output at i-rate.', + syntax: 'outic14(ichn, imsb, ilsb, ivalue, imin, imax)', + parameters: [ + { + name: 'ichn', + description: 'MIDI channel number (1-16)', + type: 'initialization' + }, + { + name: 'imsb', + description: 'most significant byte controller number when using 14-bit parameters (0-127)', + type: 'initialization' + }, + { + name: 'ilsb', + description: 'least significant byte controller number when using 14-bit parameters (0-127)', + type: 'initialization' + }, + { + name: 'ivalue', + description: 'floating point value', + type: 'initialization' + }, + { + name: 'imin', + description: 'minimum floating point value (converted in MIDI integer value 0)', + type: 'initialization' + }, + { + name: 'imax', + description: 'maximum floating point value (converted in MIDI integer value 16383 (14-bit))', + type: 'initialization' + }, + ], + seeAlso: ['MIDI Message Output'] +}, +{ + name: 'outipat', + type: 'opcode', + category: 'Real-time MIDI:Output', + description: 'Sends polyphonic MIDI aftertouch messages at i-rate.', + syntax: 'outipat(ichn, inotenum, ivalue, imin, imax)', + parameters: [ + { + name: 'ichn', + description: 'MIDI channel number (1-16)', + type: 'initialization' + }, + { + name: 'inotenum', + description: 'MIDI note number (used in polyphonic aftertouch messages)', + type: 'initialization' + }, + { + name: 'ivalue', + description: 'floating point value', + type: 'initialization' + }, + { + name: 'imin', + description: 'minimum floating point value (converted in MIDI integer value 0)', + type: 'initialization' + }, + { + name: 'imax', + description: 'maximum floating point value (converted in MIDI integer value 127 (7 bit))', + type: 'initialization' + }, + ], + seeAlso: ['MIDI Message Output'] +}, +{ + name: 'outipb', + type: 'opcode', + category: 'Real-time MIDI:Output', + description: 'Sends MIDI pitch-bend messages at i-rate.', + syntax: 'outipb(ichn, ivalue, imin, imax)', + example: '--8<-- "examples/outipb.csd"', + parameters: [ + { + name: 'ichn', + description: 'MIDI channel number (1-16)', + type: 'initialization' + }, + { + name: 'ivalue', + description: 'floating point value', + type: 'initialization' + }, + { + name: 'imin', + description: 'minimum floating point value (converted in MIDI integer value 0)', + type: 'initialization' + }, + { + name: 'imax', + description: 'maximum floating point value (converted in MIDI integer value 127 (7 bit))', + type: 'initialization' + }, + ], + seeAlso: ['MIDI Message Output'] +}, +{ + name: 'outipc', + type: 'opcode', + category: 'Real-time MIDI:Output', + description: 'Sends MIDI program change messages at i-rate.', + syntax: 'outipc(ichn, iprog, imin, imax)', + example: '--8<-- "examples/outipc.csd"', + parameters: [ + { + name: 'ichn', + description: 'MIDI channel number (1-16)', + type: 'initialization' + }, + { + name: 'iprog', + description: 'program change number in floating point', + type: 'initialization' + }, + { + name: 'imin', + description: 'minimum floating point value (converted in MIDI integer value 0)', + type: 'initialization' + }, + { + name: 'imax', + description: 'maximum floating point value (converted in MIDI integer value 127 (7 bit))', + type: 'initialization' + }, + ], + seeAlso: ['MIDI Message Output'] +}, +{ + name: 'outkat', + type: 'opcode', + category: 'Real-time MIDI:Output', + description: 'Sends MIDI aftertouch messages at k-rate.', + syntax: 'outkat(kchn, kvalue, kmin, kmax)', + example: '--8<-- "examples/outkat.csd"', + parameters: [ + { + name: 'kchn', + description: 'MIDI channel number (1-16)', + type: 'performance' + }, + { + name: 'kvalue', + description: 'floating point value', + type: 'performance' + }, + { + name: 'kmin', + description: 'minimum floating point value (converted in MIDI integer value 0)', + type: 'performance' + }, + { + name: 'kmax', + description: 'maximum floating point value (converted in MIDI integer value 127)', + type: 'performance' + }, + ], + seeAlso: ['MIDI Message Output'] +}, +{ + name: 'outkc', + type: 'opcode', + category: 'Real-time MIDI:Output', + description: 'Sends MIDI controller messages at k-rate.', + syntax: 'outkc(kchn, knum, kvalue, kmin, kmax)', + example: '--8<-- "examples/outkc.csd"', + parameters: [ + { + name: 'kchn', + description: 'MIDI channel number (1-16)', + type: 'performance' + }, + { + name: 'knum', + description: 'controller number (0-127 for example 1 = ModWheel; 2 = BreathControl etc.)', + type: 'performance' + }, + { + name: 'kvalue', + description: 'floating point value', + type: 'performance' + }, + { + name: 'kmin', + description: 'minimum floating point value (converted in MIDI integer value 0)', + type: 'performance' + }, + { + name: 'kmax', + description: 'maximum floating point value (converted in MIDI integer value 127 (7 bit))', + type: 'performance' + }, + ], + seeAlso: ['MIDI Message Output'] +}, +{ + name: 'outkc14', + type: 'opcode', + category: 'Real-time MIDI:Output', + description: 'Sends 14-bit MIDI controller output at k-rate.', + syntax: 'outkc14(kchn, kmsb, klsb, kvalue, kmin, kmax)', + parameters: [ + { + name: 'kchn', + description: 'MIDI channel number (1-16)', + type: 'performance' + }, + { + name: 'kmsb', + description: 'most significant byte controller number when using 14-bit parameters (0-127)', + type: 'performance' + }, + { + name: 'klsb', + description: 'least significant byte controller number when using 14-bit parameters (0-127)', + type: 'performance' + }, + { + name: 'kvalue', + description: 'floating point value', + type: 'performance' + }, + { + name: 'kmin', + description: 'minimum floating point value (converted in MIDI integer value 0)', + type: 'performance' + }, + { + name: 'kmax', + description: 'maximum floating point value (converted in MIDI integer value 16383 (14-bit))', + type: 'performance' + }, + ], + seeAlso: ['MIDI Message Output'] +}, +{ + name: 'outkpat', + type: 'opcode', + category: 'Real-time MIDI:Output', + description: 'Sends polyphonic MIDI aftertouch messages at k-rate.', + syntax: 'outkpat(kchn, knotenum, kvalue, kmin, kmax)', + parameters: [ + { + name: 'kchn', + description: 'MIDI channel number (1-16)', + type: 'performance' + }, + { + name: 'knotenum', + description: 'MIDI note number (used in polyphonic aftertouch messages)', + type: 'performance' + }, + { + name: 'kvalue', + description: 'floating point value', + type: 'performance' + }, + { + name: 'kmin', + description: 'minimum floating point value (converted in MIDI integer value 0)', + type: 'performance' + }, + { + name: 'kmax', + description: 'maximum floating point value (converted in MIDI integer value 127 (7 bit))', + type: 'performance' + }, + ], + seeAlso: ['MIDI Message Output'] +}, +{ + name: 'outkpb', + type: 'opcode', + category: 'Real-time MIDI:Output', + description: 'Sends MIDI pitch-bend messages at k-rate.', + syntax: 'outkpb(kchn, kvalue, kmin, kmax)', + example: '--8<-- "examples/outkpb.csd"', + parameters: [ + { + name: 'kchn', + description: 'MIDI channel number (1-16)', + type: 'performance' + }, + { + name: 'kvalue', + description: 'floating point value', + type: 'performance' + }, + { + name: 'kmin', + description: 'minimum floating point value (converted in MIDI integer value 0)', + type: 'performance' + }, + { + name: 'kmax', + description: 'maximum floating point value (converted in MIDI integer value 127 (7 bit))', + type: 'performance' + }, + ], + seeAlso: ['MIDI Message Output'] +}, +{ + name: 'outkpc', + type: 'opcode', + category: 'Real-time MIDI:Output', + description: 'Sends MIDI program change messages at k-rate.', + syntax: 'outkpc(kchn, kprog, kmin, kmax)', + example: '--8<-- "examples/outkpc.csd"', + parameters: [ + { + name: 'kchn', + description: 'MIDI channel number (1-16)', + type: 'performance' + }, + { + name: 'kprog', + description: 'program change number in floating point', + type: 'performance' + }, + { + name: 'kmin', + description: 'minimum floating point value (converted in MIDI integer value 0)', + type: 'performance' + }, + { + name: 'kmax', + description: 'maximum floating point value (converted in MIDI integer value 127 (7 bit))', + type: 'performance' + }, + ], + seeAlso: ['MIDI Message Output'] +}, +] diff --git a/src/lib/csound-reference/real-time-midi-slider-banks.ts b/src/lib/csound-reference/real-time-midi-slider-banks.ts new file mode 100644 index 0000000..05732f2 --- /dev/null +++ b/src/lib/csound-reference/real-time-midi-slider-banks.ts @@ -0,0 +1,423 @@ +import type { CsoundReference } from './types' + +// Real-time MIDI:Slider Banks +export const realTimeMidiSliderBanks: CsoundReference[] = [ +{ + name: 's16b14', + type: 'opcode', + category: 'Real-time MIDI:Slider Banks', + description: 'Creates a bank of 16 different 14-bit MIDI control message numbers.', + syntax: 'i1, ..., i16 = s16b14(ichan, ictlno_msb1, ictlno_lsb1, imin1, imax1, \\\n initvalue1, ifn1, ..., ictlno_msb16, ictlno_lsb16, \\\n imin16, imax16, initvalue16, ifn16)\n k1, ..., k16 = s16b14(ichan, ictlno_msb1, ictlno_lsb1, imin1, imax1, \\\n initvalue1, ifn1, ..., ictlno_msb16, ictlno_lsb16, \\\n imin16, imax16, initvalue16, ifn16)', + parameters: [ + { + name: 'ichan', + description: 'MIDI channel (1-16)', + type: 'initialization' + }, + { + name: 'msb32', + description: 'MIDI control number, most significant byte (0-127)', + type: 'initialization' + }, + { + name: 'lsb32', + description: 'MIDI control number, least significant byte (0-127)', + type: 'initialization' + }, + ], + seeAlso: ['Slider Banks'] +}, +{ + name: 's32b14', + type: 'opcode', + category: 'Real-time MIDI:Slider Banks', + description: 'Creates a bank of 32 different 14-bit MIDI control message numbers.', + syntax: 'i1, ..., i32 = s32b14(ichan, ictlno_msb1, ictlno_lsb1, imin1, imax1, \\\n initvalue1, ifn1, ..., ictlno_msb32, ictlno_lsb32, \\\n imin32, imax32, initvalue32, ifn32)\n k1, ..., k32 = s32b14(ichan, ictlno_msb1, ictlno_lsb1, imin1, imax1, \\\n initvalue1, ifn1, ..., ictlno_msb32, ictlno_lsb32, \\\n imin32, imax32, initvalue32, ifn32)', + parameters: [ + { + name: 'ichan', + description: 'MIDI channel (1-16)', + type: 'initialization' + }, + { + name: 'msb32', + description: 'MIDI control number, most significant byte (0-127)', + type: 'initialization' + }, + { + name: 'lsb32', + description: 'MIDI control number, least significant byte (0-127)', + type: 'initialization' + }, + ], + seeAlso: ['Slider Banks'] +}, +{ + name: 'slider16', + type: 'opcode', + category: 'Real-time MIDI:Slider Banks', + description: 'Creates a bank of 16 different MIDI control message numbers.', + syntax: 'i1, ..., i16 = slider16(ichan, ictlnum1, imin1, imax1, init1, ifn1, ..., \\\n ictlnum16, imin16, imax16, init16, ifn16)\n k1, ..., k16 = slider16(ichan, ictlnum1, imin1, imax1, init1, ifn1, ..., \\\n ictlnum16, imin16, imax16, init16, ifn16)', + parameters: [ + { + name: 'ichan', + description: 'MIDI channel (1-16)', + type: 'initialization' + }, + ], + seeAlso: ['Slider Banks'] +}, +{ + name: 'slider16f', + type: 'opcode', + category: 'Real-time MIDI:Slider Banks', + description: 'Creates a bank of 16 different MIDI control message numbers, filtered before output.', + syntax: 'k1, ..., k16 = slider16f(ichan, ictlnum1, imin1, imax1, init1, ifn1, icutoff1, \\\n ..., ictlnum16, imin16, imax16, init16, ifn16, icutoff16)', + parameters: [ + { + name: 'ichan', + description: 'MIDI channel (1-16)', + type: 'initialization' + }, + ], + seeAlso: ['Slider Banks'] +}, +{ + name: 'slider16table', + type: 'opcode', + category: 'Real-time MIDI:Slider Banks', + description: 'Stores a bank of 16 different MIDI control messages to a table.', + syntax: 'kflag = slider16table(ichan, ioutTable, ioffset, ictlnum1, imin1, imax1, \\\n init1, ifn1, ...., \\\n ictlnum16, imin16, imax16, init16, ifn16)', + parameters: [ + { + name: 'ichan', + description: 'MIDI channel (1-16)', + type: 'initialization' + }, + { + name: 'ioutTable', + description: 'number of the table that will contain the output', + type: 'initialization' + }, + { + name: 'ioffset', + description: 'output table offset. A zero means that the output of the first slider will affect the first table element. A 10 means that the output of the first slider will affect the 11th table element.', + type: 'initialization' + }, + { + name: 'kflag', + description: 'a flag that informs if any control-change message in the bank has been received. In this case _kflag_ is set to 1. Otherwise is set to zero.', + type: 'performance' + }, + ], + seeAlso: ['Slider Banks'] +}, +{ + name: 'slider16tablef', + type: 'opcode', + category: 'Real-time MIDI:Slider Banks', + description: 'Stores a bank of 16 different MIDI control messages to a table, filtered before output.', + syntax: 'kflag = slider16tablef(ichan, ioutTable, ioffset, ictlnum1, imin1, imax1, \\\n init1, ifn1, icutoff1, ...., \\\n ictlnum16, imin16, imax16, init16, ifn16, icutoff16)', + parameters: [ + { + name: 'ichan', + description: 'MIDI channel (1-16)', + type: 'initialization' + }, + { + name: 'ioutTable', + description: 'number of the table that will contain the output', + type: 'initialization' + }, + { + name: 'ioffset', + description: 'output table offset. A zero means that the output of the first slider will affect the first table element. A 10 means that the output of the first slider will affect the 11th table element.', + type: 'initialization' + }, + { + name: 'kflag', + description: 'a flag that informs if any control-change message in the bank has been received. In this case _kflag_ is set to 1. Otherwise is set to zero.', + type: 'performance' + }, + ], + seeAlso: ['Slider Banks'] +}, +{ + name: 'slider32', + type: 'opcode', + category: 'Real-time MIDI:Slider Banks', + description: 'Creates a bank of 32 different MIDI control message numbers.', + syntax: 'i1, ..., i32 = slider32(ichan, ictlnum1, imin1, imax1, init1, ifn1, ..., \\\n ictlnum32, imin32, imax32, init32, ifn32)\n k1, ..., k32 = slider32(ichan, ictlnum1, imin1, imax1, init1, ifn1, ..., \\\n ictlnum32, imin32, imax32, init32, ifn32)', + parameters: [ + { + name: 'ichan', + description: 'MIDI channel (1-16)', + type: 'initialization' + }, + ], + seeAlso: ['Slider Banks'] +}, +{ + name: 'slider32f', + type: 'opcode', + category: 'Real-time MIDI:Slider Banks', + description: 'Creates a bank of 32 different MIDI control message numbers, filtered before output.', + syntax: 'k1, ..., k32 = slider32f(ichan, ictlnum1, imin1, imax1, init1, ifn1, icutoff1, \\\n ..., ictlnum32, imin32, imax32, init32, ifn32, icutoff32)', + parameters: [ + { + name: 'ichan', + description: 'MIDI channel (1-16)', + type: 'initialization' + }, + ], + seeAlso: ['Slider Banks'] +}, +{ + name: 'slider32table', + type: 'opcode', + category: 'Real-time MIDI:Slider Banks', + description: 'Stores a bank of 32 different MIDI control messages to a table.', + syntax: 'kflag = slider32table(ichan, ioutTable, ioffset, ictlnum1, imin1, \\\n imax1, init1, ifn1, ...., \\\n ictlnum32, imin32, imax32, init32, ifn32)', + parameters: [ + { + name: 'ichan', + description: 'MIDI channel (1-16)', + type: 'initialization' + }, + { + name: 'ioutTable', + description: 'number of the table that will contain the output', + type: 'initialization' + }, + { + name: 'ioffset', + description: 'output table offset. A zero means that the output of the first slider will affect the first table element. A 10 means that the output of the first slider will affect the 11th table element.', + type: 'initialization' + }, + { + name: 'kflag', + description: 'a flag that informs if any control-change message in the bank has been received. In this case _kflag_ is set to 1. Otherwise is set to zero.', + type: 'performance' + }, + ], + seeAlso: ['Slider Banks'] +}, +{ + name: 'slider32tablef', + type: 'opcode', + category: 'Real-time MIDI:Slider Banks', + description: 'Stores a bank of 32 different MIDI control messages to a table, filtered before output.', + syntax: 'kflag = slider32tablef(ichan, ioutTable, ioffset, ictlnum1, imin1, imax1, \\\n init1, ifn1, icutoff1, ...., \\\n ictlnum32, imin32, imax32, init32, ifn32, icutoff32)', + parameters: [ + { + name: 'ichan', + description: 'MIDI channel (1-16)', + type: 'initialization' + }, + { + name: 'ioutTable', + description: 'number of the table that will contain the output', + type: 'initialization' + }, + { + name: 'ioffset', + description: 'output table offset. A zero means that the output of the first slider will affect the first table element. A 10 means that the output of the first slider will affect the 11th table element.', + type: 'initialization' + }, + { + name: 'kflag', + description: 'a flag that informs if any control-change message in the bank has been received. In this case _kflag_ is set to 1. Otherwise is set to zero.', + type: 'performance' + }, + ], + seeAlso: ['Slider Banks'] +}, +{ + name: 'slider64', + type: 'opcode', + category: 'Real-time MIDI:Slider Banks', + description: 'Creates a bank of 64 different MIDI control message numbers.', + syntax: 'i1, ..., i64 = slider64(ichan, ictlnum1, imin1, imax1, init1, ifn1, ..., \\\n ictlnum64, imin64, imax64, init64, ifn64)\n k1, ..., k64 = slider64(ichan, ictlnum1, imin1, imax1, init1, ifn1, ..., \\\n ictlnum64, imin64, imax64, init64, ifn64)', + parameters: [ + { + name: 'ichan', + description: 'MIDI channel (1-16)', + type: 'initialization' + }, + ], + seeAlso: ['Slider Banks'] +}, +{ + name: 'slider64f', + type: 'opcode', + category: 'Real-time MIDI:Slider Banks', + description: 'Creates a bank of 64 different MIDI control message numbers, filtered before output.', + syntax: 'k1, ..., k64 = slider64f(ichan, ictlnum1, imin1, imax1, init1, ifn1, icutoff1, \\\n ..., ictlnum64, imin64, imax64, init64, ifn64, icutoff64)', + parameters: [ + { + name: 'ichan', + description: 'MIDI channel (1-16)', + type: 'initialization' + }, + ], + seeAlso: ['Slider Banks'] +}, +{ + name: 'slider64table', + type: 'opcode', + category: 'Real-time MIDI:Slider Banks', + description: 'Stores a bank of 64 different MIDI control messages to a table.', + syntax: 'kflag = slider64table(ichan, ioutTable, ioffset, ictlnum1, imin1, \\\n imax1, init1, ifn1, ...., \\\n ictlnum64, imin64, imax64, init64, ifn64)', + parameters: [ + { + name: 'ichan', + description: 'MIDI channel (1-16)', + type: 'initialization' + }, + { + name: 'ioutTable', + description: 'number of the table that will contain the output', + type: 'initialization' + }, + { + name: 'ioffset', + description: 'output table offset. A zero means that the output of the first slider will affect the first table element. A 10 means that the output of the first slider will affect the 11th table element.', + type: 'initialization' + }, + { + name: 'kflag', + description: 'a flag that informs if any control-change message in the bank has been received. In this case _kflag_ is set to 1. Otherwise is set to zero.', + type: 'performance' + }, + ], + seeAlso: ['Slider Banks'] +}, +{ + name: 'slider64tablef', + type: 'opcode', + category: 'Real-time MIDI:Slider Banks', + description: 'Stores a bank of 64 different MIDI control messages to a table, filtered before output.', + syntax: 'kflag = slider64tablef(ichan, ioutTable, ioffset, ictlnum1, imin1, imax1, \\\n init1, ifn1, icutoff1, ...., \\\n ictlnum64, imin64, imax64, init64, ifn64, icutoff64)', + parameters: [ + { + name: 'ichan', + description: 'MIDI channel (1-16)', + type: 'initialization' + }, + { + name: 'ioutTable', + description: 'number of the table that will contain the output', + type: 'initialization' + }, + { + name: 'ioffset', + description: 'output table offset. A zero means that the output of the first slider will affect the first table element. A 10 means that the output of the first slider will affect the 11th table element.', + type: 'initialization' + }, + { + name: 'kflag', + description: 'a flag that informs if any control-change message in the bank has been received. In this case _kflag_ is set to 1. Otherwise is set to zero.', + type: 'performance' + }, + ], + seeAlso: ['Slider Banks'] +}, +{ + name: 'slider8', + type: 'opcode', + category: 'Real-time MIDI:Slider Banks', + description: 'Creates a bank of 8 different MIDI control message numbers.', + syntax: 'i1, ..., i8 = slider8(ichan, ictlnum1, imin1, imax1, init1, ifn1, ..., \\\n ictlnum8, imin8, imax8, init8, ifn8)\n k1, ..., k8 = slider8(ichan, ictlnum1, imin1, imax1, init1, ifn1, ..., \\\n ictlnum8, imin8, imax8, init8, ifn8)', + parameters: [ + { + name: 'ichan', + description: 'MIDI channel (1-16)', + type: 'initialization' + }, + ], + seeAlso: ['Slider Banks'] +}, +{ + name: 'slider8f', + type: 'opcode', + category: 'Real-time MIDI:Slider Banks', + description: 'Creates a bank of 8 different MIDI control message numbers, filtered before output.', + syntax: 'k1, ..., k8 = slider8f(ichan, ictlnum1, imin1, imax1, init1, ifn1, icutoff1, \\\n ..., ictlnum8, imin8, imax8, init8, ifn8, icutoff8)', + parameters: [ + { + name: 'ichan', + description: 'MIDI channel (1-16)', + type: 'initialization' + }, + ], + seeAlso: ['Slider Banks'] +}, +{ + name: 'slider8table', + type: 'opcode', + category: 'Real-time MIDI:Slider Banks', + description: 'Stores a bank of 8 different MIDI control messages to a table.', + syntax: 'kflag = slider8table(ichan, ioutTable, ioffset, ictlnum1, imin1, imax1, \\\n init1, ifn1, ..., ictlnum8, imin8, imax8, init8, ifn8)', + parameters: [ + { + name: 'ichan', + description: 'MIDI channel (1-16)', + type: 'initialization' + }, + { + name: 'ioutTable', + description: 'number of the table that will contain the output', + type: 'initialization' + }, + { + name: 'ioffset', + description: 'output table offset. A zero means that the output of the first slider will affect the first table element. A 10 means that the output of the first slider will affect the 11th table element.', + type: 'initialization' + }, + { + name: 'kflag', + description: 'a flag that informs if any control-change message in the bank has been received. In this case _kflag_ is set to 1. Otherwise is set to zero.', + type: 'performance' + }, + ], + seeAlso: ['Slider Banks'] +}, +{ + name: 'slider8tablef', + type: 'opcode', + category: 'Real-time MIDI:Slider Banks', + description: 'Stores a bank of 8 different MIDI control messages to a table, filtered before output.', + syntax: 'kflag = slider8tablef(ichan, ioutTable, ioffset, ictlnum1, imin1, imax1, \\\n init1, ifn1, icutoff1, ...., \\\n ictlnum8, imin8, imax8, init8, ifn8, icutoff8)', + parameters: [ + { + name: 'ichan', + description: 'MIDI channel (1-16)', + type: 'initialization' + }, + { + name: 'ioutTable', + description: 'number of the table that will contain the output', + type: 'initialization' + }, + { + name: 'ioffset', + description: 'output table offset. A zero means that the output of the first slider will affect the first table element. A 10 means that the output of the first slider will affect the 11th table element.', + type: 'initialization' + }, + { + name: 'kflag', + description: 'a flag that informs if any control-change message in the bank has been received. In this case _kflag_ is set to 1. Otherwise is set to zero.', + type: 'performance' + }, + ], + seeAlso: ['Slider Banks'] +}, +{ + name: 'sliderKawai', + type: 'opcode', + category: 'Real-time MIDI:Slider Banks', + description: 'Creates a bank of 16 different MIDI control message numbers from a KAWAI MM-16 midi mixer.', + syntax: 'k1, k2, ...., k16 = sliderKawai(imin1, imax1, init1, ifn1, imin2, imax2, \\\n init2, ifn2, ..., imin16, imax16, init16, ifn16)', + seeAlso: ['Slider Banks'] +}, +] diff --git a/src/lib/csound-reference/real-time-midi-system-realtime.ts b/src/lib/csound-reference/real-time-midi-system-realtime.ts new file mode 100644 index 0000000..4dbdad0 --- /dev/null +++ b/src/lib/csound-reference/real-time-midi-system-realtime.ts @@ -0,0 +1,36 @@ +import type { CsoundReference } from './types' + +// Real-time MIDI:System Realtime +export const realTimeMidiSystemRealtime: CsoundReference[] = [ +{ + name: 'mclock', + type: 'opcode', + category: 'Real-time MIDI:System Realtime', + description: 'Sends a MIDI CLOCK message.', + syntax: 'mclock(ifreq)', + example: '--8<-- "examples/mclock.csd"', + parameters: [ + { + name: 'ifreq', + description: 'clock message frequency rate in Hz', + type: 'initialization' + }, + ], + seeAlso: ['mrtmsg', 'System Realtime Messages'] +}, +{ + name: 'mrtmsg', + type: 'opcode', + category: 'Real-time MIDI:System Realtime', + description: 'Send system real-time messages to the MIDI OUT port.', + syntax: 'mrtmsg(imsgtype)', + parameters: [ + { + name: 'imsgtype', + description: 'type of real-time message:', + type: 'initialization' + }, + ], + seeAlso: ['mclock', 'System Realtime Messages'] +}, +] diff --git a/src/lib/csound-reference/remote-opcodes.ts b/src/lib/csound-reference/remote-opcodes.ts new file mode 100644 index 0000000..8725bbd --- /dev/null +++ b/src/lib/csound-reference/remote-opcodes.ts @@ -0,0 +1,97 @@ +import type { CsoundReference } from './types' + +// Remote Opcodes +export const remoteOpcodes: CsoundReference[] = [ +{ + name: 'insglobal', + type: 'opcode', + category: 'Remote Opcodes', + description: 'An opcode which can be used to implement a remote orchestra. This opcode will send note events from a source machine to many destinations.', + syntax: 'insglobal(isource, instrnum [,instrnum...])', + parameters: [ + { + name: 'isource', + description: 'a string that is the intended server computer (e.g. 192.168.0.100). This is the source host which generates the events of the given instrument(s) and sends it to all the machines involved in the remote concert.', + type: 'initialization' + }, + { + name: 'instrnum', + description: 'a list of instrument numbers which will be played on the destination machines', + type: 'initialization' + }, + ], + seeAlso: ['Remote Opcodes'] +}, +{ + name: 'insremot', + type: 'opcode', + category: 'Remote Opcodes', + description: 'An opcode which can be used to implement a remote orchestra. This opcode will send note events from a source machine to one destination.', + syntax: 'insremot(idestination, isource, instrnum [, instrnum...])', + example: '--8<-- "examples/insremot.csd"', + parameters: [ + { + name: 'idestination', + description: 'a string that is the intended client computer (e.g. 192.168.0.100). This is the destination host which receives the events from the given instrument.', + type: 'initialization' + }, + { + name: 'isource', + description: 'a string that is the intended server computer (e.g. 192.168.0.100). This is the source host which generates the events of the given instrument and sends it to the address given by idestination.', + type: 'initialization' + }, + { + name: 'instrnum', + description: 'a list of instrument numbers which will be played on the destination machine', + type: 'initialization' + }, + ], + seeAlso: ['Remote Opcodes'] +}, +{ + name: 'midglobal', + type: 'opcode', + category: 'Remote Opcodes', + description: 'An opcode which can be used to implement a remote midi orchestra. This opcode will broadcast the midi events to all the machines involved in the remote concert.', + syntax: 'midglobal(isource, instrnum [, instrnum...])', + parameters: [ + { + name: 'isource', + description: 'a string that is the intended host computer (e.g. 192.168.0.100). This is the source host which generates the events of the given instrument(s) and sends it to all the machines involved in the remote concert.', + type: 'initialization' + }, + { + name: 'instrnum', + description: 'a list of instrument numbers which will be played on the destination machines', + type: 'initialization' + }, + ], + seeAlso: ['Remote Opcodes'] +}, +{ + name: 'midremot', + type: 'opcode', + category: 'Remote Opcodes', + description: 'An opcode which can be used to implement a remote midi orchestra. This opcode will send midi events from a source machine to one destination.', + syntax: 'midremot(idestination, isource, instrnum [, instrnum...])', + example: '--8<-- "examples/midremot.csd"', + parameters: [ + { + name: 'idestination', + description: 'a string that is the intended host computer (e.g. 192.168.0.100). This is the destination host which receives the events from the given instrument.', + type: 'initialization' + }, + { + name: 'isource', + description: 'a string that is the intended host computer (e.g. 192.168.0.100). This is the source host which generates the events of the given instrument and sends it to the address given by idestination.', + type: 'initialization' + }, + { + name: 'instrnum', + description: 'a list of instrument numbers which will be played on the destination machine', + type: 'initialization' + }, + ], + seeAlso: ['Remote Opcodes'] +}, +] diff --git a/src/lib/csound-reference/serial-i-o.ts b/src/lib/csound-reference/serial-i-o.ts new file mode 100644 index 0000000..f1928a8 --- /dev/null +++ b/src/lib/csound-reference/serial-i-o.ts @@ -0,0 +1,235 @@ +import type { CsoundReference } from './types' + +// Serial I/O +export const serialIO: CsoundReference[] = [ +{ + name: 'arduinoRead', + type: 'opcode', + category: 'Serial I/O', + description: 'Read integer data from an arduino port using the Csound-Arduino protocol.', + syntax: 'kval = arduinoRead(iPort, iStream [, iSmooth])', + example: '--8<-- "examples/arduinoRead.csd"', + parameters: [ + { + name: 'iPort', + description: 'port number obtained from a _arduinoStart_ opcode.', + type: 'performance' + }, + { + name: 'iStream', + description: 'Number of the data stream in range 0 to 30.', + type: 'performance' + }, + { + name: 'iSmooth', + description: 'halftime of a portamento filter to smooth the stream of data. Defaults to 0 meaning no filtering.', + type: 'performance' + }, + { + name: 'kval', + description: 'data to read in range [0, 1023].', + type: 'performance' + }, + ], + seeAlso: ['non-MIDI Devices', 'New Arduino Opcodes to Simplify the Streaming of Sensor and Controller Data to Csound'] +}, +{ + name: 'arduinoReadF', + type: 'opcode', + category: 'Serial I/O', + description: 'Read integer data from an arduino port using the Csound-Arduino protocol.', + syntax: 'kval = arduinoReadF(iPort, iStream1, iStream2, iStream3)', + example: '--8<-- "examples/arduinoReadF.csd"', + parameters: [ + { + name: 'iPort', + description: 'port number obtained from a _arduinoStart_ opcode.', + type: 'performance' + }, + { + name: 'iStream1', + description: 'Numbers of the three data streams in the range 0 to 30. Each stream carries 10 bits of the 30 bits floating point result. The division is created in the Arduino sketch encapsulated in the put_float function.', + type: 'performance' + }, + { + name: 'iStream2', + description: 'Numbers of the three data streams in the range 0 to 30. Each stream carries 10 bits of the 30 bits floating point result. The division is created in the Arduino sketch encapsulated in the put_float function.', + type: 'performance' + }, + { + name: 'iStream3', + description: 'Numbers of the three data streams in the range 0 to 30. Each stream carries 10 bits of the 30 bits floating point result. The division is created in the Arduino sketch encapsulated in the put_float function.', + type: 'performance' + }, + { + name: 'kval', + description: 'floating point value read.', + type: 'performance' + }, + ], + seeAlso: ['non-MIDI Devices', 'New Arduino Opcodes to Simplify the Streaming of Sensor and Controller Data to Csound'] +}, +{ + name: 'arduinoStart', + type: 'opcode', + category: 'Serial I/O', + description: 'Open a serial port for use with the Arduino protocol.', + syntax: 'iPort = arduinoStart(SPortName [, ibaudRate])', + parameters: [ + { + name: 'SPortName', + description: 'port name number', + type: 'initialization' + }, + { + name: 'ibaudrate', + description: 'serial speed, defaulting to 9600 bps.', + type: 'initialization' + }, + ], + seeAlso: ['non-MIDI Devices', 'New Arduino Opcodes to Simplify the Streaming of Sensor and Controller Data to Csound'] +}, +{ + name: 'arduinoStop', + type: 'opcode', + category: 'Serial I/O', + description: 'Close a serial port using Arduino protocol.', + syntax: 'arduinoStop(iPort)', + parameters: [ + { + name: 'iPort', + description: 'port number obtained from a _arduinoStart_opcode.', + type: 'initialization' + }, + ], + seeAlso: ['non-MIDI Devices', 'New Arduino Opcodes to Simplify the Streaming of Sensor and Controller Data to Csound'] +}, +{ + name: 'serialBegin', + type: 'opcode', + category: 'Serial I/O', + description: 'Open a serial port for arduino.', + syntax: 'iPort = serialBegin(SPortName [, ibaudRate])', + example: '--8<-- "examples/serialBegin.csd"', + parameters: [ + { + name: 'SPortName', + description: 'port name number', + type: 'initialization' + }, + { + name: 'ibaudrate', + description: 'serial speed, defaulting to 9600 bps.', + type: 'initialization' + }, + ], + seeAlso: ['non-MIDI Devices'] +}, +{ + name: 'serialEnd', + type: 'opcode', + category: 'Serial I/O', + description: 'Close a serial port for arduino.', + syntax: 'serialEnd(iPort)', + parameters: [ + { + name: 'iPort', + description: 'port number optained from a _serialBegin_opcode.', + type: 'initialization' + }, + ], + seeAlso: ['non-MIDI Devices'] +}, +{ + name: 'serialFlush', + type: 'opcode', + category: 'Serial I/O', + description: 'Flush data from a serial port.', + syntax: 'serialFlush(iPort)', + parameters: [ + { + name: 'iPort', + description: 'port number optained from a _serialBegin_ opcode.', + type: 'performance' + }, + ], + seeAlso: ['non-MIDI Devices'] +}, +{ + name: 'serialPrint', + type: 'opcode', + category: 'Serial I/O', + description: 'Print data from a serial port.', + syntax: 'serialPrint(iPort)', + parameters: [ + { + name: 'iPort', + description: 'port number optained from a _serialBegin_ opcode.', + type: 'performance' + }, + ], + seeAlso: ['non-MIDI Devices'] +}, +{ + name: 'serialRead', + type: 'opcode', + category: 'Serial I/O', + description: 'Read data from a serial port for arduino.', + syntax: 'kByte = serialRead(iPort)', + example: '--8<-- "examples/serialRead.csd"', + parameters: [ + { + name: 'iPort', + description: 'port number optained from a _serialBegin_ opcode.', + type: 'performance' + }, + { + name: 'kByte', + description: 'a byte of data to read.', + type: 'performance' + }, + ], + seeAlso: ['non-MIDI Devices'] +}, +{ + name: 'serialWrite', + type: 'opcode', + category: 'Serial I/O', + description: 'Write data to a serial port for arduino.', + syntax: 'serialWrite(iPort, iByte)\n serialWrite(iPort, kByte)\n serialWrite(iPort, SBytes)', + example: '--8<-- "examples/serialWrite.csd"', + parameters: [ + { + name: 'iPort', + description: 'port number optained from a _serialBegin_ opcode.', + type: 'performance' + }, + { + name: 'iByte', + description: 'a byte of data to write.', + type: 'performance' + }, + ], + seeAlso: ['non-MIDI Devices'] +}, +{ + name: 'serialWrite_i', + type: 'opcode', + category: 'Serial I/O', + description: 'Write data to a serial port for arduino.', + syntax: 'serialWrite_i(iPort, iByte)\n serialWrite_i(iPort, SBytes)', + parameters: [ + { + name: 'iPort', + description: 'port number optained from a _serialBegin_ opcode.', + type: 'initialization' + }, + { + name: 'iByte', + description: 'a byte of data to write.', + type: 'initialization' + }, + ], + seeAlso: ['non-MIDI Devices'] +}, +] diff --git a/src/lib/csound-reference/signal-flow-graph-opcodes.ts b/src/lib/csound-reference/signal-flow-graph-opcodes.ts new file mode 100644 index 0000000..ba159d8 --- /dev/null +++ b/src/lib/csound-reference/signal-flow-graph-opcodes.ts @@ -0,0 +1,296 @@ +import type { CsoundReference } from './types' + +// Signal Flow Graph Opcodes +export const signalFlowGraphOpcodes: CsoundReference[] = [ +{ + name: 'alwayson', + type: 'opcode', + category: 'Signal Flow Graph Opcodes', + description: 'Activates the indicated instrument in the orchestra header, without need for an i statement.', + syntax: 'alwayson(Tinstrument [, p4, ..., pn])', + example: '--8<-- "examples/alwayson-modern.csd"', + parameters: [ + { + name: 'Tinstrument', + description: 'String name of the instrument definition to be turned on.', + type: 'initialization' + }, + ], + seeAlso: ['Signal Flow Graph Opcodes'] +}, +{ + name: 'connect', + type: 'opcode', + category: 'Signal Flow Graph Opcodes', + description: 'Connects a source outlet to a sink inlet.', + syntax: 'connect(Tsource1, Soutlet1, Tsink1, Sinlet1)', + example: '--8<-- "examples/connect-modern.csd"', + parameters: [ + { + name: 'Tsource1', + description: 'String name of the source instrument definition.', + type: 'initialization' + }, + { + name: 'Soutlet1', + description: 'String name of the source outlet in the source instrument.', + type: 'initialization' + }, + { + name: 'Tsink1', + description: 'String name of the sink instrument definition.', + type: 'initialization' + }, + { + name: 'Sinlet1', + description: 'String name of the sink inlet in the sink instrument.', + type: 'initialization' + }, + ], + seeAlso: ['Signal Flow Graph Opcodes', 'http://www.csoundjournal.com/issue13/signalFlowGraphOpcodes.html'] +}, +{ + name: 'ftgenonce', + type: 'opcode', + category: 'Signal Flow Graph Opcodes', + description: 'Generate a function table from within an instrument definition, without duplication of data.', + syntax: 'ifno = ftgenonce(ip1, ip2dummy, isize, igen, iarga, iargb, ...)', + example: '--8<-- "examples/ftgenonce.csd"', + parameters: [ + { + name: 'ifno', + description: 'an automatically assigned table number.', + type: 'initialization' + }, + { + name: 'ip1', + description: 'the number of the table to be generated or 0 if the number is to be assigned.', + type: 'initialization' + }, + { + name: 'ip2dummy', + description: 'ignored.', + type: 'initialization' + }, + { + name: 'isize', + description: 'table size. Corresponds to p3 of the score _f statement_.', + type: 'initialization' + }, + { + name: 'igen', + description: 'function table _GEN_ routine. Corresponds to p4 of the score _f statement_.', + type: 'initialization' + }, + ], + seeAlso: ['Signal Flow Graph Opcodes'] +}, +{ + name: 'inleta', + type: 'opcode', + category: 'Signal Flow Graph Opcodes', + description: 'Receives an arate signal into an instrument through a named port.', + syntax: 'asignal = inleta(Sname)', + example: '--8<-- "examples/inleta.csd"', + parameters: [ + { + name: 'Sname', + description: 'String name of the inlet port. The name of the inlet is implicitly qualified by the instrument name or number, so it is valid to use the same inlet name in more than one instrument (but not to use the same inlet name twice in one instrument).', + type: 'initialization' + }, + { + name: 'asignal', + description: 'audio input signal', + type: 'performance' + }, + ], + seeAlso: ['Signal Flow Graph Opcodes', 'http://www.csoundjournal.com/issue13/signalFlowGraphOpcodes.html'] +}, +{ + name: 'inletf', + type: 'opcode', + category: 'Signal Flow Graph Opcodes', + description: 'Receives an frate signal (fsig) into an instrument from a named port.', + syntax: 'fsignal = inletf(Sname)', + parameters: [ + { + name: 'Sname', + description: 'String name of the inlet port. The name of the inlet is implicitly qualified by the instrument name or number, so it is valid to use the same inlet name in more than one instrument (but not to use the same inlet name twice in one instrument).', + type: 'initialization' + }, + { + name: 'ksignal', + description: 'frate input signal', + type: 'performance' + }, + ], +}, +{ + name: 'inletk', + type: 'opcode', + category: 'Signal Flow Graph Opcodes', + description: 'Receives a krate signal into an instrument from a named port.', + syntax: 'ksignal = inletk(Sname)', + example: '--8<-- "examples/inletk.csd"', + parameters: [ + { + name: 'Sname', + description: 'String name of the inlet port. The name of the inlet is implicitly qualified by the instrument name or number, so it is valid to use the same inlet name in more than one instrument (but not to use the same inlet name twice in one instrument).', + type: 'initialization' + }, + { + name: 'ksignal', + description: 'krate input signal', + type: 'performance' + }, + ], + seeAlso: ['Signal Flow Graph Opcodes', 'http://www.csoundjournal.com/issue13/signalFlowGraphOpcodes.html'] +}, +{ + name: 'inletkid', + type: 'opcode', + category: 'Signal Flow Graph Opcodes', + description: 'Receives a krate signal into an instrument from a named port.', + syntax: 'ksignal = inletkid(Sname, SinstanceID)', + parameters: [ + { + name: 'Sname', + description: 'String name of the inlet port. The name of the inlet is implicitly qualified by the instrument name or number, so it is valid to use the same inlet name in more than one instrument (but not to use the same inlet name twice in one instrument).', + type: 'initialization' + }, + { + name: 'SinstanceID', + description: 'String name of the outlet port\'s instance ID. This enables the inlet to discriminate between different instances of the outlet, e,g. one instance of the outlet might be created by a note specifying one instance ID, and another instance might be created by a note specifying another ID. This might be used, e.g., to situate difference instances of an instrument at different points in an Ambisonic space in a spatializing effects processor.', + type: 'initialization' + }, + { + name: 'ksignal', + description: 'krate input signal', + type: 'performance' + }, + ], +}, +{ + name: 'inletv', + type: 'opcode', + category: 'Signal Flow Graph Opcodes', + description: 'Receives an arate array signal into an instrument through a named port.', + syntax: 'array = inletv(Sname)', + parameters: [ + { + name: 'Sname', + description: 'String name of the inlet port. The name of the inlet is implicitly qualified by the instrument name or number, so it is valid to use the same inlet name in more than one instrument (but not to use the same inlet name twice in one instrument).', + type: 'initialization' + }, + { + name: 'array', + description: 'audio rate array inlet signal', + type: 'performance' + }, + ], +}, +{ + name: 'outleta', + type: 'opcode', + category: 'Signal Flow Graph Opcodes', + description: 'Sends an arate signal out from an instrument to a named port.', + syntax: 'outleta(Sname, asignal)', + example: '--8<-- "examples/outleta.csd"', + parameters: [ + { + name: 'Sname', + description: 'String name of the outlet port. The name of the outlet is implicitly qualified by the instrument name or number, so it is valid to use the same outlet name in more than one instrument (but not to use the same outlet name twice in one instrument).', + type: 'initialization' + }, + { + name: 'asignal', + description: 'audio output signal', + type: 'performance' + }, + ], + seeAlso: ['Signal Flow Graph Opcodes', 'http://www.csoundjournal.com/issue13/signalFlowGraphOpcodes.html'] +}, +{ + name: 'outletf', + type: 'opcode', + category: 'Signal Flow Graph Opcodes', + description: 'Sends a frate signal (fsig) out from an instrument to a named port.', + syntax: 'outletf(Sname, fsignal)', + parameters: [ + { + name: 'Sname', + description: 'String name of the outlet port. The name of the outlet is implicitly qualified by the instrument name or number, so it is valid to use the same outlet name in more than one instrument (but not to use the same outlet name twice in one instrument).', + type: 'initialization' + }, + { + name: 'fsignal', + description: 'frate output signal (fsig)', + type: 'performance' + }, + ], +}, +{ + name: 'outletk', + type: 'opcode', + category: 'Signal Flow Graph Opcodes', + description: 'Sends a krate signal out from an instrument to a named port.', + syntax: 'outletk(Sname, ksignal)', + example: '--8<-- "examples/outletk.csd"', + parameters: [ + { + name: 'Sname', + description: 'String name of the outlet port. The name of the outlet is implicitly qualified by the instrument name or number, so it is valid to use the same outlet name in more than one instrument (but not to use the same outlet name twice in one instrument).', + type: 'initialization' + }, + { + name: 'ksignal', + description: 'krate output signal', + type: 'performance' + }, + ], + seeAlso: ['Signal Flow Graph Opcodes', 'http://www.csoundjournal.com/issue13/signalFlowGraphOpcodes.html'] +}, +{ + name: 'outletkid', + type: 'opcode', + category: 'Signal Flow Graph Opcodes', + description: 'Sends a krate signal out from an instrument to a named port.', + syntax: 'outletkid(Sname, SinstanceID, ksignal)', + parameters: [ + { + name: 'Sname', + description: 'String name of the outlet port. The name of the outlet is implicitly qualified by the instrument name or number, so it is valid to use the same outlet name in more than one instrument (but not to use the same outlet name twice in one instrument).', + type: 'initialization' + }, + { + name: 'SinstanceID', + description: 'String name of the outlet port\'s instance ID. This enables the inlet to discriminate between different instances of the outlet, e,g. one instance of the outlet might be created by a note specifying one instance ID, and another instance might be created by a note specifying another ID. This might be used, e.g., to situate difference instances of an instrument at different points in an Ambisonic space in a spatializing effects processor.', + type: 'initialization' + }, + { + name: 'ksignal', + description: 'krate output signal', + type: 'performance' + }, + ], +}, +{ + name: 'outletv', + type: 'opcode', + category: 'Signal Flow Graph Opcodes', + description: 'Sends an arate array signal out from an instrument to a named port.', + syntax: 'outletv(Sname, array)', + parameters: [ + { + name: 'Sname', + description: 'String name of the outlet port. The name of the outlet is implicitly qualified by the instrument name or number, so it is valid to use the same outlet name in more than one instrument (but not to use the same outlet name twice in one instrument).', + type: 'initialization' + }, + { + name: 'array', + description: 'arate array output signal', + type: 'performance' + }, + ], +}, +] diff --git a/src/lib/csound-reference/signal-generators-additive-synthesis-resynthesis.ts b/src/lib/csound-reference/signal-generators-additive-synthesis-resynthesis.ts new file mode 100644 index 0000000..e1b18b3 --- /dev/null +++ b/src/lib/csound-reference/signal-generators-additive-synthesis-resynthesis.ts @@ -0,0 +1,173 @@ +import type { CsoundReference } from './types' + +// Signal Generators:Additive Synthesis/Resynthesis +export const signalGeneratorsAdditiveSynthesisResynthesis: CsoundReference[] = [ +{ + name: 'adsyn', + type: 'opcode', + category: 'Signal Generators:Additive Synthesis/Resynthesis', + description: 'Output is an additive set of individually controlled sinusoids, using an oscillator bank.', + syntax: 'ares = adsyn(kamod, kfmod, ksmod, ifilcod)', + example: '--8<-- "examples/adsyn-modern.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'ifilcod', + description: 'integer or character-string denoting a control-file derived from analysis of an audio signal. An integer denotes the suffix of a file _adsyn.m_ or _pvoc.m_; a character-string (in double quotes) gives a filename, optionally a full pathname. If not fullpath, the file is sought first in the current directory, then in the one given by the environment variable [SADIR](../invoke/environment-variables.md) (if defined). _adsyn_ control contains breakpoint amplitude- and frequency-envelope values organized for oscillator resynthesis, while _pvoc_ control contains similar data organized for fft resynthesis. Memory usage depends on the size of the files involved, which are read and held entirely in memory during computation but are shared by multiple calls (see also [lpread](../opcodes/lpread.md)).', + type: 'initialization' + }, + { + name: 'kamod', + description: 'amplitude factor of the contributing partials.', + type: 'performance' + }, + { + name: 'kfmod', + description: 'frequency factor of the contributing partials. It is a control-rate transposition factor: a value of 1 incurs no transposition, 1.5 transposes up a perfect fifth, and .5 down an octave.', + type: 'performance' + }, + { + name: 'ksmod', + description: 'speed factor of the contributing partials.', + type: 'performance' + }, + ], + seeAlso: ['Additive Synthesis/Resynthesis'] +}, +{ + name: 'adsynt', + type: 'opcode', + category: 'Signal Generators:Additive Synthesis/Resynthesis', + description: 'Performs additive synthesis with an arbitrary number of partials, not necessarily harmonic.', + syntax: 'ares = adsynt(kamp, kcps, iwfn, ifreqfn, iampfn, icnt [, iphs])', + example: '--8<-- "examples/adsynt-modern.csd"', + rates: ['a-rate', 'k-rate', 'i-rate'], + parameters: [ + { + name: 'iwfn', + description: 'table containing a waveform, usually a sine. Table values are not interpolated for performance reasons, so larger tables provide better quality.', + type: 'initialization' + }, + { + name: 'ifreqfn', + description: 'table containing frequency values for each partial. _ifreqfn_ may contain beginning frequency values for each partial, but is usually used for generating parameters at runtime with _tablew_. Frequencies must be relative to _kcps_. Size must be at least _icnt_.', + type: 'initialization' + }, + { + name: 'iampfn', + description: 'table containing amplitude values for each partial. _iampfn_ may contain beginning amplitude values for each partial, but is usually used for generating parameters at runtime with _tablew_. Amplitudes must be relative to _kamp_. Size must be at least _icnt_.', + type: 'initialization' + }, + { + name: 'icnt', + description: 'number of partials to be generated', + type: 'initialization' + }, + { + name: 'iphs', + description: 'initial phase of each oscillator, if _iphs_ = -1, initialization is skipped. If _iphs_ > 1, all phases will be initialized with a random value.', + type: 'initialization' + }, + { + name: 'kamp', + description: 'amplitude of note', + type: 'performance' + }, + { + name: 'kcps', + description: 'base frequency of note. Partial frequencies will be relative to _kcps_.', + type: 'performance' + }, + ], + seeAlso: ['Additive Synthesis/Resynthesis'] +}, +{ + name: 'adsynt2', + type: 'opcode', + category: 'Signal Generators:Additive Synthesis/Resynthesis', + description: 'Performs additive synthesis with an arbitrary number of partials, not necessarily harmonic. (see [adsynt](../opcodes/adsynt.md) for detailed manual)', + syntax: 'ar = adsynt2(kamp, kcps, iwfn, ifreqfn, iampfn, icnt [, iphs])', + example: '--8<-- "examples/adsynt2-modern.csd"', + rates: ['k-rate', 'i-rate'], + parameters: [ + { + name: 'iwfn', + description: 'table containing a waveform, usually a sine. Table values are not interpolated for performance reasons, so larger tables provide better quality.', + type: 'initialization' + }, + { + name: 'ifreqfn', + description: 'table containing frequency values for each partial. _ifreqfn_ may contain beginning frequency values for each partial, but is usually used for generating parameters at runtime with _tablew_. Frequencies must be relative to _kcps_. Size must be at least _icnt_.', + type: 'initialization' + }, + { + name: 'iampfn', + description: 'table containing amplitude values for each partial. _iampfn_ may contain beginning amplitude values for each partial, but is usually used for generating parameters at runtime with _tablew_. Amplitudes must be relative to _kamp_. Size must be at least _icnt_.', + type: 'initialization' + }, + { + name: 'icnt', + description: 'number of partials to be generated', + type: 'initialization' + }, + { + name: 'iphs', + description: 'initial phase of each oscillator, if _iphs_ = -1, initialization is skipped. If _iphs_ > 1, all phases will be initialized with a random value.', + type: 'initialization' + }, + { + name: 'kamp', + description: 'amplitude of note', + type: 'performance' + }, + { + name: 'kcps', + description: 'base frequency of note. Partial frequencies will be relative to _kcps_.', + type: 'performance' + }, + ], + seeAlso: ['Additive Synthesis/Resynthesis'] +}, +{ + name: 'hsboscil', + type: 'opcode', + category: 'Signal Generators:Additive Synthesis/Resynthesis', + description: 'An oscillator which takes tonality and brightness as arguments, relative to a base frequency.', + syntax: 'ares = hsboscil(kamp, ktone, kbrite, ibasfreq, iwfn, ioctfn \\\n [, ioctcnt] [, iphs])', + example: '--8<-- "examples/hsboscil.csd"', + rates: ['a-rate', 'k-rate', 'i-rate'], + parameters: [ + { + name: 'ibasfreq', + description: 'base frequency to which tonality and brighness are relative', + type: 'initialization' + }, + { + name: 'iwfn', + description: 'function table of the waveform, usually a sine', + type: 'initialization' + }, + { + name: 'ioctfn', + description: 'function table used for weighting the octaves, usually something like:', + type: 'initialization' + }, + { + name: 'kamp', + description: 'amplitude of note', + type: 'performance' + }, + { + name: 'ktone', + description: 'cyclic tonality parameter relative to _ibasfreq_ in logarithmic octave, range 0 to 1, values >> 1 can be used, and are internally reduced to _frac_(_ktone_).', + type: 'performance' + }, + { + name: 'kbrite', + description: 'brightness parameter relative to _ibasfreq_, achieved by weighting _ioctcnt_ octaves. It is scaled in such a way, that a value of 0 corresponds to the orignal value of _ibasfreq_, 1 corresponds to one octave above _ibasfreq_, -2 corresponds to two octaves below _ibasfreq_, etc. _kbrite_ may be fractional.', + type: 'performance' + }, + ], + seeAlso: ['Additive Synthesis/Resynthesis'] +}, +] diff --git a/src/lib/csound-reference/signal-generators-basic-oscillators.ts b/src/lib/csound-reference/signal-generators-basic-oscillators.ts new file mode 100644 index 0000000..602f042 --- /dev/null +++ b/src/lib/csound-reference/signal-generators-basic-oscillators.ts @@ -0,0 +1,505 @@ +import type { CsoundReference } from './types' + +// Signal Generators:Basic Oscillators +export const signalGeneratorsBasicOscillators: CsoundReference[] = [ +{ + name: 'lfo', + type: 'opcode', + category: 'Signal Generators:Basic Oscillators', + description: 'A low frequency oscillator of various shapes.', + syntax: 'kres = lfo(kamp, kcps [, itype])\n ares = lfo(kamp, kcps [, itype])', + example: '--8<-- "examples/lfo.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'kamp', + description: 'amplitude of output', + type: 'performance' + }, + { + name: 'kcps', + description: 'frequency of oscillator', + type: 'performance' + }, + ], + seeAlso: ['Basic Oscillators'] +}, +{ + name: 'oscbnk', + type: 'opcode', + category: 'Signal Generators:Basic Oscillators', + description: 'Mixes the output of any number of oscillators.', + syntax: 'ares = oscbnk(kcps, kamd, kfmd, kpmd, iovrlap, iseed, kl1minf, kl1maxf, \\\n kl2minf, kl2maxf, ilfomode, keqminf, keqmaxf, keqminl, keqmaxl, \\\n keqminq, keqmaxq, ieqmode, kfn [, il1fn] [, il2fn] [, ieqffn] \\\n [, ieqlfn] [, ieqqfn] [, itabl] [, ioutfn])', + example: '--8<-- "examples/oscbnk.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'iovrlap', + description: 'Number of oscillator units.', + type: 'initialization' + }, + { + name: 'iseed', + description: 'Seed value for random number generator (positive integer in the range 1 to 2147483646 (2 ^ 31 - 2)). _iseed_ <= 0 seeds from the current time.', + type: 'initialization' + }, + { + name: 'ieqmode', + description: 'Parametric equalizer mode', + type: 'initialization' + }, + { + name: 'ilfomode', + description: 'LFO modulation mode, sum of:', + type: 'initialization' + }, + { + name: 'ares', + description: 'Output signal.', + type: 'performance' + }, + { + name: 'kcps', + description: 'Oscillator frequency in Hz.', + type: 'performance' + }, + { + name: 'kamd', + description: 'AM depth (0 - 1).', + type: 'performance' + }, + { + name: 'kfmd', + description: 'FM depth (in Hz).', + type: 'performance' + }, + { + name: 'kpmd', + description: 'Phase modulation depth.', + type: 'performance' + }, + { + name: 'kl1minf', + description: 'LFO1 minimum and maximum frequency in Hz.', + type: 'performance' + }, + { + name: 'kl1maxf', + description: 'LFO1 minimum and maximum frequency in Hz.', + type: 'performance' + }, + { + name: 'kl2minf', + description: 'LFO2 minimum and maximum frequency in Hz. (Note: oscillator and LFO frequencies are allowed to be zero or negative.)', + type: 'performance' + }, + { + name: 'kl2maxf', + description: 'LFO2 minimum and maximum frequency in Hz. (Note: oscillator and LFO frequencies are allowed to be zero or negative.)', + type: 'performance' + }, + { + name: 'keqminf', + description: 'Parametric equalizer minimum and maximum frequency in Hz.', + type: 'performance' + }, + { + name: 'keqmaxf', + description: 'Parametric equalizer minimum and maximum frequency in Hz.', + type: 'performance' + }, + { + name: 'keqminl', + description: 'Parametric equalizer minimum and maximum level.', + type: 'performance' + }, + { + name: 'keqmaxl', + description: 'Parametric equalizer minimum and maximum level.', + type: 'performance' + }, + { + name: 'keqminq', + description: 'Parametric equalizer minimum and maximum Q.', + type: 'performance' + }, + { + name: 'keqmaxq', + description: 'Parametric equalizer minimum and maximum Q.', + type: 'performance' + }, + { + name: 'kfn', + description: 'Oscillator waveform table. Table number can be changed at k-rate (this is useful to select from a set of band-limited tables generated by GEN30, to avoid aliasing). The table is read with linear interpolation.', + type: 'performance' + }, + ], + seeAlso: ['Basic Oscillators'] +}, +{ + name: 'oscil', + type: 'opcode', + category: 'Signal Generators:Basic Oscillators', + description: 'A simple oscillator without any interpolation.', + syntax: 'ares = oscil(xamp, xcps [, ifn, iphs])\n kres = oscil(kamp, kcps [, ifn, iphs])', + example: '--8<-- "examples/oscil.csd"', + rates: ['a-rate', 'k-rate', 'i-rate'], + parameters: [ + { + name: 'ifn', + description: '(optional) function table number. Requires a wrap-around guard point. The table number defaults to -1 which indicates a sinewave.', + type: 'initialization' + }, + { + name: 'kamp', + description: 'amplitude', + type: 'performance' + }, + { + name: 'xamp', + description: 'amplitude', + type: 'performance' + }, + { + name: 'kcps', + description: 'frequency in cycles per second.', + type: 'performance' + }, + { + name: 'xcps', + description: 'frequency in cycles per second.', + type: 'performance' + }, + ], + seeAlso: ['Basic Oscillators'] +}, +{ + name: 'oscil3', + type: 'opcode', + category: 'Signal Generators:Basic Oscillators', + description: 'A simple oscillator with cubic interpolation.', + syntax: 'ares = oscil3(xamp, xcps [, ifn, iphs])\n kres = oscil3(kamp, kcps [, ifn, iphs])', + example: '--8<-- "examples/oscil3.csd"', + rates: ['a-rate', 'k-rate', 'i-rate'], + parameters: [ + { + name: 'kamp', + description: 'amplitude', + type: 'performance' + }, + { + name: 'xamp', + description: 'amplitude', + type: 'performance' + }, + { + name: 'kcps', + description: 'frequency in cycles per second.', + type: 'performance' + }, + { + name: 'xcps', + description: 'frequency in cycles per second.', + type: 'performance' + }, + ], + seeAlso: ['Basic Oscillators'] +}, +{ + name: 'oscili', + type: 'opcode', + category: 'Signal Generators:Basic Oscillators', + description: 'A simple oscillator with linear interpolation.', + syntax: 'ares = oscili(xamp, xcps[, ifn, iphs])\n kres = oscili(kamp, kcps[, ifn, iphs])', + example: '--8<-- "examples/oscili.csd"', + rates: ['a-rate', 'k-rate', 'i-rate'], + parameters: [ + { + name: 'kamp', + description: 'amplitude', + type: 'performance' + }, + { + name: 'xamp', + description: 'amplitude', + type: 'performance' + }, + { + name: 'kcps', + description: 'frequency in cycles per second.', + type: 'performance' + }, + { + name: 'xcps', + description: 'frequency in cycles per second.', + type: 'performance' + }, + ], + seeAlso: ['Basic Oscillators'] +}, +{ + name: 'oscilikt', + type: 'opcode', + category: 'Signal Generators:Basic Oscillators', + description: 'A linearly interpolated oscillator that allows changing the table number at k-rate.', + syntax: 'ares = oscilikt(xamp, xcps, kfn [, iphs] [, istor])\n kres = oscilikt(kamp, kcps, kfn [, iphs] [, istor])', + example: '--8<-- "examples/oscilikt.csd"', + rates: ['a-rate', 'k-rate', 'i-rate'], + parameters: [ + { + name: 'kamp', + description: 'amplitude.', + type: 'performance' + }, + { + name: 'xamp', + description: 'amplitude.', + type: 'performance' + }, + { + name: 'kcps', + description: 'frequency in Hz. Zero and negative values are allowed. However, the absolute value must be less than [sr](../opcodes/sr.md) (and recommended to be less than _sr_/2).', + type: 'performance' + }, + { + name: 'xcps', + description: 'frequency in Hz. Zero and negative values are allowed. However, the absolute value must be less than [sr](../opcodes/sr.md) (and recommended to be less than _sr_/2).', + type: 'performance' + }, + { + name: 'kfn', + description: 'function table number. Can be varied at control rate (useful to morph waveforms, or select from a set of band-limited tables generated by [GEN30](../scoregens/gen30.md)).', + type: 'performance' + }, + ], + seeAlso: ['Basic Oscillators'] +}, +{ + name: 'osciliktp', + type: 'opcode', + category: 'Signal Generators:Basic Oscillators', + description: 'A linearly interpolated oscillator that allows allows phase modulation.', + syntax: 'ares = osciliktp(kcps, kfn, kphs [, istor])', + example: '--8<-- "examples/osciliktp.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'ares', + description: 'audio-rate ouptut signal.', + type: 'performance' + }, + { + name: 'kcps', + description: 'frequency in Hz. Zero and negative values are allowed. However, the absolute value must be less than [sr](../opcodes/sr.md) (and recommended to be less than _sr_/2).', + type: 'performance' + }, + { + name: 'kfn', + description: 'function table number. Can be varied at control rate (useful to morph waveforms, or select from a set of band-limited tables generated by [GEN30](../scoregens/gen30.md)).', + type: 'performance' + }, + { + name: 'kphs', + description: 'phase (k-rate), the expected range is 0 to 1. The absolute value of the difference of the current and previous value of _kphs_ must be less than [ksmps](../opcodes/ksmps.md).', + type: 'performance' + }, + ], + seeAlso: ['Basic Oscillators'] +}, +{ + name: 'oscilikts', + type: 'opcode', + category: 'Signal Generators:Basic Oscillators', + description: 'A linearly interpolated oscillator with sync status that allows changing the table number at k-rate.', + syntax: 'ares = oscilikts(xamp, xcps, kfn, async, kphs [, istor])', + example: '--8<-- "examples/oscilikts.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'xamp', + description: 'amplitude.', + type: 'performance' + }, + { + name: 'xcps', + description: 'frequency in Hz. Zero and negative values are allowed. However, the absolute value must be less than [sr](../opcodes/sr.md) (and recommended to be less than _sr_/2).', + type: 'performance' + }, + { + name: 'kfn', + description: 'function table number. Can be varied at control rate (useful to morph waveforms, or select from a set of band-limited tables generated by [GEN30](../scoregens/gen30.md)).', + type: 'performance' + }, + { + name: 'async', + description: 'any positive value resets the phase of _oscilikts_ to _kphs_. Zero or negative values have no effect.', + type: 'performance' + }, + { + name: 'kphs', + description: 'sets the phase, initially and when it is re-initialized with async.', + type: 'performance' + }, + ], + seeAlso: ['Basic Oscillators'] +}, +{ + name: 'osciln', + type: 'opcode', + category: 'Signal Generators:Basic Oscillators', + description: 'Accesses table values at a user-defined frequency.', + syntax: 'ares = osciln(kamp, ifrq, ifn, itimes)', + example: '--8<-- "examples/osciln.csd"', + rates: ['a-rate', 'k-rate', 'i-rate'], + parameters: [ + { + name: 'ifrq', + description: 'rate and number of times through the stored table.', + type: 'initialization' + }, + { + name: 'itimes', + description: 'rate and number of times through the stored table.', + type: 'initialization' + }, + { + name: 'ifn', + description: 'function table number.', + type: 'initialization' + }, + { + name: 'kamp', + description: 'amplitude factor', + type: 'performance' + }, + ], + seeAlso: ['Table Access'] +}, +{ + name: 'oscils', + type: 'opcode', + category: 'Signal Generators:Basic Oscillators', + description: 'A simple, fast sine oscillator.', + syntax: 'ares = oscils(iamp, icps, iphs [, iflg])', + example: '--8<-- "examples/oscils.csd"', + rates: ['a-rate', 'i-rate'], + parameters: [ + { + name: 'iamp', + description: 'output amplitude.', + type: 'initialization' + }, + { + name: 'icps', + description: 'frequency in Hz (may be zero or negative, however the absolute value must be less than _sr_/2).', + type: 'initialization' + }, + { + name: 'iphs', + description: 'start phase between 0 and 1.', + type: 'initialization' + }, + { + name: 'iflg', + description: 'sum of the following values:', + type: 'initialization' + }, + { + name: 'ares', + description: 'audio output', + type: 'performance' + }, + ], + seeAlso: ['Basic Oscillators'] +}, +{ + name: 'oscilx', + type: 'opcode', + category: 'Signal Generators:Basic Oscillators', + description: 'Same as the [osciln](../opcodes/osciln.md) opcode.', +}, +{ + name: 'poscil', + type: 'opcode', + category: 'Signal Generators:Basic Oscillators', + description: 'High precision oscillator.', + syntax: 'ares = poscil(aamp, acps [, ifn, iphs])\n ares = poscil(aamp, kcps [, ifn, iphs])\n ares = poscil(kamp, acps [, ifn, iphs])\n ares = poscil(kamp, kcps [, ifn, iphs])\n ires = poscil(kamp, kcps [, ifn, iphs])\n kres = poscil(kamp, kcps [, ifn, iphs])', + example: '--8<-- "examples/poscil-modern.csd"', + rates: ['a-rate', 'k-rate', 'i-rate'], + parameters: [ + { + name: 'ifn', + description: '(optional) function table number. This defaults to -1 which indicates a sinewave.', + type: 'initialization' + }, + { + name: 'ares', + description: 'output signal', + type: 'performance' + }, + { + name: 'kamp', + description: 'the amplitude of the output signal.', + type: 'performance' + }, + { + name: 'aamp', + description: 'the amplitude of the output signal.', + type: 'performance' + }, + { + name: 'kcps', + description: 'the frequency of the output signal in cycles per second.', + type: 'performance' + }, + { + name: 'acps', + description: 'the frequency of the output signal in cycles per second.', + type: 'performance' + }, + ], + seeAlso: ['Basic Oscillators'] +}, +{ + name: 'poscil3', + type: 'opcode', + category: 'Signal Generators:Basic Oscillators', + description: 'High precision oscillator with cubic interpolation.', + syntax: 'ares = poscil3(aamp, acps [, ifn, iphs])\n ares = poscil3(aamp, kcps [, ifn, iphs])\n ares = poscil3(kamp, acps [, ifn, iphs])\n ares = poscil3(kamp, kcps [, ifn, iphs])\n ires = poscil3(kamp, kcps [, ifn, iphs])\n kres = poscil3(kamp, kcps [, ifn, iphs])', + example: '--8<-- "examples/poscil3.csd"', + rates: ['a-rate', 'k-rate', 'i-rate'], + parameters: [ + { + name: 'ifn', + description: '(optional) function table number. This defaults to -1 which indicates a sinewave.', + type: 'initialization' + }, + { + name: 'ares', + description: 'output signal', + type: 'performance' + }, + { + name: 'kamp', + description: 'the amplitude of the output signal.', + type: 'performance' + }, + { + name: 'aamp', + description: 'the amplitude of the output signal.', + type: 'performance' + }, + { + name: 'kcps', + description: 'the frequency of the output signal in cycles per second.', + type: 'performance' + }, + { + name: 'acps', + description: 'the frequency of the output signal in cycles per second.', + type: 'performance' + }, + ], + seeAlso: ['Basic Oscillators'] +}, +] diff --git a/src/lib/csound-reference/signal-generators-dynamic-spectrum-oscillators.ts b/src/lib/csound-reference/signal-generators-dynamic-spectrum-oscillators.ts new file mode 100644 index 0000000..5401788 --- /dev/null +++ b/src/lib/csound-reference/signal-generators-dynamic-spectrum-oscillators.ts @@ -0,0 +1,137 @@ +import type { CsoundReference } from './types' + +// Signal Generators:Dynamic Spectrum Oscillators +export const signalGeneratorsDynamicSpectrumOscillators: CsoundReference[] = [ +{ + name: 'buzz', + type: 'opcode', + category: 'Signal Generators:Dynamic Spectrum Oscillators', + description: 'Output is a set of harmonically related sine partials.', + syntax: 'ares = buzz(xamp, xcps, knh, ifn [, iphs])', + example: '--8<-- "examples/buzz-modern.csd"', + rates: ['a-rate', 'i-rate'], + parameters: [ + { + name: 'ifn', + description: 'table number of a stored function containing a sine wave. A large table of at least 8192 points is recommended.', + type: 'initialization' + }, + { + name: 'xamp', + description: 'amplitude', + type: 'performance' + }, + { + name: 'xcps', + description: 'frequency in cycles per second', + type: 'performance' + }, + { + name: 'knh', + description: 'total number of harmonics requested. New in Csound version 3.57, _knh_ defaults to one. If _knh_ is negative, the absolute value is used.', + type: 'performance' + }, + ], + seeAlso: ['Dynamic Spectrum Oscillators'] +}, +{ + name: 'gbuzz', + type: 'opcode', + category: 'Signal Generators:Dynamic Spectrum Oscillators', + description: 'Output is a set of harmonically related cosine partials.', + syntax: 'ares = gbuzz(xamp, xcps, knh, klh, kmul, ifn [, iphs])', + example: '--8<-- "examples/gbuzz.csd"', + rates: ['a-rate', 'i-rate'], + parameters: [ + { + name: 'ifn', + description: 'table number of a stored function containing a cosine wave. A large table of at least 8192 points is recommended.', + type: 'initialization' + }, + { + name: 'knh', + description: 'total number of harmonics requested. If _knh_ is negative, the absolute value is used. If _knh_ is zero, a value of 1 is used.', + type: 'performance' + }, + { + name: 'klh', + description: 'lowest harmonic present. Can be positive, zero or negative. In _gbuzz_ the set of partials can begin at any partial number and proceeds upwards; if _klh_ is negative, all partials below zero will reflect as positive partials without phase change (since cosine is an even function), and will add constructively to any positive partials in the set.', + type: 'performance' + }, + { + name: 'kmul', + description: 'specifies the multiplier in the series of amplitude coefficients. This is a power series: if the _klh_th partial has a strength coefficient of A, the (_klh_ + n)th partial will have a coefficient of A * (_kmul_ ** n), i.e. strength values trace an exponential curve. _kmul_ may be positive, zero or negative, and is not restricted to integers.', + type: 'performance' + }, + ], + seeAlso: ['Dynamic Spectrum Oscillators'] +}, +{ + name: 'mpulse', + type: 'opcode', + category: 'Signal Generators:Dynamic Spectrum Oscillators', + description: 'Generates a set of impulses.', + syntax: 'ares = mpulse(kamp, kintvl [, ioffset])', + example: '--8<-- "examples/mpulse.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'kamp', + description: 'amplitude of the impulses generated', + type: 'performance' + }, + { + name: 'kintvl', + description: 'Interval of time in seconds (or samples if _kintvl_ is negative) to the next pulse.', + type: 'performance' + }, + ], + seeAlso: ['Dynamic Spectrum Oscillators'] +}, +{ + name: 'squinewave', + type: 'opcode', + category: 'Signal Generators:Dynamic Spectrum Oscillators', + description: 'A mostly bandlimited shape-shifting square-pulse-saw-sinewave oscillator with hardsync.', + syntax: 'aout [, asyncout] = squinewave(acps, aClip, aSkew, asyncin [, iMinSweep] [, iphase])\n aout [, asyncout] = squinewave(acps, aClip, aSkew [, ksyncin] [, iMinSweep] [, iphase])', + example: '--8<-- "examples/squinewave.csd"', + parameters: [ + { + name: 'aout', + description: 'audio output, normalized +/-1', + type: 'performance' + }, + { + name: 'asyncout', + description: '(optional) - Sync signal: 1 at endpoint of each cycle, else 0.', + type: 'performance' + }, + { + name: 'acps', + description: 'frequency. Range 0-anything; negative freq not implemented.', + type: 'performance' + }, + { + name: 'aClip', + description: '"squareness" of waveform shape. Range 0-1. Clip 0 is sinewave (or saw), clip 1 is squarewave (or pulse).', + type: 'performance' + }, + { + name: 'aSkew', + description: 'symmetry of waveform shape. Range -1 to +1. Skew = 0 is symmetric like sine or square. Skew +1 or -1 is right/left-facing saw or pulse.', + type: 'performance' + }, + { + name: 'asyncin', + description: '(optional, ignored if not a-rate) - when >= 1, waveform quickly sweeps to phase 0. Sweep length is 0 to about 1.5*iMinSweep samples depending on current phase.', + type: 'performance' + }, + { + name: 'ksyncin', + description: '(optional, ignored if not a-rate) - when >= 1, waveform quickly sweeps to phase 0. Sweep length is 0 to about 1.5*iMinSweep samples depending on current phase.', + type: 'performance' + }, + ], + seeAlso: ['Dynamic Spectrum Oscillators'] +}, +] diff --git a/src/lib/csound-reference/signal-generators-envelope-generators.ts b/src/lib/csound-reference/signal-generators-envelope-generators.ts new file mode 100644 index 0000000..44524a8 --- /dev/null +++ b/src/lib/csound-reference/signal-generators-envelope-generators.ts @@ -0,0 +1,341 @@ +import type { CsoundReference } from './types' + +// Signal Generators:Envelope Generators +export const signalGeneratorsEnvelopeGenerators: CsoundReference[] = [ +{ + name: 'adsr', + type: 'opcode', + category: 'Signal Generators:Envelope Generators', + description: 'Calculates the classical ADSR envelope using linear segments.', + syntax: 'ares = adsr(iatt, idec, islev, irel [, idel])\n kres = adsr(iatt, idec, islev, irel [, idel])', + example: '--8<-- "examples/adsr-modern.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'iatt', + description: 'duration of attack phase', + type: 'initialization' + }, + { + name: 'idec', + description: 'duration of decay', + type: 'initialization' + }, + { + name: 'islev', + description: 'level for sustain phase', + type: 'initialization' + }, + { + name: 'irel', + description: 'duration of release phase', + type: 'initialization' + }, + { + name: 'idel', + description: 'period of zero before the envelope starts', + type: 'initialization' + }, + ], + seeAlso: ['Envelope Generators'] +}, +{ + name: 'envlpx', + type: 'opcode', + category: 'Signal Generators:Envelope Generators', + description: 'Applies an envelope consisting of 3 segments.', + syntax: 'ares = envlpx(xamp, irise, idur, idec, ifn, iatss, iatdec [, ixmod])\n kres = envlpx(kamp, irise, idur, idec, ifn, iatss, iatdec [, ixmod])', + example: '--8<-- "examples/envlpx.csd"', + rates: ['a-rate', 'k-rate', 'i-rate'], + parameters: [ + { + name: 'irise', + description: 'rise time in seconds. A zero or negative value signifies no rise modification.', + type: 'initialization' + }, + { + name: 'idur', + description: 'overall duration in seconds. A zero or negative value will cause initialization to be skipped.', + type: 'initialization' + }, + { + name: 'idec', + description: 'decay time in seconds. Zero means no decay. An _idec_ > _idur_ will cause a truncated decay.', + type: 'initialization' + }, + { + name: 'ifn', + description: 'function table number of stored rise shape with extended guard point.', + type: 'initialization' + }, + { + name: 'iatss', + description: 'the ratio of the final value of the pseudo-steady-state period to the value at its beginning (i.e the attenuation from the end of the rise segment to the start of the decay). A ratio greater than 1 causes an exponential growth and a ratio less than 1 creates an exponential decay. A ratio of 1 will maintain a true steady state at the last rise value. Note that this attenuation is not at a fixed rate (as in a piano), but is sensitive to a note\'s duration. However, if _iatss_ is negative (or if steady state < 4 k-periods) a fixed attenuation rate of _abs_(_iatss_) per second will be used. 0 is illegal.', + type: 'initialization' + }, + { + name: 'iatdec', + description: 'the ratio of the value at the end of the decay period to the value at its beginning (the end of the steady-state segment) . It must be positive and is normally of the order of .01. A large or excessively small value is apt to produce a cutoff which is audible. A zero or negative value is illegal.', + type: 'initialization' + }, + { + name: 'kamp', + description: 'input amplitude signal.', + type: 'performance' + }, + { + name: 'xamp', + description: 'input amplitude signal.', + type: 'performance' + }, + ], + seeAlso: ['Envelope Generators'] +}, +{ + name: 'envlpxr', + type: 'opcode', + category: 'Signal Generators:Envelope Generators', + description: 'The _envlpx_ opcode with a final release segment.', + syntax: 'ares = envlpxr(xamp, irise, idec, ifn, iatss, iatdec [, ixmod] [,irind])\n kres = envlpxr(kamp, irise, idec, ifn, iatss, iatdec [, ixmod] [,irind])', + example: '--8<-- "examples/envlpxr.csd"', + rates: ['a-rate', 'k-rate', 'i-rate'], + parameters: [ + { + name: 'irise', + description: 'rise time in seconds. A zero or negative value signifies no rise modification.', + type: 'initialization' + }, + { + name: 'idec', + description: 'decay time in seconds. Zero means no decay.', + type: 'initialization' + }, + { + name: 'ifn', + description: 'function table number of stored rise shape with extended guard point.', + type: 'initialization' + }, + { + name: 'iatss', + description: 'attenuation factor determining the exponential change in value over time during the pseudo steady state period between the end of the rise and the beginning of the decay (at the note\'s release). A factor greater than 1 causes an exponential growth and a factor less than 1 creates an exponential decay. A factor of 1 will maintain a true steady state at the last rise value; 0 is illegal. The value will change by _abs_(_iatss_) per second.', + type: 'initialization' + }, + { + name: 'iatdec', + description: 'the ratio of the value at the end of the decay period to the value at its beginning (when the note is released). It must be positive and is normally of the order of .01. A large or excessively small value is apt to produce a cutoff which is audible. A zero or negative value is illegal.', + type: 'initialization' + }, + { + name: 'kamp', + description: 'input amplitude signal.', + type: 'performance' + }, + { + name: 'xamp', + description: 'input amplitude signal.', + type: 'performance' + }, + ], + seeAlso: ['Envelope Generators'] +}, +{ + name: 'gtadsr', + type: 'opcode', + category: 'Signal Generators:Envelope Generators', + description: 'A gated linear attack-decay-sustain with exponential release.', + syntax: 'ares = gtadsr(asig, katt, kdec, ksus, krel, kgate)\n xres = gtadsr(kamp, katt, kdec, ksus, krel, kgate)', + example: '--8<-- "examples/gtadsr.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'x', + description: 'output signal (k or a-rate)', + type: 'performance' + }, + { + name: 'ares', + description: 'output signal (k or a-rate)', + type: 'performance' + }, + { + name: 'asig', + description: 'input signal (envelope as an amplitude processor)', + type: 'performance' + }, + { + name: 'kamp', + description: 'maximum amplitude (envelope as a signal generator)', + type: 'performance' + }, + { + name: 'katt', + description: 'duration of attack phase', + type: 'performance' + }, + { + name: 'kdec', + description: 'duration of decay', + type: 'performance' + }, + { + name: 'ksus', + description: 'level for sustain phase (in the range 0 - 1)', + type: 'performance' + }, + { + name: 'krel', + description: 'duration of release phase', + type: 'performance' + }, + { + name: 'kgate', + description: 'gate signal (0 = low, > 0 high).', + type: 'performance' + }, + ], + seeAlso: ['Envelope Generators'] +}, +{ + name: 'linen', + type: 'opcode', + category: 'Signal Generators:Envelope Generators', + description: 'Applies a straight line rise and decay pattern to an input amp signal.', + syntax: 'ares = linen(xamp, irise, idur, idec)\n kres = linen(kamp, irise, idur, idec)', + example: '--8<-- "examples/linen.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'irise', + description: 'rise time in seconds. A zero or negative value signifies no rise modification.', + type: 'initialization' + }, + { + name: 'idur', + description: 'overall duration in seconds. A zero or negative value will cause initialization to be skipped.', + type: 'initialization' + }, + { + name: 'idec', + description: 'decay time in seconds. Zero means no decay. An _idec_ > _idur_ will cause a truncated decay.', + type: 'initialization' + }, + { + name: 'kamp', + description: 'input amplitude signal.', + type: 'performance' + }, + { + name: 'xamp', + description: 'input amplitude signal.', + type: 'performance' + }, + ], + seeAlso: ['Envelope Generators'] +}, +{ + name: 'linenr', + type: 'opcode', + category: 'Signal Generators:Envelope Generators', + description: 'The _linen_ opcode extended with a final release segment.', + syntax: 'ares = linenr(xamp, irise, idec, iatdec)\n kres = linenr(kamp, irise, idec, iatdec)', + example: '--8<-- "examples/linenr.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'irise', + description: 'rise time in seconds. A zero or negative value signifies no rise modification.', + type: 'initialization' + }, + { + name: 'idec', + description: 'decay time in seconds. Zero means no decay.', + type: 'initialization' + }, + { + name: 'iatdec', + description: 'attenuation factor by which the closing steady state value is reduced exponentially over the decay period. This value must be positive and is normally of the order of .01. A large or excessively small value is apt to produce a cutoff which is audible. A zero or negative value is illegal.', + type: 'initialization' + }, + { + name: 'kamp', + description: 'input amplitude signal.', + type: 'performance' + }, + { + name: 'xamp', + description: 'input amplitude signal.', + type: 'performance' + }, + ], + seeAlso: ['Envelope Generators'] +}, +{ + name: 'madsr', + type: 'opcode', + category: 'Signal Generators:Envelope Generators', + description: 'Calculates the classical ADSR envelope using the [linsegr](../opcodes/linsegr.md) mechanism.', + syntax: 'ares = madsr(iatt, idec, islev, irel [, idel] [, ireltim])\n kres = madsr(iatt, idec, islev, irel [, idel] [, ireltim])', + example: '--8<-- "examples/madsr.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'iatt', + description: 'duration of attack phase', + type: 'initialization' + }, + { + name: 'idec', + description: 'duration of decay', + type: 'initialization' + }, + { + name: 'islev', + description: 'level for sustain phase', + type: 'initialization' + }, + { + name: 'irel', + description: 'duration of release phase.', + type: 'initialization' + }, + { + name: 'idel', + description: 'period of zero before the envelope starts', + type: 'initialization' + }, + ], + seeAlso: ['Envelope Generators'] +}, +{ + name: 'mxadsr', + type: 'opcode', + category: 'Signal Generators:Envelope Generators', + description: 'Calculates the classical ADSR envelope using the [expsegr](../opcodes/expsegr.md) mechanism.', + syntax: 'ares = mxadsr(iatt, idec, islev, irel [, idel] [, ireltim])\n kres = mxadsr(iatt, idec, islev, irel [, idel] [, ireltim])', + example: '--8<-- "examples/mxadsr.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'iatt', + description: 'duration of attack phase', + type: 'initialization' + }, + { + name: 'idec', + description: 'duration of decay', + type: 'initialization' + }, + { + name: 'islev', + description: 'level for sustain phase', + type: 'initialization' + }, + { + name: 'irel', + description: 'duration of release phase', + type: 'initialization' + }, + ], + seeAlso: ['Envelope Generators'] +}, +] diff --git a/src/lib/csound-reference/signal-generators-fm-synthesis.ts b/src/lib/csound-reference/signal-generators-fm-synthesis.ts new file mode 100644 index 0000000..7869318 --- /dev/null +++ b/src/lib/csound-reference/signal-generators-fm-synthesis.ts @@ -0,0 +1,510 @@ +import type { CsoundReference } from './types' + +// Signal Generators:FM Synthesis +export const signalGeneratorsFmSynthesis: CsoundReference[] = [ +{ + name: 'crossfm', + type: 'opcode', + category: 'Signal Generators:FM Synthesis', + description: 'Two oscillators, mutually frequency and/or phase modulated by each other.', + syntax: 'a1, a2 = crossfm(xfrq1, xfrq2, xndx1, xndx2, kcps, ifn1, ifn2 [, iphs1] [, iphs2])\n a1, a2 = crossfmi(xfrq1, xfrq2, xndx1, xndx2, kcps, ifn1, ifn2 [, iphs1] [, iphs2])\n a1, a2 = crosspm(xfrq1, xfrq2, xndx1, xndx2, kcps, ifn1, ifn2 [, iphs1] [, iphs2])\n a1, a2 = crosspmi(xfrq1, xfrq2, xndx1, xndx2, kcps, ifn1, ifn2 [, iphs1] [, iphs2])\n a1, a2 = crossfmpm(xfrq1, xfrq2, xndx1, xndx2, kcps, ifn1, ifn2 [, iphs1] [, iphs2])\n a1, a2 = crossfmpmi(xfrq1, xfrq2, xndx1, xndx2, kcps, ifn1, ifn2 [, iphs1] [, iphs2])', + example: '--8<-- "examples/crossfm.csd"', + rates: ['k-rate'], + parameters: [ + { + name: 'ifn1', + description: 'function table number for oscillator #1. Requires a wrap-around guard point.', + type: 'initialization' + }, + { + name: 'ifn2', + description: 'function table number for oscillator #2. Requires a wrap-around guard point.', + type: 'initialization' + }, + { + name: 'xfrq1', + description: 'a factor that, when multipled by the _kcps_ parameter, gives the frequency of oscillator #1.', + type: 'performance' + }, + { + name: 'xfrq2', + description: 'a factor that, when multipled by the _kcps_ parameter, gives the frequency of oscillator #2.', + type: 'performance' + }, + { + name: 'xndx1', + description: 'the index of the modulation of oscillator #2 by oscillator #1.', + type: 'performance' + }, + { + name: 'xndx2', + description: 'the index of the modulation of oscillator #1 by oscillator #2.', + type: 'performance' + }, + { + name: 'kcps', + description: 'a common denominator, in cycles per second, for both oscillators frequencies.', + type: 'performance' + }, + ], + seeAlso: ['FM Synthesis', 'http://en.wikipedia.org/wiki/Frequency_modulation_synthesis', 'http://www.csoundjournal.com/issue12/crossfm.html'] +}, +{ + name: 'fmb3', + type: 'opcode', + category: 'Signal Generators:FM Synthesis', + description: 'Uses FM synthesis to create a Hammond B3 organ sound.', + syntax: 'ares = fmb3(kamp, kfreq, kc1, kc2, kvdepth, kvrate[, ifn1, ifn2, ifn3, \\\n ifn4, ivfn])', + example: '--8<-- "examples/fmb3.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'ifn1', + description: 'sine wave * _ifn2_ -- sine wave * _ifn3_ -- sine wave * _ifn4_ -- sine wave', + type: 'initialization' + }, + { + name: 'kamp', + description: 'Amplitude of note.', + type: 'performance' + }, + { + name: 'kfreq', + description: 'Frequency of note played.', + type: 'performance' + }, + { + name: 'kc1', + description: 'Controls for the synthesizer:', + type: 'performance' + }, + { + name: 'kc2', + description: 'Controls for the synthesizer:', + type: 'performance' + }, + { + name: 'kc1', + description: 'Total mod index * _kc2_ -- Crossfade of two modulators * _Algorithm_ -- 4', + type: 'performance' + }, + { + name: 'kvdepth', + description: 'Vibrator depth', + type: 'performance' + }, + { + name: 'kvrate', + description: 'Vibrator rate', + type: 'performance' + }, + ], + seeAlso: ['FM Synthesis', 'http://en.wikipedia.org/wiki/Frequency_modulation_synthesis'] +}, +{ + name: 'fmbell', + type: 'opcode', + category: 'Signal Generators:FM Synthesis', + description: 'Uses FM synthesis to create a tublar bell sound.', + syntax: 'ares = fmbell(kamp, kfreq, kc1, kc2, kvdepth, kvrate[, ifn1, ifn2, ifn3, \\\n ifn4, ivfn, isus])', + example: '--8<-- "examples/fmbell.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'ifn1', + description: 'sine wave * _ifn2_ -- sine wave * _ifn3_ -- sine wave * _ifn4_ -- sine wave', + type: 'initialization' + }, + { + name: 'kamp', + description: 'Amplitude of note.', + type: 'performance' + }, + { + name: 'kfreq', + description: 'Frequency of note played.', + type: 'performance' + }, + { + name: 'kc1', + description: 'Controls for the synthesizer:', + type: 'performance' + }, + { + name: 'kc2', + description: 'Controls for the synthesizer:', + type: 'performance' + }, + { + name: 'kc1', + description: 'Mod index 1 * _kc2_ -- Crossfade of two outputs * _Algorithm_ -- 5', + type: 'performance' + }, + { + name: 'kvdepth', + description: 'Vibrator depth', + type: 'performance' + }, + { + name: 'kvrate', + description: 'Vibrator rate', + type: 'performance' + }, + ], + seeAlso: ['FM Synthesis', 'http://en.wikipedia.org/wiki/Frequency_modulation_synthesis'] +}, +{ + name: 'fmmetal', + type: 'opcode', + category: 'Signal Generators:FM Synthesis', + description: 'Uses FM synthesis to create a “Heavy Metal” sound.', + syntax: 'ares = fmmetal(kamp, kfreq, kc1, kc2, kvdepth, kvrate, ifn1, ifn2, ifn3, \\\n ifn4, ivfn)', + example: '--8<-- "examples/fmmetal.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'ifn1', + description: 'sine wave * _ifn2_ -- [twopeaks.aiff](../examples/twopeaks.aiff) * _ifn3_ -- [twopeaks.aiff](../examples/twopeaks.aiff) * _ifn4_ -- sine wave', + type: 'initialization' + }, + { + name: 'kamp', + description: 'Amplitude of note.', + type: 'performance' + }, + { + name: 'kfreq', + description: 'Frequency of note played.', + type: 'performance' + }, + { + name: 'kc1', + description: 'Controls for the synthesizer:', + type: 'performance' + }, + { + name: 'kc2', + description: 'Controls for the synthesizer:', + type: 'performance' + }, + { + name: 'kc1', + description: 'Total mod index * _kc2_ -- Crossfade of two modulators * _Algorithm_ -- 3', + type: 'performance' + }, + { + name: 'kvdepth', + description: 'Vibrator depth', + type: 'performance' + }, + { + name: 'kvrate', + description: 'Vibrator rate', + type: 'performance' + }, + ], + seeAlso: ['FM Synthesis', 'http://en.wikipedia.org/wiki/Frequency_modulation_synthesis'] +}, +{ + name: 'fmpercfl', + type: 'opcode', + category: 'Signal Generators:FM Synthesis', + description: 'Uses FM synthesis to create a percussive flute sound.', + syntax: 'ares = fmpercfl(kamp, kfreq, kc1, kc2, kvdepth, kvrate[, ifn1, ifn2, \\\n ifn3, ifn4, ivfn])', + example: '--8<-- "examples/fmpercfl.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'ifn1', + description: 'sine wave * _ifn2_ -- sine wave * _ifn3_ -- sine wave * _ifn4_ -- sine wave', + type: 'initialization' + }, + { + name: 'kamp', + description: 'Amplitude of note.', + type: 'performance' + }, + { + name: 'kfreq', + description: 'Frequency of note played.', + type: 'performance' + }, + { + name: 'kc1', + description: 'Controls for the synthesizer:', + type: 'performance' + }, + { + name: 'kc2', + description: 'Controls for the synthesizer:', + type: 'performance' + }, + { + name: 'kc1', + description: 'Total mod index * _kc2_ -- Crossfade of two modulators * _Algorithm_ -- 4', + type: 'performance' + }, + { + name: 'kvdepth', + description: 'Vibrator depth', + type: 'performance' + }, + { + name: 'kvrate', + description: 'Vibrator rate', + type: 'performance' + }, + ], + seeAlso: ['FM Synthesis', 'http://en.wikipedia.org/wiki/Frequency_modulation_synthesis'] +}, +{ + name: 'fmrhode', + type: 'opcode', + category: 'Signal Generators:FM Synthesis', + description: 'Uses FM synthesis to create a Fender Rhodes electric piano sound.', + syntax: 'ares = fmrhode(kamp, kfreq, kc1, kc2, kvdepth, kvrate, ifn1, ifn2, \\\n ifn3, ifn4, ivfn)', + example: '--8<-- "examples/fmrhode.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'ifn1', + description: 'sine wave * _ifn2_ -- sine wave * _ifn3_ -- sine wave * _ifn4_ -- [fwavblnk.aiff](../examples/fwavblnk.aiff)', + type: 'initialization' + }, + { + name: 'kamp', + description: 'Amplitude of note.', + type: 'performance' + }, + { + name: 'kfreq', + description: 'Frequency of note played.', + type: 'performance' + }, + { + name: 'kc1', + description: 'Controls for the synthesizer:', + type: 'performance' + }, + { + name: 'kc2', + description: 'Controls for the synthesizer:', + type: 'performance' + }, + { + name: 'kc1', + description: 'Mod index 1 * _kc2_ -- Crossfade of two outputs * _Algorithm_ -- 5', + type: 'performance' + }, + { + name: 'kvdepth', + description: 'Vibrator depth', + type: 'performance' + }, + { + name: 'kvrate', + description: 'Vibrator rate', + type: 'performance' + }, + ], + seeAlso: ['FM Synthesis', 'http://en.wikipedia.org/wiki/Frequency_modulation_synthesis'] +}, +{ + name: 'fmvoice', + type: 'opcode', + category: 'Signal Generators:FM Synthesis', + description: 'FM Singing Voice Synthesis.', + syntax: 'ares = fmvoice(kamp, kfreq, kvowel, ktilt, kvibamt, kvibrate[, ifn1, \\\n ifn2, ifn3, ifn4, ivibfn])', + example: '--8<-- "examples/fmvoice.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'ifn1', + description: 'Tables, usually of sinewaves. The last is for vibrato', + type: 'initialization' + }, + { + name: 'ifn2', + description: 'Tables, usually of sinewaves. The last is for vibrato', + type: 'initialization' + }, + { + name: 'ifn3', + description: 'Tables, usually of sinewaves. The last is for vibrato', + type: 'initialization' + }, + { + name: 'ifn3', + description: 'Tables, usually of sinewaves. The last is for vibrato', + type: 'initialization' + }, + { + name: 'ivibfn', + description: 'Tables, usually of sinewaves. The last is for vibrato', + type: 'initialization' + }, + { + name: 'kamp', + description: 'Amplitude of note.', + type: 'performance' + }, + { + name: 'kfreq', + description: 'Frequency of note played.', + type: 'performance' + }, + { + name: 'kvowel', + description: 'the vowel being sung, in the range 0-64', + type: 'performance' + }, + { + name: 'ktilt', + description: 'the spectral tilt of the sound in the range 0 to 99', + type: 'performance' + }, + { + name: 'kvibamt', + description: 'Depth of vibrato', + type: 'performance' + }, + { + name: 'kvibrate', + description: 'Rate of vibrato', + type: 'performance' + }, + ], + seeAlso: ['FM Synthesis', 'http://en.wikipedia.org/wiki/Frequency_modulation_synthesis'] +}, +{ + name: 'fmwurlie', + type: 'opcode', + category: 'Signal Generators:FM Synthesis', + description: 'Uses FM synthesis to create a Wurlitzer electric piano sound.', + syntax: 'ares = fmwurlie(kamp, kfreq, kc1, kc2, kvdepth, kvrate, ifn1, ifn2, ifn3, \\\n ifn4, ivfn)', + example: '--8<-- "examples/fmwurlie.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'ifn1', + description: 'sine wave * _ifn2_ -- sine wave * _ifn3_ -- sine wave * _ifn4_ -- [fwavblnk.aiff](../examples/fwavblnk.aiff)', + type: 'initialization' + }, + { + name: 'kamp', + description: 'Amplitude of note.', + type: 'performance' + }, + { + name: 'kfreq', + description: 'Frequency of note played.', + type: 'performance' + }, + { + name: 'kc1', + description: 'Controls for the synthesizer:', + type: 'performance' + }, + { + name: 'kc2', + description: 'Controls for the synthesizer:', + type: 'performance' + }, + { + name: 'kc1', + description: 'Mod index 1 * _kc2_ -- Crossfade of two outputs * _Algorithm_ -- 5', + type: 'performance' + }, + { + name: 'kvdepth', + description: 'Vibrator depth', + type: 'performance' + }, + { + name: 'kvrate', + description: 'Vibrator rate', + type: 'performance' + }, + ], + seeAlso: ['FM Synthesis', 'http://en.wikipedia.org/wiki/Frequency_modulation_synthesis'] +}, +{ + name: 'foscil', + type: 'opcode', + category: 'Signal Generators:FM Synthesis', + description: 'A basic frequency modulated oscillator.', + syntax: 'ares = foscil(xamp, kcps, xcar, xmod, kndx [, ifn , iphs])', + example: '--8<-- "examples/foscil.csd"', + rates: ['a-rate', 'k-rate', 'i-rate'], + parameters: [ + { + name: 'xamp', + description: 'the amplitude of the output signal.', + type: 'performance' + }, + { + name: 'kcps', + description: 'a common denominator, in cycles per second, for the carrier and modulating frequencies.', + type: 'performance' + }, + { + name: 'xcar', + description: 'a factor that, when multiplied by the _kcps_ parameter, gives the carrier frequency.', + type: 'performance' + }, + { + name: 'xmod', + description: 'a factor that, when multiplied by the _kcps_ parameter, gives the modulating frequency.', + type: 'performance' + }, + { + name: 'kndx', + description: 'the modulation index.', + type: 'performance' + }, + { + name: 'xcar', + description: '_n_ * _xmod_), _n_ = 0,1,2,... The input _kndx_ is the index of modulation (usually time-varying and ranging 0 to 4 or so) which determines the spread of acoustic energy over the partial positions given by _n_ = 0,1,2,.., etc. _ifn_ should point to a stored sine wave. Previous to version 3.50, _xcar_ and _xmod_ could be k-rate only.', + type: 'performance' + }, + ], + seeAlso: ['FM Synthesis', 'http://en.wikipedia.org/wiki/Frequency_modulation_synthesis'] +}, +{ + name: 'foscili', + type: 'opcode', + category: 'Signal Generators:FM Synthesis', + description: 'Basic frequency modulated oscillator with linear interpolation.', + syntax: 'ares = foscili(xamp, kcps, xcar, xmod, kndx [, ifn, iphs])', + example: '--8<-- "examples/foscili.csd"', + rates: ['a-rate', 'k-rate', 'i-rate'], + parameters: [ + { + name: 'xamp', + description: 'the amplitude of the output signal.', + type: 'performance' + }, + { + name: 'kcps', + description: 'a common denominator, in cycles per second, for the carrier and modulating frequencies.', + type: 'performance' + }, + { + name: 'xcar', + description: 'a factor that, when multiplied by the _kcps_ parameter, gives the carrier frequency.', + type: 'performance' + }, + { + name: 'xmod', + description: 'a factor that, when multiplied by the _kcps_ parameter, gives the modulating frequency.', + type: 'performance' + }, + { + name: 'kndx', + description: 'the modulation index.', + type: 'performance' + }, + ], + seeAlso: ['FM Synthesis', 'http://en.wikipedia.org/wiki/Frequency_modulation_synthesis'] +}, +] diff --git a/src/lib/csound-reference/signal-generators-granular-synthesis.ts b/src/lib/csound-reference/signal-generators-granular-synthesis.ts new file mode 100644 index 0000000..05db354 --- /dev/null +++ b/src/lib/csound-reference/signal-generators-granular-synthesis.ts @@ -0,0 +1,1004 @@ +import type { CsoundReference } from './types' + +// Signal Generators:Granular Synthesis +export const signalGeneratorsGranularSynthesis: CsoundReference[] = [ +{ + name: 'diskgrain', + type: 'opcode', + category: 'Signal Generators:Granular Synthesis', + description: 'Synchronous granular synthesis, using a soundfile as source.', + syntax: 'asig = diskgrain(Sfname, kamp, kfreq, kpitch, kgrsize, kprate, \\\n ifun, iolaps [,imaxgrsize , ioffset])', + example: '--8<-- "examples/diskgrain.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'Sfilename', + description: 'source soundfile.', + type: 'initialization' + }, + { + name: 'ifun', + description: 'grain envelope function table.', + type: 'initialization' + }, + { + name: 'iolaps', + description: 'maximum number of overlaps, max(kfreq)*max(kgrsize). Estimating a large value should not affect performance, but exceeding this value will probably have disastrous consequences.', + type: 'initialization' + }, + { + name: 'imaxgrsize', + description: 'max grain size in secs (default 1.0).', + type: 'initialization' + }, + { + name: 'ioffset', + description: 'start offset in secs from beginning of file (default: 0).', + type: 'initialization' + }, + { + name: 'kamp', + description: 'amplitude scaling', + type: 'performance' + }, + { + name: 'kfreq', + description: 'frequency of grain generation, or density, in grains/sec.', + type: 'performance' + }, + { + name: 'kpitch', + description: 'grain pitch scaling (1=normal pitch, < 1 lower, > 1 higher; negative, backwards)', + type: 'performance' + }, + { + name: 'kgrsize', + description: 'grain size in secs.', + type: 'performance' + }, + { + name: 'kprate', + description: 'readout pointer rate, in grains. The value of 1 will advance the reading pointer 1 grain ahead in the source table. Larger values will time-compress and smaller values will time-expand the source signal. Negative values will cause the pointer to run backwards and zero will freeze it.', + type: 'performance' + }, + ], + seeAlso: ['Granular Synthesis'] +}, +{ + name: 'fof', + type: 'opcode', + category: 'Signal Generators:Granular Synthesis', + description: 'Produces sinusoid bursts useful for formant and granular synthesis.', + syntax: 'ares = fof(xamp, xfund, xform, koct, kband, kris, kdur, kdec, iolaps, \\\n ifna, ifnb, itotdur [, iphs] [, ifmode] [, iskip])', + example: '--8<-- "examples/fof.csd"', + rates: ['a-rate', 'i-rate'], + parameters: [ + { + name: 'iolaps', + description: 'number of preallocated spaces needed to hold overlapping burst data. Overlaps are frequency dependent, and the space required depends on the maximum value of _xfund * kdur_. Can be over-estimated at no computation cost. Uses less than 50 bytes of memory per _iolap_.', + type: 'initialization' + }, + { + name: 'ifna', + description: 'table numbers of two stored functions. The first is a sine table for sineburst synthesis (size of at least 4096 recommended). The second is a rise shape, used forwards and backwards to shape the sineburst rise and decay; this may be linear ([GEN07](../scoregens/gen07.md)) or perhaps a sigmoid ([GEN19](../scoregens/gen19.md)).', + type: 'initialization' + }, + { + name: 'ifnb', + description: 'table numbers of two stored functions. The first is a sine table for sineburst synthesis (size of at least 4096 recommended). The second is a rise shape, used forwards and backwards to shape the sineburst rise and decay; this may be linear ([GEN07](../scoregens/gen07.md)) or perhaps a sigmoid ([GEN19](../scoregens/gen19.md)).', + type: 'initialization' + }, + { + name: 'itotdur', + description: 'total time during which this _fof_ will be active. Normally set to p3. No new sineburst is created if it cannot complete its _kdur_ within the remaining _itotdur_.', + type: 'initialization' + }, + { + name: 'xamp', + description: 'peak amplitude of each sineburst, observed at the true end of its rise pattern. The rise may exceed this value given a large bandwidth (say, Q < 10) and/or when the bursts are overlapping.', + type: 'performance' + }, + { + name: 'xfund', + description: 'the fundamental frequency (in Hertz) of the impulses that create new sinebursts.', + type: 'performance' + }, + { + name: 'xform', + description: 'the formant frequency, i.e. freq of the sinusoid burst induced by each _xfund_ impulse. This frequency can be fixed for each burst or can vary continuously (see _ifmode_).', + type: 'performance' + }, + { + name: 'koct', + description: 'octaviation index, normally zero. If greater than zero, lowers the effective _xfund_ frequency by attenuating odd-numbered sinebursts. Whole numbers are full octaves, fractions transitional.', + type: 'performance' + }, + { + name: 'kband', + description: 'the formant bandwidth (at -6dB), expressed in Hz. The bandwidth determines the rate of exponential decay throughout the sineburst, before the enveloping described below is applied.', + type: 'performance' + }, + { + name: 'kris', + description: 'rise, overall duration, and decay times (in seconds) of the sinusoid burst. These values apply an enveloped duration to each burst, in similar fashion to a Csound _linen_ generator but with rise and decay shapes derived from the _ifnb_ input. _kris_ inversely determines the skirtwidth (at -40 dB) of the induced formant region. _kdur_ affects the density of sineburst overlaps, and thus the speed of computation. Typical values for vocal imitation are .003,.02,.007.', + type: 'performance' + }, + { + name: 'kdur', + description: 'rise, overall duration, and decay times (in seconds) of the sinusoid burst. These values apply an enveloped duration to each burst, in similar fashion to a Csound _linen_ generator but with rise and decay shapes derived from the _ifnb_ input. _kris_ inversely determines the skirtwidth (at -40 dB) of the induced formant region. _kdur_ affects the density of sineburst overlaps, and thus the speed of computation. Typical values for vocal imitation are .003,.02,.007.', + type: 'performance' + }, + { + name: 'kdec', + description: 'rise, overall duration, and decay times (in seconds) of the sinusoid burst. These values apply an enveloped duration to each burst, in similar fashion to a Csound _linen_ generator but with rise and decay shapes derived from the _ifnb_ input. _kris_ inversely determines the skirtwidth (at -40 dB) of the induced formant region. _kdur_ affects the density of sineburst overlaps, and thus the speed of computation. Typical values for vocal imitation are .003,.02,.007.', + type: 'performance' + }, + ], + seeAlso: ['Granular Synthesis'] +}, +{ + name: 'fof2', + type: 'opcode', + category: 'Signal Generators:Granular Synthesis', + description: 'Produces sinusoid bursts including k-rate incremental indexing with each successive burst.', + syntax: 'ares = fof2(xamp, xfund, xform, koct, kband, kris, kdur, kdec, iolaps, \\\n ifna, ifnb, itotdur, kphs, kgliss [, iskip])', + example: '--8<-- "examples/fof2.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'iolaps', + description: 'number of preallocated spaces needed to hold overlapping burst data. Overlaps are frequency dependent, and the space required depends on the maximum value of _xfund * kdur_. Can be over-estimated at no computation cost. Uses less than 50 bytes of memory per _iolap_.', + type: 'initialization' + }, + { + name: 'ifna', + description: 'table numbers of two stored functions. The first is a sine table for sineburst synthesis (size of at least 4096 recommended). The second is a rise shape, used forwards and backwards to shape the sineburst rise and decay; this may be linear ([GEN07](../scoregens/gen07.md)) or perhaps a sigmoid ([GEN19](../scoregens/gen19.md)).', + type: 'initialization' + }, + { + name: 'ifnb', + description: 'table numbers of two stored functions. The first is a sine table for sineburst synthesis (size of at least 4096 recommended). The second is a rise shape, used forwards and backwards to shape the sineburst rise and decay; this may be linear ([GEN07](../scoregens/gen07.md)) or perhaps a sigmoid ([GEN19](../scoregens/gen19.md)).', + type: 'initialization' + }, + { + name: 'itotdur', + description: 'total time during which this _fof_ will be active. Normally set to p3. No new sineburst is created if it cannot complete its _kdur_ within the remaining _itotdur_.', + type: 'initialization' + }, + { + name: 'xamp', + description: 'peak amplitude of each sineburst, observed at the true end of its rise pattern. The rise may exceed this value given a large bandwidth (say, Q < 10) and/or when the bursts are overlapping.', + type: 'performance' + }, + { + name: 'xfund', + description: 'the fundamental frequency (in Hertz) of the impulses that create new sinebursts.', + type: 'performance' + }, + { + name: 'xform', + description: 'the formant frequency, i.e. freq of the sinusoid burst induced by each _xfund_ impulse. This frequency can be fixed for each burst or can vary continuously.', + type: 'performance' + }, + { + name: 'koct', + description: 'octaviation index, normally zero. If greater than zero, lowers the effective _xfund_ frequency by attenuating odd-numbered sinebursts. Whole numbers are full octaves, fractions transitional.', + type: 'performance' + }, + { + name: 'kband', + description: 'the formant bandwidth (at -6dB), expressed in Hz. The bandwidth determines the rate of exponential decay throughout the sineburst, before the enveloping described below is applied.', + type: 'performance' + }, + { + name: 'kris', + description: 'rise, overall duration, and decay times (in seconds) of the sinusoid burst. These values apply an enveloped duration to each burst, in similar fashion to a Csound _linen_ generator but with rise and decay shapes derived from the _ifnb_ input. _kris_ inversely determines the skirtwidth (at -40 dB) of the induced formant region. _kdur_ affects the density of sineburst overlaps, and thus the speed of computation. Typical values for vocal imitation are .003,.02,.007.', + type: 'performance' + }, + { + name: 'kdur', + description: 'rise, overall duration, and decay times (in seconds) of the sinusoid burst. These values apply an enveloped duration to each burst, in similar fashion to a Csound _linen_ generator but with rise and decay shapes derived from the _ifnb_ input. _kris_ inversely determines the skirtwidth (at -40 dB) of the induced formant region. _kdur_ affects the density of sineburst overlaps, and thus the speed of computation. Typical values for vocal imitation are .003,.02,.007.', + type: 'performance' + }, + { + name: 'kdec', + description: 'rise, overall duration, and decay times (in seconds) of the sinusoid burst. These values apply an enveloped duration to each burst, in similar fashion to a Csound _linen_ generator but with rise and decay shapes derived from the _ifnb_ input. _kris_ inversely determines the skirtwidth (at -40 dB) of the induced formant region. _kdur_ affects the density of sineburst overlaps, and thus the speed of computation. Typical values for vocal imitation are .003,.02,.007.', + type: 'performance' + }, + { + name: 'kphs', + description: 'allows k-rate indexing of function table _ifna_ with each successive burst, making it suitable for time-warping applications. Values of _kphs_ are normalized from 0 to 1, 1 being the end of the function table _ifna_.', + type: 'performance' + }, + { + name: 'kgliss', + description: 'sets the end pitch of each grain relative to the initial pitch, in octaves. Thus _kgliss_ = 2 means that the grain ends two octaves above its initial pitch, while _kgliss_ = -3/4 has the grain ending a major sixth below. Each 1/12 added to _kgliss_ raises the ending frequency one half-step. If you want no glissando, set _kgliss_ to 0.', + type: 'performance' + }, + ], + seeAlso: ['Granular Synthesis'] +}, +{ + name: 'fog', + type: 'opcode', + category: 'Signal Generators:Granular Synthesis', + description: 'Audio output is a succession of grains derived from data in a stored function table.', + syntax: 'ares = fog(xamp, xdens, xtrans, aspd, koct, kband, kris, kdur, kdec, \\\n iolaps, ifna, ifnb, itotdur [, iphs] [, itmode] [, iskip])', + example: '--8<-- "examples/fog.csd"', + rates: ['a-rate', 'i-rate'], + parameters: [ + { + name: 'iolaps', + description: 'number of pre-located spaces needed to hold overlapping grain data. Overlaps are density dependent, and the space required depends on the maximum value of _xdens_ * _kdur_. Can be over-estimated at no computation cost. Uses less than 50 bytes of memory per _iolap_.', + type: 'initialization' + }, + { + name: 'ifna', + description: 'table numbers of two stored functions. The first is the data used for granulation, usually from a soundfile ([GEN01](../scoregens/gen01.md)). The second is a rise shape, used forwards and backwards to shape the grain rise and decay; this is normally a sigmoid ([GEN19](../scoregens/gen19.md)) but may be linear ([GEN05](../scoregens/gen05.md)).', + type: 'initialization' + }, + { + name: 'ifnb', + description: 'table numbers of two stored functions. The first is the data used for granulation, usually from a soundfile ([GEN01](../scoregens/gen01.md)). The second is a rise shape, used forwards and backwards to shape the grain rise and decay; this is normally a sigmoid ([GEN19](../scoregens/gen19.md)) but may be linear ([GEN05](../scoregens/gen05.md)).', + type: 'initialization' + }, + { + name: 'itotdur', + description: 'total time during which this _fog_ will be active. Normally set to p3. No new grain is created if it cannot complete its _kdur_ within the remaining _itotdur_.', + type: 'initialization' + }, + { + name: 'xamp', + description: 'amplitude factor. Amplitude is also dependent on the number of overlapping grains, the interaction of the rise shape (_ifnb_) and the exponential decay (_kband_), and the scaling of the grain waveform (_ifna_). The actual amplitude may therefore exceed _xamp_.', + type: 'performance' + }, + { + name: 'xdens', + description: 'density. The frequency of grains per second.', + type: 'performance' + }, + { + name: 'xtrans', + description: 'transposition factor. The rate at which data from the stored function table _ifna_ is read within each grain. This has the effect of transposing the original material. A value of 1 produces the original pitch. Higher values transpose upwards, lower values downwards. Negative values result in the function table being read backwards.', + type: 'performance' + }, + { + name: 'aspd', + description: 'Starting index pointer. _aspd_ is the normalized index (0 to 1) to table _ifna_ that determines the movement of a pointer used as the starting point for reading data within each grain. (_xtrans_ determines the rate at which data is read starting from this pointer.)', + type: 'performance' + }, + { + name: 'koct', + description: 'octaviation index. The operation of this parameter is identical to that in [fof](../opcodes/fof.md).', + type: 'performance' + }, + { + name: 'kband', + description: 'grain envelope shape. These parameters determine the exponential decay (_kband_), and the rise (_kris_), overall duration (_kdur_,) and decay (_kdec_ ) times of the grain envelope. Their operation is identical to that of the local envelope parameters in _fof_.', + type: 'performance' + }, + { + name: 'kris', + description: 'grain envelope shape. These parameters determine the exponential decay (_kband_), and the rise (_kris_), overall duration (_kdur_,) and decay (_kdec_ ) times of the grain envelope. Their operation is identical to that of the local envelope parameters in _fof_.', + type: 'performance' + }, + { + name: 'kdur', + description: 'grain envelope shape. These parameters determine the exponential decay (_kband_), and the rise (_kris_), overall duration (_kdur_,) and decay (_kdec_ ) times of the grain envelope. Their operation is identical to that of the local envelope parameters in _fof_.', + type: 'performance' + }, + { + name: 'kdec', + description: 'grain envelope shape. These parameters determine the exponential decay (_kband_), and the rise (_kris_), overall duration (_kdur_,) and decay (_kdec_ ) times of the grain envelope. Their operation is identical to that of the local envelope parameters in _fof_.', + type: 'performance' + }, + ], + seeAlso: ['Granular Synthesis'] +}, +{ + name: 'grain', + type: 'opcode', + category: 'Signal Generators:Granular Synthesis', + description: 'Generates granular synthesis textures.', + syntax: 'ares = grain(xamp, xpitch, xdens, kampoff, kpitchoff, kgdur, igfn, \\\n iwfn, imgdur [, igrnd])', + example: '--8<-- "examples/grain.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'igfn', + description: 'The ftable number of the grain waveform. This can be just a sine wave or a sampled sound.', + type: 'initialization' + }, + { + name: 'iwfn', + description: 'Ftable number of the amplitude envelope used for the grains (see also [GEN20](../scoregens/gen20.md)).', + type: 'initialization' + }, + { + name: 'imgdur', + description: 'Maximum grain duration in seconds. This is the biggest value to be assigned to _kgdur_.', + type: 'initialization' + }, + { + name: 'xamp', + description: 'Amplitude of each grain.', + type: 'performance' + }, + { + name: 'xpitch', + description: 'Grain pitch. To use the original frequency of the input sound, use the formula:', + type: 'performance' + }, + { + name: 'xdens', + description: 'Density of grains measured in grains per second. If this is constant then the output is synchronous granular synthesis, very similar to [fof](../opcodes/fof.md). If _xdens_ has a random element (like added noise), then the result is more like asynchronous granular synthesis.', + type: 'performance' + }, + { + name: 'kampoff', + description: 'Maximum amplitude deviation from _xamp_. This means that the maximum amplitude a grain can have is _xamp_ + _kampoff_ and the minimum is _xamp_. If _kampoff_ is set to zero then there is no random amplitude for each grain.', + type: 'performance' + }, + { + name: 'kpitchoff', + description: 'Maximum pitch deviation from _xpitch_ in Hz. Similar to _kampoff_.', + type: 'performance' + }, + { + name: 'kgdur', + description: 'Grain duration in seconds. The maximum value for this should be declared in _imgdur_. If _kgdur_ at any point becomes greater than _imgdur_, it will be truncated to _imgdur_.', + type: 'performance' + }, + ], + seeAlso: ['Granular Synthesis'] +}, +{ + name: 'grain2', + type: 'opcode', + category: 'Signal Generators:Granular Synthesis', + description: 'Easy-to-use granular synthesis texture generator.', + syntax: 'ares = grain2(kcps, kfmd, kgdur, iovrlp, kfn, iwfn [, irpow] \\\n [, iseed] [, imode])', + example: '--8<-- "examples/grain2.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'iovrlp', + description: '(fixed) number of overlapping grains.', + type: 'initialization' + }, + { + name: 'iwfn', + description: 'function table containing window waveform (Use [GEN20](../scoregens/gen20.md) to calculate _iwfn_).', + type: 'initialization' + }, + { + name: 'ares', + description: 'output signal.', + type: 'performance' + }, + { + name: 'kcps', + description: 'grain frequency in Hz.', + type: 'performance' + }, + { + name: 'kfmd', + description: 'random variation (bipolar) in grain frequency in Hz.', + type: 'performance' + }, + { + name: 'kgdur', + description: 'grain duration in seconds. _kgdur_ also controls the duration of already active grains (actually the speed at which the window function is read). This behavior does not depend on the _imode_ flags.', + type: 'performance' + }, + { + name: 'kfn', + description: 'function table containing grain waveform. Table number can be changed at k-rate (this is useful to select from a set of band-limited tables generated by [GEN30](../scoregens/gen30.md), to avoid aliasing).', + type: 'performance' + }, + ], + seeAlso: ['Granular Synthesis'] +}, +{ + name: 'grain3', + type: 'opcode', + category: 'Signal Generators:Granular Synthesis', + description: 'Generate granular synthesis textures with more user control.', + syntax: 'ares = grain3(kcps, kphs, kfmd, kpmd, kgdur, kdens, imaxovr, kfn, iwfn, \\\n kfrpow, kprpow [, iseed] [, imode])', + example: '--8<-- "examples/grain3.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'imaxovr', + description: 'maximum number of overlapping grains. The number of overlaps can be calculated by (_kdens_ * _kgdur_); however, it can be overestimated at no cost in rendering time, and a single overlap uses (depending on system) 16 to 32 bytes of memory.', + type: 'initialization' + }, + { + name: 'iwfn', + description: 'function table containing window waveform (Use Use [GEN20](../scoregens/gen20.md) to calculate _iwfn_).', + type: 'initialization' + }, + { + name: 'ares', + description: 'output signal.', + type: 'performance' + }, + { + name: 'kcps', + description: 'grain frequency in Hz.', + type: 'performance' + }, + { + name: 'kphs', + description: 'grain phase. This is the location in the grain waveform table, expressed as a fraction (between 0 to 1) of the table length.', + type: 'performance' + }, + { + name: 'kfmd', + description: 'random variation (bipolar) in grain frequency in Hz.', + type: 'performance' + }, + { + name: 'kpmd', + description: 'random variation (bipolar) in start phase.', + type: 'performance' + }, + { + name: 'kgdur', + description: 'grain duration in seconds. _kgdur_ also controls the duration of already active grains (actually the speed at which the window function is read). This behavior does not depend on the _imode_ flags.', + type: 'performance' + }, + { + name: 'kdens', + description: 'number of grains per second.', + type: 'performance' + }, + { + name: 'kfrpow', + description: 'this value controls the distribution of grain frequency variation. If _kfrpow_ is positive, the random distribution (x is in the range -1 to 1) is:', + type: 'performance' + }, + { + name: 'kprpow', + description: 'distribution of random phase variation (see _kfrpow_). Setting _kphs_ and _kpmd_ to 0.5, and _kprpow_ to 0 will emulate _grain2_.', + type: 'performance' + }, + { + name: 'kfn', + description: 'function table containing grain waveform. Table number can be changed at k-rate (this is useful to select from a set of band-limited tables generated by Use [GEN30](../scoregens/gen30.md), to avoid aliasing).', + type: 'performance' + }, + ], + seeAlso: ['Granular Synthesis'] +}, +{ + name: 'granule', + type: 'opcode', + category: 'Signal Generators:Granular Synthesis', + description: 'A more complex granular synthesis texture generator.', + syntax: 'ares = granule(xamp, ivoice, iratio, imode, ithd, ifn, ipshift, igskip, \\\n igskip_os, ilength, kgap, igap_os, kgsize, igsize_os, iatt, idec \\\n [, iseed] [, ipitch1] [, ipitch2] [, ipitch3] [, ipitch4] [, ifnenv])', + example: '--8<-- "examples/granule.csd"', + rates: ['a-rate', 'i-rate'], + parameters: [ + { + name: 'ivoice', + description: 'number of voices.', + type: 'initialization' + }, + { + name: 'iratio', + description: 'ratio of the speed of the gskip pointer relative to output audio sample rate. eg. 0.5 will be half speed.', + type: 'initialization' + }, + { + name: 'imode', + description: '+1 grain pointer move forward (same direction of the gskip pointer), -1 backward (oppose direction to the gskip pointer) or 0 for random.', + type: 'initialization' + }, + { + name: 'ithd', + description: 'threshold, if the sampled signal in the wavetable is smaller then _ithd_, it will be skipped.', + type: 'initialization' + }, + { + name: 'ifn', + description: 'function table number of sound source.', + type: 'initialization' + }, + { + name: 'ipshift', + description: 'pitch shift control. If _ipshift_ is 0, pitch will be set randomly up and down an octave. If _ipshift_ is 1, 2, 3 or 4, up to four different pitches can be set amount the number of voices defined in _ivoice_. The optional parameters _ipitch1_, _ipitch2_, _ipitch3_ and _ipitch4_ are used to quantify the pitch shifts.', + type: 'initialization' + }, + { + name: 'igskip', + description: 'initial skip from the beginning of the function table in sec.', + type: 'initialization' + }, + { + name: 'igskip_os', + description: 'gskip pointer random offset in sec, 0 will be no offset.', + type: 'initialization' + }, + { + name: 'ilength', + description: 'length of the table to be used starting from _igskip_ in sec.', + type: 'initialization' + }, + { + name: 'igap_os', + description: 'gap random offset in % of the gap size, 0 gives no offset.', + type: 'initialization' + }, + { + name: 'igsize_os', + description: 'grain size random offset in % of grain size, 0 gives no offset.', + type: 'initialization' + }, + { + name: 'iatt', + description: 'attack of the grain envelope in % of grain size.', + type: 'initialization' + }, + { + name: 'idec', + description: 'decade of the grain envelope in % of grain size.', + type: 'initialization' + }, + { + name: 'xamp', + description: 'amplitude.', + type: 'performance' + }, + { + name: 'kgap', + description: 'gap between grains in sec.', + type: 'performance' + }, + { + name: 'kgsize', + description: 'grain size in sec.', + type: 'performance' + }, + ], + seeAlso: ['Granular Synthesis'] +}, +{ + name: 'partikkel', + type: 'opcode', + category: 'Signal Generators:Granular Synthesis', + description: 'Granular synthesizer with "per grain" control over many of its parameters. Has a sync input to sychronize its internal grain scheduler clock to an external clock source.', + syntax: 'a1 [, a2, a3, a4, a5, a6, a7, a8] = partikkel(agrainfreq, \\\n kdistribution, idisttab, async, kenv2amt, ienv2tab, ienv_attack, \\\n ienv_decay, ksustain_amount, ka_d_ratio, kduration, kamp, igainmasks, \\\n kwavfreq, ksweepshape, iwavfreqstarttab, iwavfreqendtab, awavfm, \\\n ifmamptab, kfmenv, icosine, ktraincps, knumpartials, kchroma, \\\n ichannelmasks, krandommask, kwaveform1, kwaveform2, kwaveform3, \\\n kwaveform4, iwaveamptab, asamplepos1, asamplepos2, asamplepos3, \\\n asamplepos4, kwavekey1, kwavekey2, kwavekey3, kwavekey4, imax_grains \\\n [, iopcode_id, ipanlaws])', + example: '--8<-- "examples/partikkel.csd"', + rates: ['k-rate'], + parameters: [ + { + name: 'idisttab', + description: 'function table number, distribution for random grain displacements over time. The table values are interpreted as "displacement amount" scaled by 1/grainrate. This means that a value of 0.5 in the table will displace a grain by half the grainrate period. The table values are read randomly, and scaled by _kdistribution_. For realistic stochastic results, it is advisable not to use a too small table size, as this limits the amount of possible displacement values. This can also be utilized for other purposes, e.g. using quantized displacement values to work with controlled time displacement from the periodic grain rate. If _kdistribution_ is negative, the table values will be read sequentially. A default table might be selected by using -1 as the ftable number, for _idisttab_ the default uses a zero distribution (no displacement).', + type: 'initialization' + }, + { + name: 'ienv_attack', + description: 'function table number, attack shape of grain. Needs extended guard point. A default table might be selected by using -1 as the ftable number, for _ienv_attack_ the default uses a square window (no enveloping).', + type: 'initialization' + }, + { + name: 'ienv_decay', + description: 'function table number, decay shape of grain. Needs extended guard point. A default table might be selected by using -1 as the ftable number, for _ienv_decay_ the default uses a square window (no enveloping).', + type: 'initialization' + }, + { + name: 'ienv2tab', + description: 'function table number, additional envelope applied to grain, done after attack and decay envelopes. Can be used e.g. for fof formant synthesis. Needs extended guard point. A default table might be selected by using -1 as the ftable number, for _ienv2tab_ the default uses a square window (no enveloping).', + type: 'initialization' + }, + { + name: 'icosine', + description: 'function table number, must contain a cosine, used for trainlets. Table size should be at least 2048 for good quality trainlets.', + type: 'initialization' + }, + { + name: 'igainmasks', + description: 'function table number, gain per grain. The sequence of values in the table is as follows: index 0 is used as a loop start point in reading the values, index 1 is used as a loop end point. Remaining indices contain gain values (normally in range 0 - 1, but other values are allowed, negative values will invert phase of waveform inside grain) for a sequence of grains, these are read at grain rate enabling exact patterns of "gain per grain". The loop start and end points are zero based with an origin at index 2, e.g. a loop start value of 0 and loop end value of 3 will read indices 2,3,4,5 in a loop at grain rate. A default table might be selected by using -1 as the ftable number, for _igainmasks_ the default disables gain masking (all grains are given a gain masking value of 1).', + type: 'initialization' + }, + { + name: 'ichannelmasks', + description: 'function table number, see _igainmasks_ for a description of how the values in the table are read. Range is 0 to N, where N is the number of output channels. A value of zero will send the grain to audio output 1 from the opcode. Fractional values are allowed, e.g. a value of 3.5 will mix the grain equally to outputs 4 and 5. The channelmask value wraps around from the last to the first output, so that a vaalue of N-0.5 will mix the grain equally between the last and the first output. If another panning law between outputs is desired, this can be described in the _ipanlaws_ table. The user is responsible for keeping the values in range, the opcode will crash with out of range values. A default table might be selected by using -1 as the ftable number, for _ichannelmasks_ the default disables channel masking (all grains are given a channel masking value of 0 and are sent to _partikkel_ audio out 1).', + type: 'initialization' + }, + { + name: 'iwavfreqstarttab', + description: 'function table number, see _igainmasks_ for a description of how the values in the table are read. Start frequency multiplicator for each grain. Pitch will glide from start frequency to end frequency following a line or curve as set by _ksweepshape_. A default table might be selected by using -1 as the ftable number, for _iwavfreqstarttab_ the default uses a multiplicator of 1, disabling any start frequency modification.', + type: 'initialization' + }, + { + name: 'iwavfreqendtab', + description: 'function table number, see _iwavfreqstarttab_. End frequency multiplicator for each grain. A default table might be selected by using -1 as the ftable number, for _iwavfreqendtab_ the default uses a multiplicator of 1, disabling any end frequency modification.', + type: 'initialization' + }, + { + name: 'ifmamptab', + description: 'function table number, see _igainmasks_ for a description of how the values in the table are read. Frequency modulation index per grain. The signal _awavfm_ will be multiplied by values read from this table. A default table might be selected by using -1 as the ftable number, for _ifmamptab_ the default uses 1 as the index multiplicator, enabling fm for all grains.', + type: 'initialization' + }, + { + name: 'iwaveamptab', + description: 'function table number, the indices are read in a similar way to what is used for _igainmasks_. Index 0 is used as a loop start point, and index 1 is used as a loop end point. The rest of the indices are read in groups of 5, where each value represent a gain value for each of the 4 source waveforms, and the 5th value represent trainlet amplitude. A default table might be selected by using -1 as the ftable number, for _iwaveamptab_ the default uses an equal mix of all 4 source waveforms (each with an amplitude of 0.5) and setting trainlet amp to zero.', + type: 'initialization' + }, + { + name: 'imax_grains', + description: 'maximum number of grains per k-period. Estimating a large value should not affect performance, exceeding this value will lead to "oldest grains" being deleted.', + type: 'initialization' + }, + { + name: 'iopcode_id', + description: 'the opcode id, linking an instance of _partikkel_ to an instance of [partikkelsync](../opcodes/partikkelsync.md), the linked _partikkelsync_ will output trigger pulses synchronized to _partikkel_\'s grain maker scheduler. The default value is zero, which means no connection to any _partikkelsync_ instances.', + type: 'initialization' + }, + { + name: 'ipanlaws', + description: 'function table number. The table describes the panning curve used for fractional channelmask values. Fractional channelmask values will mix a grain to two neighbouring outputs, with the relative gain set by the fractional value. By default if no _ipanlaws_ table is described, a linear gain relationship is used, so that a channelmask value of e.g. 1.5 distributes the grain with 0.5 gain to output 2 and 0.5 gain to output 3. The _ipanlaws_ table can be used to describe other gain control curves (panning laws). The table should contain 8 such gain control curves, each governing the panning between two neighbouring outputs. The curves should appear one after another in the table, in a concatenated fashion. GEN 18 can be used to create this table from separate panning curve tables (see example below). The first curve describes the panning law between output 1 and output 2, the next is for panning between outputs 2 and 3, and so on. The last curve describes the panning law between the last and the first output. The table is indexed by the channelmask value such that one output (of an output pair goverened by the panning law) uses the index (tablesize/8*channelmask) while the other of the two outputs reads the value at index (tablesize/8*(int(channelmask+1)-frac(channelmask))). This means that if the panning law value halfway between these two channel masks is e.g. 0.7 (which would give approximately equal power panning), then each of those two outputs will use 0.7 as the gain value.', + type: 'initialization' + }, + { + name: 'xgrainfreq', + description: 'number of grains per second. A value of zero is allowed, and this will defer all grain scheduling to the sync input.', + type: 'performance' + }, + { + name: 'async', + description: 'sync input. Input values are added to the phase value of the internal grain maker clock, enabling tempo synchronization with an external clock source. As this is an a-rate signal, inputs are usually pulses of length 1/_sr_. Using such pulses, the internal phase value can be "nudged" up or down, enabling soft or hard synchronization. Negative input values decrements the internal phase, while positive values in the range 0 to 1 increments the internal phase. An input value of 1 will always make _partikkel_ generate a grain. If the value remains at 1, the internal grain scheduler clock will pause but any currently playing grains will still play to end.', + type: 'performance' + }, + { + name: 'kdistribution', + description: 'periodic or stochastic distribution of grains, 0 = periodic. Stochastic grain displacement is in the range of _kdistribution/grainrate_ seconds. The stochastic distribution profile (random distribution) can be set in the _idisttab_ table. If _kdistribution_ is negative, the result is deterministic time displacement as described by _idisttab_ (sequential read of displacement values). Maximum grain displacement in all cases is limited to 10 seconds, and a grain will keep the values (duration, pitch etc) it was given when it was first generated (before time displacement). Since grain displacement is relative to the grain rate, displacement amount is undefined at 0Hz grain rate and kdistribution is completely disabled in this case.', + type: 'performance' + }, + { + name: 'kenv2amt', + description: 'amount of enveloping for the secondary envelope for each grain. Range 0 to 1, where 0 is no secondary enveloping (square window), a value of 0.5 will use an interpolation between a square window and the shape set by _ienv2tab_.', + type: 'performance' + }, + { + name: 'ksustain_amount', + description: 'sustain time as fraction of grain duration. I.e. balance between enveloped time(attack+decay) and sustain level time. The sustain level is taken from the last value of the _ienv_attack_ ftable.', + type: 'performance' + }, + { + name: 'ka_d_ratio', + description: 'balance between attack time and decay time. For example, with _ksustain_amount_ set to 0.5 and _ka_d_ratio_ set to 0.5, the attack envelope of each grain will take 25% of the grain duration, full amplitude (sustain) will be held for 50% of the grain duration, and the decay envelope will take the remaining 25% of the grain duration.', + type: 'performance' + }, + { + name: 'kduration', + description: 'grain duration in milliseconds.', + type: 'performance' + }, + { + name: 'kamp', + description: 'amplitude scaling of the opcode\'s output. Multiplied by per grain amplitude read from _igainmasks_. Source waveform playback inside grains can consume a significant amount of CPU cycles, especially if grain duration is long so that we have a lot of overlapping grains. Setting kamp to zero will skip waveform playback inside grains (and not generate any sound, obviously). This can be used as a "soft" bypass method if we want to keep the opcode active but silent for some periods of time.', + type: 'performance' + }, + { + name: 'kwavfreq', + description: 'transposition scaling. Multiplied with start and end transposition values read from _iwavfreqstarttab_ and _iwavfreqendtab_.', + type: 'performance' + }, + { + name: 'ksweepshape', + description: 'transposition sweep shape, controls the curvature of the transposition sweep. Range 0 to 1. Low values will hold the transposition at the start value longer and then drop to the end value quickly, high values will drop to the end value quickly. A value of 0.5 will give a linear sweep. A value of exactly 0 will bypass sweep and only use the start frequency, while a value of exactly 1 will bypass sweep and only use the end frequency. The sweep generator might be slightly inaccurate in hitting the end frequency when using a steep curve and very long grains.', + type: 'performance' + }, + { + name: 'awavfm', + description: 'audio input for frequency modulation inside grain.', + type: 'performance' + }, + { + name: 'kfmenv', + description: 'function table number, envelope for FM modulator signal enabling the modulation index to change over the duration of a grain.', + type: 'performance' + }, + { + name: 'ktraincps', + description: 'trainlet fundamental frequency.', + type: 'performance' + }, + { + name: 'knumpartials', + description: 'number of partials in trainlets.', + type: 'performance' + }, + { + name: 'kchroma', + description: 'chroma of trainlets. A value of 1 give equal amplitude to each partial, higher values will reduce the amplitude of lower partials while strengthening the amplitude of the higher partials.', + type: 'performance' + }, + { + name: 'krandommask', + description: 'random masking (muting) of individual grains. Range 0 to 1, where a value of 0 will give no masking (all grains are played), and a value of 1 will mute all grains.', + type: 'performance' + }, + { + name: 'kwaveform1', + description: 'table number for source waveform 1.', + type: 'performance' + }, + { + name: 'kwaveform2', + description: 'table number for source waveform 2.', + type: 'performance' + }, + { + name: 'kwaveform3', + description: 'table number for source waveform 3.', + type: 'performance' + }, + { + name: 'kwaveform4', + description: 'table number for source waveform 4.', + type: 'performance' + }, + { + name: 'asamplepos1', + description: 'start position for reading source waveform 1 (in range 0..1).', + type: 'performance' + }, + { + name: 'asamplepos2', + description: 'start position for reading source waveform 2.', + type: 'performance' + }, + { + name: 'asamplepos3', + description: 'start position for reading source waveform 3.', + type: 'performance' + }, + { + name: 'asamplepos4', + description: 'start position for reading source waveform 4.', + type: 'performance' + }, + { + name: 'kwavekey1', + description: 'original key of source waveform 1. Can be used to transpose each source waveform independently.', + type: 'performance' + }, + { + name: 'kwavekey2', + description: 'as _kwavekey1_, but for source waveform 2.', + type: 'performance' + }, + { + name: 'kwavekey3', + description: 'as _kwavekey1_, but for source waveform 3.', + type: 'performance' + }, + { + name: 'kwavekey4', + description: 'as _kwavekey1_, but for source waveform 4.', + type: 'performance' + }, + ], + seeAlso: ['Granular Synthesis'] +}, +{ + name: 'partikkelget', + type: 'opcode', + category: 'Signal Generators:Granular Synthesis', + description: 'Get mask index for a specific mask parameter of a running _partikkel_ instance.', + syntax: 'kindex = partikkelget(kparameterindex, iopcode_id)', + example: '--8<-- "examples/partikkelgetset.csd"', + parameters: [ + { + name: 'iopcode_id', + description: 'the opcode id, linking an instance of [partikkel](../opcodes/partikkel.md) to an instance of _partikkelsync_.', + type: 'initialization' + }, + { + name: 'kmaskindex', + description: 'mask index output. Outputs the current mask index for the parameter specified with _kparameterindex_ in the partikkel instance identified with _iopcode_id_.', + type: 'performance' + }, + { + name: 'kparameterindex', + description: 'mask parameter. Selection of the masking parameter for which to output the current mask index. The different parameters are identified as:', + type: 'performance' + }, + ], + seeAlso: ['partikkel'] +}, +{ + name: 'partikkelset', + type: 'opcode', + category: 'Signal Generators:Granular Synthesis', + description: 'Set mask index for a specific mask parameter of a running _partikkel_ instance.', + syntax: 'partikkelset(kparameterindex, kmaskindex, iopcode_id)', + example: '--8<-- "examples/partikkelgetset.csd"', + parameters: [ + { + name: 'iopcode_id', + description: 'the opcode id, linking an instance of [partikkel](../opcodes/partikkel.md) to an instance of _partikkelsync_.', + type: 'initialization' + }, + { + name: 'kparameterindex', + description: 'mask parameter. Selection of the masking parameter for which to set the current mask index. The different parameters are identified as:', + type: 'performance' + }, + { + name: 'kmaskindex', + description: 'value to set mask index to. Sets the current mask index for the parameter specified with _kparameterindex_ in the partikkel instance identified with _iopcode_id_.', + type: 'performance' + }, + ], + seeAlso: ['partikkel'] +}, +{ + name: 'partikkelsync', + type: 'opcode', + category: 'Signal Generators:Granular Synthesis', + description: 'Outputs _partikkel_\'s grain scheduler clock pulse and phase to synchronize several instances of the _partikkel_ opcode to the same clock source.', + syntax: 'async [,aphase] = partikkelsync(iopcode_id)', + example: '--8<-- "examples/partikkelsync.csd"', + parameters: [ + { + name: 'iopcode_id', + description: 'the opcode id, linking an instance of [partikkel](../opcodes/partikkel.md) to an instance of _partikkelsync_.', + type: 'initialization' + }, + { + name: 'async', + description: 'trigger pulse signal. Outputs trigger pulses synchronized to a _partikkel_ opcode\'s grain scheduler clock. One trigger pulse is generated for each grain started in the _partikkel_ opcode with the same _opcode_id_. The normal usage would be to send this signal to another _partikkel_ opcode\'s _async_ input to synchronize several instances of _partikkel_.', + type: 'performance' + }, + { + name: 'aphase', + description: 'clock phase. Outputs a linear ramping phase signal. Can be used e.g. for softsynchronization, or just as a phase generator ala _phasor_.', + type: 'performance' + }, + ], + seeAlso: ['Granular Synthesis'] +}, +{ + name: 'sndwarp', + type: 'opcode', + category: 'Signal Generators:Granular Synthesis', + description: 'Reads a mono sound sample from a table and applies time-stretching and/or pitch modification.', + syntax: 'ares [, ac] = sndwarp(xamp, xtimewarp, xresample, ifn1, ibeg, iwsize, \\\n irandw, ioverlap, ifn2, itimemode)', + example: '--8<-- "examples/sndwarp.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'ifn1', + description: 'the number of the table holding the sound samples which will be subjected to the _sndwarp_ processing. [GEN01](../scoregens/gen01.md) is the appropriate function generator to use to store the sound samples from a pre-existing soundfile.', + type: 'initialization' + }, + { + name: 'ibeg', + description: 'the time in seconds to begin reading in the table (or soundfile). When _itimemode_ is non- zero, the value of _xtimewarp_ is offset by _ibeg_.', + type: 'initialization' + }, + { + name: 'iwsize', + description: 'the window size in samples used in the time scaling algorithm.', + type: 'initialization' + }, + { + name: 'irandw', + description: 'the bandwidth of a random number generator. The random numbers will be added to _iwsize_.', + type: 'initialization' + }, + { + name: 'ioverlap', + description: 'determines the density of overlapping windows.', + type: 'initialization' + }, + { + name: 'ifn2', + description: 'a function used to shape the window. It is usually used to create a ramp of some kind from zero at the beginning and back down to zero at the end of each window. Try using a half sine (i.e.: f1 0 16384 9 .5 1 0) which works quite well. Other shapes can also be used.', + type: 'initialization' + }, + { + name: 'ares', + description: 'the single channel of output from the _sndwarp_ unit generator. _sndwarp_ assumes that the function table holding the sampled signal is a mono one. This simply means that _sndwarp_ will index the table by single-sample frame increments. The user must be aware then that if a stereo signal is used with _sndwarp_, time and pitch will be altered accordingly.', + type: 'performance' + }, + { + name: 'xamp', + description: 'the value by which to scale the amplitude (see note on the use of this when using _ac_).', + type: 'performance' + }, + { + name: 'xtimewarp', + description: 'determines how the input signal will be stretched or shrunk in time. There are two ways to use this argument depending upon the value given for _itimemode_. When the value of _itimemode_ is 0, _xtimewarp_ will scale the time of the sound. For example, a value of 2 will stretch the sound by 2 times. When _itimemode_ is any non-zero value then _xtimewarp_ is used as a time pointer in a similar way in which the time pointer works in [lpread](../opcodes/lpread.md) and [pvoc](../opcodes/pvoc.md). An example below illustrates this. In both cases, the pitch will _not_ be altered by this process. Pitch shifting is done independently using _xresample_.', + type: 'performance' + }, + { + name: 'xresample', + description: 'the factor by which to change the pitch of the sound. For example, a value of 2 will produce a sound one octave higher than the original. The timing of the sound, however, will _not_ be altered.', + type: 'performance' + }, + ], + seeAlso: ['Granular Synthesis'] +}, +{ + name: 'sndwarpst', + type: 'opcode', + category: 'Signal Generators:Granular Synthesis', + description: 'Reads a stereo sound sample from a table and applies time-stretching and/or pitch modification.', + syntax: 'ar1, ar2 [,ac1] [, ac2] = sndwarpst(xamp, xtimewarp, xresample, ifn1, \\\n ibeg, iwsize, irandw, ioverlap, ifn2, itimemode)', + example: '--8<-- "examples/sndwarpst.csd"', + parameters: [ + { + name: 'ifn1', + description: 'the number of the table holding the sound samples which will be subjected to the _sndwarpst_ processing. [GEN01](../scoregens/gen01.md) is the appropriate function generator to use to store the sound samples from a pre-existing soundfile.', + type: 'initialization' + }, + { + name: 'ibeg', + description: 'the time in seconds to begin reading in the table (or soundfile). When _itimemode_ is non-zero, the value of _xtimewarp_ is offset by _ibeg_.', + type: 'initialization' + }, + { + name: 'iwsize', + description: 'the window size in samples used in the time scaling algorithm.', + type: 'initialization' + }, + { + name: 'irandw', + description: 'the bandwidth of a random number generator. The random numbers will be added to _iwsize_.', + type: 'initialization' + }, + { + name: 'ioverlap', + description: 'determines the density of overlapping windows.', + type: 'initialization' + }, + { + name: 'ifn2', + description: 'a function used to shape the window. It is usually used to create a ramp of some kind from zero at the beginning and back down to zero at the end of each window. Try using a half a sine (i.e.: f1 0 16384 9 .5 1 0) which works quite well. Other shapes can also be used.', + type: 'initialization' + }, + { + name: 'ar1', + description: '_ar1_ and _ar2_ are the stereo (left and right) outputs from _sndwarpst_. _sndwarpst_ assumes that the function table holding the sampled signal is a stereo one. _sndwarpst_ will index the table by a two-sample frame increment. The user must be aware then that if a mono signal is used with _sndwarpst_, time and pitch will be altered accordingly.', + type: 'performance' + }, + { + name: 'ar2', + description: '_ar1_ and _ar2_ are the stereo (left and right) outputs from _sndwarpst_. _sndwarpst_ assumes that the function table holding the sampled signal is a stereo one. _sndwarpst_ will index the table by a two-sample frame increment. The user must be aware then that if a mono signal is used with _sndwarpst_, time and pitch will be altered accordingly.', + type: 'performance' + }, + { + name: 'ac1', + description: '_ac1_ and _ac2_ are single-layer (no overlaps), unwindowed versions of the time and/or pitch altered signal. They are supplied in order to be able to balance the amplitude of the signal output, which typically contains many overlapping and windowed versions of the signal, with a clean version of the time-scaled and pitch-shifted signal. The _sndwarpst_ process can cause noticeable changes in amplitude, (up and down), due to a time differential between the overlaps when time-shifting is being done. When used with a [balance](../opcodes/balance.md) unit, _ac1_ and _ac2_ can greatly enhance the quality of sound. They are optional, but note that they must both be present in the syntax (use both or neither). An example of how to use this is given below.', + type: 'performance' + }, + { + name: 'ac2', + description: '_ac1_ and _ac2_ are single-layer (no overlaps), unwindowed versions of the time and/or pitch altered signal. They are supplied in order to be able to balance the amplitude of the signal output, which typically contains many overlapping and windowed versions of the signal, with a clean version of the time-scaled and pitch-shifted signal. The _sndwarpst_ process can cause noticeable changes in amplitude, (up and down), due to a time differential between the overlaps when time-shifting is being done. When used with a [balance](../opcodes/balance.md) unit, _ac1_ and _ac2_ can greatly enhance the quality of sound. They are optional, but note that they must both be present in the syntax (use both or neither). An example of how to use this is given below.', + type: 'performance' + }, + { + name: 'xamp', + description: 'the value by which to scale the amplitude (see note on the use of this when using _ac1_ and _ac2_).', + type: 'performance' + }, + { + name: 'xtimewarp', + description: 'determines how the input signal will be stretched or shrunk in time. There are two ways to use this argument depending upon the value given for _itimemode_. When the value of _itimemode_ is 0, _xtimewarp_ will scale the time of the sound. For example, a value of 2 will stretch the sound by 2 times. When _itimemode_ is any non-zero value then _xtimewarp_ is used as a time pointer in a similar way in which the time pointer works in [lpread](../opcodes/lpread.md) and [pvoc](../opcodes/pvoc.md). An example below illustrates this. In both cases, the pitch will _not_ be altered by this process. Pitch shifting is done independently using _xresample_.', + type: 'performance' + }, + { + name: 'xresample', + description: 'the factor by which to change the pitch of the sound. For example, a value of 2 will produce a sound one octave higher than the original. The timing of the sound, however, will _not_ be altered.', + type: 'performance' + }, + ], + seeAlso: ['Granular Synthesis'] +}, +] diff --git a/src/lib/csound-reference/signal-generators-hyper-vectorial-synthesis.ts b/src/lib/csound-reference/signal-generators-hyper-vectorial-synthesis.ts new file mode 100644 index 0000000..0988a1f --- /dev/null +++ b/src/lib/csound-reference/signal-generators-hyper-vectorial-synthesis.ts @@ -0,0 +1,172 @@ +import type { CsoundReference } from './types' + +// Signal Generators:Hyper Vectorial Synthesis +export const signalGeneratorsHyperVectorialSynthesis: CsoundReference[] = [ +{ + name: 'hvs1', + type: 'opcode', + category: 'Signal Generators:Hyper Vectorial Synthesis', + description: 'Allows one-dimensional Hyper Vectorial Synthesis (HVS) controlled by externally-updated k-variables.', + syntax: 'hvs1(kx, inumParms, inumPointsX, iOutTab, iPositionsTab, iSnapTab [, iConfigTab])', + example: '--8<-- "examples/hvs1.csd"', + parameters: [ + { + name: 'inumParms', + description: 'number of parameters controlled by the HVS. Each HVS snapshot is made up of inumParms elements.', + type: 'initialization' + }, + { + name: 'inumPointsX', + description: 'number of points that each dimension of the HVS cube (or square in case of two-dimensional HVS; or line in case of one-dimensional HVS) is made up.', + type: 'initialization' + }, + { + name: 'iOutTab', + description: 'number of the table receiving the set of output-parameter instant values of the HVS. The total amount of parameters is defined by the _inumParms_ argument.', + type: 'initialization' + }, + { + name: 'iPositionsTab', + description: 'a table filled with the individual positions of snapshots in the HVS matrix (see below for more information).', + type: 'initialization' + }, + { + name: 'iSnapTab', + description: 'a table filled with all the snapshots. Each snapshot is made up of a set of parameter values. The amount of elements contained in each snapshots is specified by the _inumParms_ argument. The set of elements of each snapshot follows (and is adjacent) to the previous one in this table. So the total size of this table should be >= to _inumParms_ multiplied the number of snapshots you intend to store for the HVS.', + type: 'initialization' + }, + { + name: 'iConfigTab', + description: '(optional) a table containing the behavior of the HVS for each parameter. If the value of _iConfigTab_ is zero (default), this argument is ignored, meaning that each parameter is treated with linear interpolation by the HVS. If _iConfigTab_ is different than zero, then it must refer to an existing table whose contents are in its turn referring to a particolar kind of interpolation. In this table, a value of -1 indicates that corresponding parameter is leaved unchanged (ignored) by the HVS; a value of zero indicates that corresponding parameter is treated with linear-interpolation; each other values must be integer numbers indicating an existing table filled with a shape which will determine the kind of special interpolation to be used (table-based interpolation).', + type: 'initialization' + }, + { + name: 'kx', + description: 'these are externally-modified variables which controls the motion of the pointer in the HVS matrix cube (or square or line in case of HVS matrices made up of less than 3 dimensions). The range of these input arguments must be 0 to 1.', + type: 'performance' + }, + ], + seeAlso: ['Hyper Vectorial Synthesis'] +}, +{ + name: 'hvs2', + type: 'opcode', + category: 'Signal Generators:Hyper Vectorial Synthesis', + description: 'Allows two-dimensional Hyper Vectorial Synthesis (HVS) controlled by externally-updated k-variables.', + syntax: 'hvs2(kx, ky, inumParms, inumPointsX, inumPointsY, iOutTab, iPositionsTab, \\\n iSnapTab [, iConfigTab])', + example: '--8<-- "examples/hvs2.csd"', + parameters: [ + { + name: 'inumParms', + description: 'number of parameters controlled by the HVS. Each HVS snapshot is made up of _inumParms_ elements.', + type: 'initialization' + }, + { + name: 'inumPointsX', + description: 'number of points that each dimension of the HVS cube (or square in case of two-dimensional HVS; or line in case of one-dimensional HVS) is made up.', + type: 'initialization' + }, + { + name: 'inumPointsY', + description: 'number of points that each dimension of the HVS cube (or square in case of two-dimensional HVS; or line in case of one-dimensional HVS) is made up.', + type: 'initialization' + }, + { + name: 'iOutTab', + description: 'number of the table receiving the set of output-parameter instant values of the HVS. The total amount of parameters is defined by the _inumParms_ argument.', + type: 'initialization' + }, + { + name: 'iPositionsTab', + description: 'a table filled with the individual positions of snapshots in the HVS matrix (see below for more information).', + type: 'initialization' + }, + { + name: 'iSnapTab', + description: 'a table filled with all the snapshots. Each snapshot is made up of a set of parameter values. The amount of elements contained in each snapshots is specified by the _inumParms_ argument. The set of elements of each snapshot follows (and is adjacent) to the previous one in this table. So the total size of this table should be >= to _inumParms_ multiplied the number of snapshots you intend to store for the HVS.', + type: 'initialization' + }, + { + name: 'iConfigTab', + description: '(optional) a table containing the behavior of the HVS for each parameter. If the value of _iConfigTab_ is zero (default), this argument is ignored, meaning that each parameter is treated with linear interpolation by the HVS. If _iConfigTab_ is different than zero, then it must refer to an existing table whose contents are in its turn referring to a particolar kind of interpolation. In this table, a value of -1 indicates that corresponding parameter is leaved unchanged (ignored) by the HVS; a value of zero indicates that corresponding parameter is treated with linear-interpolation; each other values must be integer numbers indicating an existing table filled with a shape which will determine the kind of special interpolation to be used (table-based interpolation).', + type: 'initialization' + }, + { + name: 'kx', + description: 'these are externally-modified variables which controls the motion of the pointer in the HVS matrix cube (or square or line in case of HVS matrices made up of less than 3 dimensions). The range of these input arguments must be 0 to 1.', + type: 'performance' + }, + { + name: 'ky', + description: 'these are externally-modified variables which controls the motion of the pointer in the HVS matrix cube (or square or line in case of HVS matrices made up of less than 3 dimensions). The range of these input arguments must be 0 to 1.', + type: 'performance' + }, + ], + seeAlso: ['Hyper Vectorial Synthesis'] +}, +{ + name: 'hvs3', + type: 'opcode', + category: 'Signal Generators:Hyper Vectorial Synthesis', + description: 'Allows three-dimensional Hyper Vectorial Synthesis (HVS) controlled by externally-updated k-variables.', + syntax: 'hvs3(kx, ky, kz, inumParms, inumPointsX, inumPointsY, inumPointsZ, iOutTab, \\\n iPositionsTab, iSnapTab [, iConfigTab])', + parameters: [ + { + name: 'inumParms', + description: 'number of parameters controlled by the HVS. Each HVS snapshot is made up of _inumParms_ elements.', + type: 'initialization' + }, + { + name: 'inumPointsX', + description: 'number of points that each dimension of the HVS cube (or square in case of two-dimensional HVS; or line in case of one-dimensional HVS) is made up.', + type: 'initialization' + }, + { + name: 'inumPointsY', + description: 'number of points that each dimension of the HVS cube (or square in case of two-dimensional HVS; or line in case of one-dimensional HVS) is made up.', + type: 'initialization' + }, + { + name: 'inumPointsZ', + description: 'number of points that each dimension of the HVS cube (or square in case of two-dimensional HVS; or line in case of one-dimensional HVS) is made up.', + type: 'initialization' + }, + { + name: 'iOutTab', + description: 'number of the table receiving the set of output-parameter instant values of the HVS. The total amount of parameters is defined by the _inumParms_ argument.', + type: 'initialization' + }, + { + name: 'iPositionsTab', + description: 'a table filled with the individual positions of snapshots in the HVS matrix (see below for more information).', + type: 'initialization' + }, + { + name: 'iSnapTab', + description: 'a table filled with all the snapshots. Each snapshot is made up of a set of parameter values. The amount of elements contained in each snapshots is specified by the _inumParms_ argument. The set of elements of each snapshot follows (and is adjacent) to the previous one in this table. So the total size of this table should be >= to _inumParms_ multiplied the number of snapshots you intend to store for the HVS.', + type: 'initialization' + }, + { + name: 'iConfigTab', + description: '(optional) a table containing the behavior of the HVS for each parameter. If the value of _iConfigTab_ is zero (default), this argument is ignored, meaning that each parameter is treated with linear interpolation by the HVS. If _iConfigTab_ is different than zero, then it must refer to an existing table whose contents are in its turn referring to a particolar kind of interpolation. In this table, a value of -1 indicates that corresponding parameter is leaved unchanged (ignored) by the HVS; a value of zero indicates that corresponding parameter is treated with linear-interpolation; each other values must be integer numbers indicating an existing table filled with a shape which will determine the kind of special interpolation to be used (table-based interpolation).', + type: 'initialization' + }, + { + name: 'kx', + description: 'these are externally-modified variables which controls the motion of the pointer in the HVS matrix cube (or square or line in case of HVS matrices made up of less than 3 dimensions). The range of these input arguments must be 0 to 1.', + type: 'performance' + }, + { + name: 'ky', + description: 'these are externally-modified variables which controls the motion of the pointer in the HVS matrix cube (or square or line in case of HVS matrices made up of less than 3 dimensions). The range of these input arguments must be 0 to 1.', + type: 'performance' + }, + { + name: 'kz', + description: 'these are externally-modified variables which controls the motion of the pointer in the HVS matrix cube (or square or line in case of HVS matrices made up of less than 3 dimensions). The range of these input arguments must be 0 to 1.', + type: 'performance' + }, + ], + seeAlso: ['Hyper Vectorial Synthesis'] +}, +] diff --git a/src/lib/csound-reference/signal-generators-linear-and-exponential-generators.ts b/src/lib/csound-reference/signal-generators-linear-and-exponential-generators.ts new file mode 100644 index 0000000..d8a1e5b --- /dev/null +++ b/src/lib/csound-reference/signal-generators-linear-and-exponential-generators.ts @@ -0,0 +1,771 @@ +import type { CsoundReference } from './types' + +// Signal Generators:Linear and Exponential Generators +export const signalGeneratorsLinearAndExponentialGenerators: CsoundReference[] = [ +{ + name: 'bpf', + type: 'opcode', + category: 'Signal Generators:Linear and Exponential Generators', + description: 'Break point function with linear interpolation.', + syntax: 'ky = bpf(kx, kx1, ky1, kx2, ..., kxn, kyn)\n iy = bpf(ix, ix1, iy1, ix2, ..., ixn, iyn)\n kys[] = bpf(kxs[], kx1, ky1, kx2, ..., kxn, kyn)\n iys[] = bpf(ixs[], ix1, iy1, ix2, ..., ixn, iyn)\n ky = bpf(kx, kxs[], kys[])\n iy = bpf(ix, ixs[], iys[])\n ay = bpf(ax, kx1, ky1, kx2, ..., kxn, kyn)\n ay = bpf(ax, kxs[], kys[])\n ky, kw = bpf(kx, kxs[], kys[], kws[])', + example: '--8<-- "examples/bpf.csd"', + parameters: [ + { + name: 'kx', + description: 'Input value', + type: 'performance' + }, + { + name: 'kxn', + description: 'Defines a breakpoint. Can be changed at krate, but all _kx_s must be sorted.', + type: 'performance' + }, + { + name: 'kyn', + description: 'Defines a breakpoint. Can be changed at krate, but all _kx_s must be sorted.', + type: 'performance' + }, + ], + seeAlso: ['Linear and Exponential Generators'] +}, +{ + name: 'bpfcos', + type: 'opcode', + category: 'Signal Generators:Linear and Exponential Generators', + description: 'Break point function with cosine (easy-in/easy-out) interpolation.', + syntax: 'ky = bpfcos(kx, kx1, ky1, kx2, ..., kxn, kyn)\n kys[] = bpfcos(kxs[], kx1, ky1, kx2, ..., kxn, kyn)\n ky = bpfcos(kx, kxs[], kys[])\n ky = bpfcos(kx, ixs[], iys[])\n ky, kz = bpfcos(kx, kxs[], kys[], kzs[])\n ky, kz = bpfcos(kx, ixs[], iys[], izs[])', + example: '--8<-- "examples/bpfcos.csd"', + parameters: [ + { + name: 'kx', + description: 'Input value. Can also be an array', + type: 'performance' + }, + { + name: 'kxn', + description: 'Defines a breakpoint. Can be changed at krate, but all _kx_s must be sorted', + type: 'performance' + }, + { + name: 'kyn', + description: 'Defines a breakpoint. Can be changed at krate, but all _kx_s must be sorted', + type: 'performance' + }, + ], + seeAlso: ['Linear and Exponential Generators'] +}, +{ + name: 'cosseg', + type: 'opcode', + category: 'Signal Generators:Linear and Exponential Generators', + description: 'Trace a series of line segments between specified points with cosine interpolation.', + syntax: 'ares = cosseg(ia, idur1, ib [, idur2] [, ic] [...])\n kres = cosseg(ia, idur1, ib [, idur2] [, ic] [...])', + example: '--8<-- "examples/cosseg.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'ia', + description: 'starting value.', + type: 'initialization' + }, + { + name: 'idur1', + description: 'duration in seconds of first segment. A zero or negative value will cause all initialization to be skipped.', + type: 'initialization' + }, + ], + seeAlso: ['Linear and Exponential Generators'] +}, +{ + name: 'cossegb', + type: 'opcode', + category: 'Signal Generators:Linear and Exponential Generators', + description: 'Trace a series of line segments between specified absolute points with cosine interpolation.', + syntax: 'ares = cossegb(ia, itim1, ib [, itim2] [, ic] [...])\n kres = cossegb(ia, itim1, ib [, itim2] [, ic] [...])', + example: '--8<-- "examples/cossegb.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'ia', + description: 'starting value.', + type: 'initialization' + }, + { + name: 'itim1', + description: 'time in seconds of end of first segment. A zero or negative value will cause all initialization to be skipped.', + type: 'initialization' + }, + ], + seeAlso: ['Linear and Exponential Generators'] +}, +{ + name: 'cossegr', + type: 'opcode', + category: 'Signal Generators:Linear and Exponential Generators', + description: 'Trace a series of line segments between specified points with cosine interpolation, including a release segment.', + syntax: 'ares = cossegr(ia, idur1, ib [, idur2] [, ic] [...], irel, iz)\n kres = cossegr(ia, idur1, ib [, idur2] [, ic] [...], irel, iz)', + example: '--8<-- "examples/cossegr.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'ia', + description: 'starting value.', + type: 'initialization' + }, + { + name: 'idur1', + description: 'duration in seconds of first segment. A zero or negative value will cause all initialization to be skipped.', + type: 'initialization' + }, + { + name: 'irel', + description: 'duration in seconds and final value of a note releasing segment.', + type: 'initialization' + }, + { + name: 'iz', + description: 'duration in seconds and final value of a note releasing segment.', + type: 'initialization' + }, + ], + seeAlso: ['Linear and Exponential Generators'] +}, +{ + name: 'expcurve', + type: 'opcode', + category: 'Signal Generators:Linear and Exponential Generators', + description: 'Generates a normalised exponential curve in range 0 to 1 of arbitrary steepness.', + syntax: 'kout = expcurve(kindex, ksteepness)', + example: '--8<-- "examples/expcurve.csd"', + parameters: [ + { + name: 'kindex', + description: 'Index value. Expected range 0 to 1.', + type: 'performance' + }, + { + name: 'ksteepness', + description: 'Steepness of the generated curve. Values closer to 1.0 result in a straighter line while larger values steepen the curve.', + type: 'performance' + }, + { + name: 'kout', + description: 'Scaled output.', + type: 'performance' + }, + ], + seeAlso: ['Linear and Exponential Generators'] +}, +{ + name: 'expon', + type: 'opcode', + category: 'Signal Generators:Linear and Exponential Generators', + description: 'Trace an exponential curve between specified points.', + syntax: 'ares = expon(ia, idur, ib)\n kres = expon(ia, idur, ib)', + example: '--8<-- "examples/expon.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'ia', + description: 'starting value. Zero is illegal for exponentials.', + type: 'initialization' + }, + { + name: 'ib', + description: 'value after _idur_ seconds. For exponentials, must be non-zero and must agree in sign with _ia_.', + type: 'initialization' + }, + { + name: 'idur', + description: 'duration in seconds of the segment. A zero or negative value will cause all initialization to be skipped.', + type: 'initialization' + }, + ], + seeAlso: ['Linear and Exponential Generators'] +}, +{ + name: 'expseg', + type: 'opcode', + category: 'Signal Generators:Linear and Exponential Generators', + description: 'Trace a series of exponential segments between specified points.', + syntax: 'ares = expseg(ia, idur1, ib [, idur2] [, ic] [...])\n kres = expseg(ia, idur1, ib [, idur2] [, ic] [...])', + example: '--8<-- "examples/expseg.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'ia', + description: 'starting value. Zero is illegal for exponentials.', + type: 'initialization' + }, + { + name: 'idur1', + description: 'duration in seconds of first segment. A zero or negative value will cause all initialization to be skipped.', + type: 'initialization' + }, + ], + seeAlso: ['Linear and Exponential Generators'] +}, +{ + name: 'expsega', + type: 'opcode', + category: 'Signal Generators:Linear and Exponential Generators', + description: 'An exponential segment generator operating at a-rate.', + syntax: 'ares = expsega(ia, idur1, ib [, idur2] [, ic] [...])', + example: '--8<-- "examples/expsega.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'ia', + description: 'starting value. Zero is illegal.', + type: 'initialization' + }, + { + name: 'idur1', + description: 'duration in seconds of first segment. A zero or negative value will cause all initialization to be skipped.', + type: 'initialization' + }, + ], + seeAlso: ['Linear and Exponential Generators'] +}, +{ + name: 'expsegb', + type: 'opcode', + category: 'Signal Generators:Linear and Exponential Generators', + description: 'Trace a series of exponential segments between specified absolute points.', + syntax: 'ares = expsegb(ia, itim1, ib [, itim2] [, ic] [...])\n kres = expsegb(ia, itim1, ib [, itim2] [, ic] [...])', + example: '--8<-- "examples/expsegb.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'ia', + description: 'starting value. Zero is illegal for exponentials.', + type: 'initialization' + }, + { + name: 'itim1', + description: 'time in seconds of end of first segment.', + type: 'initialization' + }, + ], + seeAlso: ['Linear and Exponential Generators'] +}, +{ + name: 'expsegba', + type: 'opcode', + category: 'Signal Generators:Linear and Exponential Generators', + description: 'An exponential segment generator operating at a-rate with absolute times.', + syntax: 'ares = expsegba(ia, itim1, ib [, itim2] [, ic] [...])', + example: '--8<-- "examples/expsegba.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'ia', + description: 'starting value. Zero is illegal.', + type: 'initialization' + }, + { + name: 'itim1', + description: 'time in seconds at end of first segment.', + type: 'initialization' + }, + ], + seeAlso: ['Linear and Exponential Generators'] +}, +{ + name: 'expsegr', + type: 'opcode', + category: 'Signal Generators:Linear and Exponential Generators', + description: 'Trace a series of exponential segments between specified points including a release segment.', + syntax: 'ares = expsegr(ia, idur1, ib [, idur2] [, ic] [...], irel, iz)\n kres = expsegr(ia, idur1, ib [, idur2] [, ic] [...], irel, iz)', + example: '--8<-- "examples/expsegr.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'ia', + description: 'starting value. Zero is illegal for exponentials.', + type: 'initialization' + }, + { + name: 'idur1', + description: 'duration in seconds of first segment. A zero or negative value will cause all initialization to be skipped.', + type: 'initialization' + }, + { + name: 'irel', + description: 'duration in seconds and final value of a note releasing segment.', + type: 'initialization' + }, + { + name: 'iz', + description: 'duration in seconds and final value of a note releasing segment.', + type: 'initialization' + }, + ], + seeAlso: ['Linear and Exponential Generators'] +}, +{ + name: 'gainslider', + type: 'opcode', + category: 'Signal Generators:Linear and Exponential Generators', + description: 'An implementation of a logarithmic gain curve which is similar to the gainslider~ object from Cycling 74 Max / MSP.', + syntax: 'kout = gainslider(kindex)', + example: '--8<-- "examples/gainslider.csd"', + parameters: [ + { + name: 'kindex', + description: 'Index value. Nominal range from 0-127. For example a range of 0-152 will give you a range from -∞ to +18.0 dB.', + type: 'performance' + }, + { + name: 'kout', + description: 'Scaled output.', + type: 'performance' + }, + ], + seeAlso: ['Linear and Exponential Generators'] +}, +{ + name: 'lincos', + type: 'opcode', + category: 'Signal Generators:Linear and Exponential Generators', + description: 'Linear to cosine interpolation.', + syntax: 'ky = lincos(kx, ky0, ky1 [, kx0, kx1 ])\n iy = lincos(ix, iy0, iy1 [, ix0, ix1 ])', + example: '--8<-- "examples/lincos.csd"', + parameters: [ + { + name: 'kx', + description: 'Input signal', + type: 'performance' + }, + { + name: 'ky0', + description: 'Lower limit of output range', + type: 'performance' + }, + { + name: 'ky1', + description: 'Higher limit of output range', + type: 'performance' + }, + { + name: 'kx0', + description: 'Lower limit of input range (default = 0)', + type: 'performance' + }, + { + name: 'kx1', + description: 'Higher limit of input range (default = 1)', + type: 'performance' + }, + ], + seeAlso: ['Linear and Exponential Generators'] +}, +{ + name: 'line', + type: 'opcode', + category: 'Signal Generators:Linear and Exponential Generators', + description: 'Trace a straight line between specified points.', + syntax: 'ares = line(ia, idur, ib)\n kres = line(ia, idur, ib)', + example: '--8<-- "examples/line.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'ia', + description: 'starting value.', + type: 'initialization' + }, + { + name: 'ib', + description: 'value after _idur_ seconds.', + type: 'initialization' + }, + { + name: 'idur', + description: 'duration in seconds of segment. A zero or negative value will cause all initialization to be skipped.', + type: 'initialization' + }, + ], + seeAlso: ['Linear and Exponential Generators'] +}, +{ + name: 'linlin', + type: 'opcode', + category: 'Signal Generators:Linear and Exponential Generators', + description: 'Linear to linear interpolation.', + syntax: 'ky = linlin(kx, ky0, ky1 [, kx0, kx1 ])\n iy = linlin(ix, iy0, iy1 [, ix0, ix1 ])\n kys[] = linlin(kxs[], ky0, ky1 [, kx0, kx1 ])\n iys[] = linlin(ixs[], ky0, ky1, [ kx0, kx1 ])\n kC[] = linlin(kx, kA[], kB[] [, kx0, kx1 ])', + example: '--8<-- "examples/linlin.csd"', + parameters: [ + { + name: 'kx', + description: 'Input signal', + type: 'performance' + }, + { + name: 'kx0', + description: 'Lower limit of input range. _Defaults to 0_', + type: 'performance' + }, + { + name: 'kx1', + description: 'Higher limit of input range. _Defaults to 1_', + type: 'performance' + }, + { + name: 'ky0', + description: 'Lower limit of output range', + type: 'performance' + }, + { + name: 'ky1', + description: 'Higher limit of output range', + type: 'performance' + }, + ], + seeAlso: ['Linear and Exponential Generators'] +}, +{ + name: 'linseg', + type: 'opcode', + category: 'Signal Generators:Linear and Exponential Generators', + description: 'Trace a series of line segments between specified points.', + syntax: 'ares = linseg(ia, idur1, ib [, idur2] [, ic] [...])\n kres = linseg(ia, idur1, ib [, idur2] [, ic] [...])', + example: '--8<-- "examples/linseg.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'ia', + description: 'starting value.', + type: 'initialization' + }, + { + name: 'idur1', + description: 'duration in seconds of first segment. A zero or negative value will cause all initialization to be skipped.', + type: 'initialization' + }, + ], + seeAlso: ['Linear and Exponential Generators'] +}, +{ + name: 'linsegb', + type: 'opcode', + category: 'Signal Generators:Linear and Exponential Generators', + description: 'Trace a series of line segments between specified absolute points.', + syntax: 'ares = linsegb(ia, itim1, ib [, itim2] [, ic] [...])\n kres = linsegb(ia, itim1, ib [, itim2] [, ic] [...])', + example: '--8<-- "examples/linsegb.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'ia', + description: 'starting value.', + type: 'initialization' + }, + { + name: 'itim1', + description: 'time in seconds of end of first segment. A zero or negative value will cause all initialization to be skipped.', + type: 'initialization' + }, + ], + seeAlso: ['Linear and Exponential Generators'] +}, +{ + name: 'linsegr', + type: 'opcode', + category: 'Signal Generators:Linear and Exponential Generators', + description: 'Trace a series of line segments between specified points including a release segment.', + syntax: 'ares = linsegr(ia, idur1, ib [, idur2] [, ic] [...], irel, iz)\n kres = linsegr(ia, idur1, ib [, idur2] [, ic] [...], irel, iz)', + example: '--8<-- "examples/linsegr.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'ia', + description: 'starting value.', + type: 'initialization' + }, + { + name: 'idur1', + description: 'duration in seconds of first segment. A zero or negative value will cause all initialization to be skipped.', + type: 'initialization' + }, + { + name: 'irel', + description: 'duration in seconds and final value of a note releasing segment.', + type: 'initialization' + }, + { + name: 'iz', + description: 'duration in seconds and final value of a note releasing segment.', + type: 'initialization' + }, + ], + seeAlso: ['Linear and Exponential Generators'] +}, +{ + name: 'logcurve', + type: 'opcode', + category: 'Signal Generators:Linear and Exponential Generators', + description: 'This opcode implements a formula for generating a normalised logarithmic curve in range 0 - 1. It is based on the Max / MSP work of Eric Singer (c) 1994.', + syntax: 'kout = logcurve(kindex, ksteepness)', + example: '--8<-- "examples/logcurve.csd"', + parameters: [ + { + name: 'kindex', + description: 'Index value. Expected range 0 to 1.', + type: 'performance' + }, + { + name: 'ksteepness', + description: 'Steepness of the generated curve. Values closer to 1.0 result in a straighter line while larger values steepen the curve.', + type: 'performance' + }, + { + name: 'kout', + description: 'Scaled output.', + type: 'performance' + }, + ], + seeAlso: ['Linear and Exponential Generators'] +}, +{ + name: 'loopseg', + type: 'opcode', + category: 'Signal Generators:Linear and Exponential Generators', + description: 'Generate control signal consisting of linear segments delimited by two or more specified points.', + syntax: 'ksig = loopseg(kfreq, ktrig, iphase, kvalue0, ktime0 [, kvalue1] [, ktime1] \\\n [, kvalue2] [, ktime2][...])', + example: '--8<-- "examples/loopseg.csd"', + parameters: [ + { + name: 'iphase', + description: 'A value between 0 and 1 to say where to start the loop. Zero, the commonest value, indicates the beginning.', + type: 'initialization' + }, + { + name: 'ksig', + description: 'Output signal.', + type: 'performance' + }, + { + name: 'kfreq', + description: 'Repeat rate in Hz or fraction of Hz.', + type: 'performance' + }, + { + name: 'ktrig', + description: 'If non-zero, retriggers the envelope from start (see [trigger opcode](../opcodes/trigger.md)), before the envelope cycle is completed.', + type: 'performance' + }, + ], + seeAlso: ['Linear and Exponential Generators'] +}, +{ + name: 'loopsegp', + type: 'opcode', + category: 'Signal Generators:Linear and Exponential Generators', + description: 'Control signals based on linear segments.', + syntax: 'ksig = loopsegp(kphase, kvalue0, kdur0, kvalue1 \\\n [, kdur1, ... , kdurN-1, kvalueN])', + example: '--8<-- "examples/loopsegp.csd"', + parameters: [ + { + name: 'ksig', + description: 'output signal', + type: 'performance' + }, + { + name: 'kphase', + description: 'point of the sequence read, expressed as a fraction of a cycle (0 to 1)', + type: 'performance' + }, + { + name: 'kvalueN', + description: 'values of points', + type: 'performance' + }, + ], + seeAlso: ['Linear and Exponential Generators'] +}, +{ + name: 'looptseg', + type: 'opcode', + category: 'Signal Generators:Linear and Exponential Generators', + description: 'Generate control signal consisting of exponential or linear segments delimited by two or more specified points.', + syntax: 'ksig = looptseg(kfreq, ktrig, iphase, kvalue0, ktype0, ktime0, [, kvalue1] \\\n [,ktype1] [, ktime1] [, kvalue2] [,ktype2] [, ktime2] [...] \\\n [, kvalueN] [,ktypeN] [, ktimeN])', + example: '--8<-- "examples/looptseg.csd"', + parameters: [ + { + name: 'iphase', + description: 'A value between 0 and 1 to say where to start the loop. Zero, the commonest value, indicates the beginning.', + type: 'initialization' + }, + { + name: 'ksig', + description: 'Output signal.', + type: 'performance' + }, + { + name: 'kfreq', + description: 'Repeat rate in Hz or fraction of Hz.', + type: 'performance' + }, + { + name: 'ktrig', + description: 'If non-zero, retriggers the envelope from start (see [trigger opcode](../opcodes/trigger.md)), before the envelope cycle is completed.', + type: 'performance' + }, + ], + seeAlso: ['Linear and Exponential Generators'] +}, +{ + name: 'loopxseg', + type: 'opcode', + category: 'Signal Generators:Linear and Exponential Generators', + description: 'Generate control signal consisting of exponential segments delimited by two or more specified points.', + syntax: 'ksig = loopxseg(kfreq, ktrig, iphase, kvalue0, ktime0 [, kvalue1] [, ktime1] \\\n [, kvalue2] [, ktime2] [...])', + example: '--8<-- "examples/loopxseg.csd"', + parameters: [ + { + name: 'ksig', + description: 'Output signal.', + type: 'performance' + }, + { + name: 'kfreq', + description: 'Repeat rate in Hz or fraction of Hz.', + type: 'performance' + }, + { + name: 'ktrig', + description: 'If non-zero, retriggers the envelope from start (see [trigger opcode](../opcodes/trigger.md)), before the envelope cycle is completed.', + type: 'performance' + }, + { + name: 'iphase', + description: 'A value between 0 and 1 to say where to start the loop. Zero, the commonest value, indicates the beginning.', + type: 'performance' + }, + ], + seeAlso: ['Linear and Exponential Generators'] +}, +{ + name: 'lpshold', + type: 'opcode', + category: 'Signal Generators:Linear and Exponential Generators', + description: 'Generate control signal consisting of held segments.', + syntax: 'ksig = lpshold(kfreq, ktrig, iphase, kvalue0, ktime0 [, kvalue1] [, ktime1] \\\n [, kvalue2] [, ktime2] [...])', + example: '--8<-- "examples/lpshold.csd"', + parameters: [ + { + name: 'ksig', + description: 'Output signal', + type: 'performance' + }, + { + name: 'kfreq', + description: 'Repeat rate in Hz or fraction of Hz', + type: 'performance' + }, + { + name: 'ktrig', + description: 'If non-zero, retriggers the envelope from start (see [trigger opcode](../opcodes/trigger.md)), before the envelope cycle is completed.', + type: 'performance' + }, + { + name: 'iphase', + description: 'A vaue between 0 and 1 to say where to start the loop. Zero, the commonest value, indicates the beginning.', + type: 'performance' + }, + ], + seeAlso: ['Linear and Exponential Generators'] +}, +{ + name: 'lpsholdp', + type: 'opcode', + category: 'Signal Generators:Linear and Exponential Generators', + description: 'Control signals based on held segments.', + syntax: 'ksig = lpsholdp(kphase, kvalue0, ktime0 [, kvalue1] [, ktime1] \\\n [, kvalue2] [, ktime2] [...])', + example: '--8<-- "examples/lpsholdp.csd"', + parameters: [ + { + name: 'ksig', + description: 'output signal', + type: 'performance' + }, + { + name: 'kphase', + description: 'point of the sequence read, expressed as a fraction of a cycle (0 to 1)', + type: 'performance' + }, + ], + seeAlso: ['Linear and Exponential Generators'] +}, +{ + name: 'scale', + type: 'opcode', + category: 'Signal Generators:Linear and Exponential Generators', + description: 'Arbitrary signal scaling.', + syntax: 'kscl = scale(kinput, kmax, kmin[, kimax, kimin])', + example: '--8<-- "examples/scale.csd"', + parameters: [ + { + name: 'kin', + description: 'Input value. Can originate from any k-rate source as long as that source\'s output is in range', + type: 'performance' + }, + { + name: 'kmin', + description: 'Minimum value of the resultant scale operation.', + type: 'performance' + }, + { + name: 'kmax', + description: 'Maximum value of the resultant scale operation.', + type: 'performance' + }, + { + name: 'kimin', + description: 'Optional; Minimum of the incoming value range, defaulting to zero.', + type: 'performance' + }, + { + name: 'kimax', + description: 'Optional; Maximum of the incoming value range, defaulting to one.', + type: 'performance' + }, + ], + seeAlso: ['Linear and Exponential Generators'] +}, +{ + name: 'scale2', + type: 'opcode', + category: 'Signal Generators:Linear and Exponential Generators', + description: 'Arbitrary signal scaling with optional smoothing.', + syntax: 'kscl = scale2(kinput, kmin, kmax[, kimin, kimax][ihtime])', + example: '--8<-- "examples/scale2.csd"', + parameters: [ + { + name: 'kin', + description: 'Input value. Can originate from any k-rate source and should be in the range _kimin_ to _kimax_. If it is larger than kimax it is treated as kimax, and if less than kimin then it is treated as kimin.', + type: 'performance' + }, + { + name: 'kmin', + description: 'Minimum value of the resultant scale operation.', + type: 'performance' + }, + { + name: 'kmax', + description: 'Maximum value of the resultant scale operation.', + type: 'performance' + }, + { + name: 'kimin', + description: 'Optional; Minimum of the incoming value range, defaulting to zero.', + type: 'performance' + }, + { + name: 'kimax', + description: 'Optional; Maximum of the incoming value range, defaulting to one.', + type: 'performance' + }, + ], + seeAlso: ['Linear and Exponential Generators'] +}, +] diff --git a/src/lib/csound-reference/signal-generators-models-and-emulations.ts b/src/lib/csound-reference/signal-generators-models-and-emulations.ts new file mode 100644 index 0000000..f93b55a --- /dev/null +++ b/src/lib/csound-reference/signal-generators-models-and-emulations.ts @@ -0,0 +1,1002 @@ +import type { CsoundReference } from './types' + +// Signal Generators:Models and Emulations +export const signalGeneratorsModelsAndEmulations: CsoundReference[] = [ +{ + name: 'bamboo', + type: 'opcode', + category: 'Signal Generators:Models and Emulations', + description: 'Semi-physical model of a bamboo sound.', + syntax: 'ares = bamboo(kamp, idettack [, inum] [, idamp] [, imaxshake] [, ifreq] \\\n [, ifreq1] [, ifreq2])', + example: '--8<-- "examples/bamboo-modern.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'idettack', + description: 'period of time over which all sound is stopped', + type: 'initialization' + }, + { + name: 'kamp', + description: 'Amplitude of output. Note: As these instruments are stochastic, this is only an approximation.', + type: 'performance' + }, + ], + seeAlso: ['Models and Emulations'] +}, +{ + name: 'barmodel', + type: 'opcode', + category: 'Signal Generators:Models and Emulations', + description: 'Creates a tone similar to a struck metal bar.', + syntax: 'ares = barmodel(kbcL, kbcR, iK, ib, kscan, iT30, ipos, ivel, iwid)', + example: '--8<-- "examples/barmodel-modern.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'iK', + description: 'dimensionless stiffness parameter. If this parameter is negative then the initialisation is skipped and the previous state of the bar is continued.', + type: 'initialization' + }, + { + name: 'ib', + description: 'high-frequency loss parameter (keep this small).', + type: 'initialization' + }, + { + name: 'iT30', + description: '30 db decay time in seconds.', + type: 'initialization' + }, + { + name: 'ipos', + description: 'position along the bar that the strike occurs.', + type: 'initialization' + }, + { + name: 'ivel', + description: 'normalized strike velocity.', + type: 'initialization' + }, + { + name: 'iwid', + description: 'spatial width of strike.', + type: 'initialization' + }, + { + name: 'kbcL', + description: 'Boundary condition at left end of bar (1 is clamped, 2 pivoting and 3 free).', + type: 'performance' + }, + { + name: 'kbcR', + description: 'Boundary condition at right end of bar (1 is clamped, 2 pivoting and 3 free).', + type: 'performance' + }, + { + name: 'kscan', + description: 'Speed of scanning the output location.', + type: 'performance' + }, + ], + seeAlso: ['Models and Emulations'] +}, +{ + name: 'cabasa', + type: 'opcode', + category: 'Signal Generators:Models and Emulations', + description: 'Semi-physical model of a cabasa sound.', + syntax: 'ares = cabasa(iamp, idettack [, inum] [, idamp] [, imaxshake])', + example: '--8<-- "examples/cabasa-modern.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'iamp', + description: 'Amplitude of output. Note: As these instruments are stochastic, this is only a approximation.', + type: 'initialization' + }, + { + name: 'idettack', + description: 'period of time over which all sound is stopped', + type: 'initialization' + }, + ], + seeAlso: ['Models and Emulations'] +}, +{ + name: 'crunch', + type: 'opcode', + category: 'Signal Generators:Models and Emulations', + description: 'Semi-physical model of a crunch sound.', + syntax: 'ares = crunch(iamp, idettack [, inum] [, idamp] [, imaxshake])', + example: '--8<-- "examples/crunch.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'iamp', + description: 'Amplitude of output. Note: As these instruments are stochastic, this is only a approximation.', + type: 'initialization' + }, + { + name: 'idettack', + description: 'period of time over which all sound is stopped', + type: 'initialization' + }, + ], + seeAlso: ['Models and Emulations'] +}, +{ + name: 'dripwater', + type: 'opcode', + category: 'Signal Generators:Models and Emulations', + description: 'Semi-physical model of a water drop.', + syntax: 'ares = dripwater(kamp, idettack [, inum] [, idamp] [, imaxshake] [, ifreq] \\\n [, ifreq1] [, ifreq2])', + example: '--8<-- "examples/dripwater.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'idettack', + description: 'period of time over which all sound is stopped', + type: 'initialization' + }, + { + name: 'kamp', + description: 'Amplitude of output. Note: As these instruments are stochastic, this is only an approximation.', + type: 'performance' + }, + ], + seeAlso: ['Models and Emulations'] +}, +{ + name: 'fareylen', + type: 'opcode', + category: 'Signal Generators:Models and Emulations', + description: 'Returns the length of a Farey Sequence.', + syntax: 'kfl = fareylen(kfn)', + example: '--8<-- "examples/fareylen.csd"', + parameters: [ + { + name: 'kfn', + description: 'Integer identifying the sequence.', + type: 'performance' + }, + ], + seeAlso: ['Models and Emulations'] +}, +{ + name: 'fareyleni', + type: 'opcode', + category: 'Signal Generators:Models and Emulations', + description: 'Returns the length of a Farey Sequence.', + syntax: 'ifl = fareyleni(ifn)', + example: '--8<-- "examples/fareyleni.csd"', + rates: ['i-rate'], + seeAlso: ['Models and Emulations'] +}, +{ + name: 'gendy', + type: 'opcode', + category: 'Signal Generators:Models and Emulations', + description: 'Dynamic stochastic approach to waveform synthesis conceived by Iannis Xenakis.', + syntax: 'ares = gendy(kamp, kampdist, kdurdist, kadpar, kddpar, kminfreq, kmaxfreq, \\\n kampscl, kdurscl [, initcps] [, knum])\n kres = gendy(kamp, kampdist, kdurdist, kadpar, kddpar, kminfreq, kmaxfreq, \\\n kampscl, kdurscl [, initcps] [, knum])', + example: '--8<-- "examples/gendy.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'kamp', + description: 'amplitude.', + type: 'performance' + }, + { + name: 'kampdist', + description: 'choice of probability distribution for the next perturbation of the amplitude of a control point. The valid distributions are:', + type: 'performance' + }, + { + name: 'kdurdist', + description: 'choice of distribution for the perturbation of the current inter control point duration. See _kampdist_ for the valid distributions. If _kdurdist_=6, the user can use an external k-rate signal through _kddpar_.', + type: 'performance' + }, + { + name: 'kadpar', + description: 'parameter for the _kampdist_ distribution. Should be in the range of 0.0001 to 1.', + type: 'performance' + }, + { + name: 'kddpar', + description: 'parameter for the _kdurdist_ distribution. Should be in the range of 0.0001 to 1.', + type: 'performance' + }, + { + name: 'kminfreq', + description: 'minimum allowed frequency of oscillation.', + type: 'performance' + }, + { + name: 'kmaxfreq', + description: 'maximum allowed frequency of oscillation.', + type: 'performance' + }, + { + name: 'kampscl', + description: 'multiplier for the distribution\'s delta value for amplitude (1.0 is full range).', + type: 'performance' + }, + { + name: 'kdurscl', + description: 'multiplier for the distribution\'s delta value for duration.', + type: 'performance' + }, + { + name: 'knum', + description: '1 segments and is repeated in the time. The vertexes (control points) are moved according to a stochastic action and they are limited within the boundaries of a mirror formed by an amplitude barrier and a time barrier.', + type: 'performance' + }, + ], + seeAlso: ['Models and Emulations', 'gendyc', 'gendyx'] +}, +{ + name: 'gendyc', + type: 'opcode', + category: 'Signal Generators:Models and Emulations', + description: 'Dynamic stochastic approach to waveform synthesis using cubic interpolation.', + syntax: 'ares = gendyc(kamp, kampdist, kdurdist, kadpar, kddpar, kminfreq, kmaxfreq, \\\n kampscl, kdurscl [, initcps] [, knum])\n kres = gendyc(kamp, kampdist, kdurdist, kadpar, kddpar, kminfreq, kmaxfreq, \\\n kampscl, kdurscl [, initcps] [, knum])', + example: '--8<-- "examples/gendyc.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'kamp', + description: 'amplitude.', + type: 'performance' + }, + { + name: 'kampdist', + description: 'choice of probability distribution for the next perturbation of the amplitude of a control point. The valid distributions are:', + type: 'performance' + }, + { + name: 'kdurdist', + description: 'choice of distribution for the perturbation of the current inter control point duration. See _kampdist_ for the valid distributions. If _kdurdist_=6, the user can use an external k-rate signal through _kddpar_.', + type: 'performance' + }, + { + name: 'kadpar', + description: 'parameter for the _kampdist_ distribution. Should be in the range of 0.0001 to 1.', + type: 'performance' + }, + { + name: 'kddpar', + description: 'parameter for the _kdurdist_ distribution. Should be in the range of 0.0001 to 1.', + type: 'performance' + }, + { + name: 'kminfreq', + description: 'minimum allowed frequency of oscillation.', + type: 'performance' + }, + { + name: 'kmaxfreq', + description: 'maximum allowed frequency of oscillation.', + type: 'performance' + }, + { + name: 'kampscl', + description: 'multiplier for the distribution\'s delta value for amplitude (1.0 is full range).', + type: 'performance' + }, + { + name: 'kdurscl', + description: 'multiplier for the distribution\'s delta value for duration.', + type: 'performance' + }, + { + name: 'knum', + description: '1 segments and is repeated in the time. The vertexes (control points) are moved according to a stochastic action and they are limited within the boundaries of a mirror formed by an amplitude barrier and a time barrier.', + type: 'performance' + }, + ], + seeAlso: ['Models and Emulations', 'gendy', 'gendyx'] +}, +{ + name: 'gendyx', + type: 'opcode', + category: 'Signal Generators:Models and Emulations', + description: 'Variation of the dynamic stochastic approach to waveform synthesis conceived by Iannis Xenakis.', + syntax: 'ares = gendyx(kamp, kampdist, kdurdist, kadpar, kddpar, kminfreq, kmaxfreq, \\\n kampscl, kdurscl, kcurveup, kcurvedown [, initcps] [, knum])\n kres = gendyx(kamp, kampdist, kdurdist, kadpar, kddpar, kminfreq, kmaxfreq, \\\n kampscl, kdurscl, kcurveup, kcurvedown [, initcps] [, knum])', + example: '--8<-- "examples/gendyx.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'kamp', + description: 'amplitude.', + type: 'performance' + }, + { + name: 'kampdist', + description: 'choice of probability distribution for the next perturbation of the amplitude of a control point. The valid distributions are:', + type: 'performance' + }, + { + name: 'kdurdist', + description: 'choice of distribution for the perturbation of the current inter control point duration. See _kampdist_ for the valid distributions. If _kdurdist_=6, the user can use an external k-rate signal through _kddpar_.', + type: 'performance' + }, + { + name: 'kadpar', + description: 'parameter for the _kampdist_ distribution. Should be in the range of 0.0001 to 1.', + type: 'performance' + }, + { + name: 'kddpar', + description: 'parameter for the _kdurdist_ distribution. Should be in the range of 0.0001 to 1.', + type: 'performance' + }, + { + name: 'kminfreq', + description: 'minimum allowed frequency of oscillation.', + type: 'performance' + }, + { + name: 'kmaxfreq', + description: 'maximum allowed frequency of oscillation.', + type: 'performance' + }, + { + name: 'kampscl', + description: 'multiplier for the distribution\'s delta value for amplitude (1.0 is full range).', + type: 'performance' + }, + { + name: 'kdurscl', + description: 'multiplier for the distribution\'s delta value for duration.', + type: 'performance' + }, + { + name: 'kcurveup', + description: 'controls the curve for the increasing amplitudes between two points; it has to be non negative.', + type: 'performance' + }, + { + name: 'kcurvedown', + description: 'controls the curve for the decreasing amplitudes between two points; it has to be non negative.', + type: 'performance' + }, + { + name: 'knum', + description: '1 curves and is repeated in the time. The vertexes (control points) are moved according to a stochastic action and they are limited within the boundaries of a mirror formed by an amplitude barrier and a time barrier.', + type: 'performance' + }, + ], + seeAlso: ['Models and Emulations', 'gendyc', 'gendy'] +}, +{ + name: 'gogobel', + type: 'opcode', + category: 'Signal Generators:Models and Emulations', + description: 'Audio output is a tone related to the striking of a cow bell or similar.', + syntax: 'ares = gogobel(kamp, kfreq, ihrd, ipos, imp, kvibf, kvamp, ivfn)', + example: '--8<-- "examples/gogobel.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'ihrd', + description: 'the hardness of the stick used in the strike. A range of 0 to 1 is used. 0.5 is a suitable value.', + type: 'initialization' + }, + { + name: 'ipos', + description: 'where the block is hit, in the range 0 to 1.', + type: 'initialization' + }, + { + name: 'imp', + description: 'a table of the strike impulses. The file [marmstk1.wav](../examples/marmstk1.wav) is a suitable function from measurements and can be loaded with a [GEN01](../scoregens/gen01.md) table. It is also available at [ftp://ftp.cs.bath.ac.uk/pub/dream/documentation/sounds/modelling/](ftp://ftp.cs.bath.ac.uk/pub/dream/documentation/sounds/modelling/).', + type: 'initialization' + }, + { + name: 'ivfn', + description: 'shape of vibrato, usually a sine table, created by a function.', + type: 'initialization' + }, + { + name: 'kamp', + description: 'Amplitude of note.', + type: 'performance' + }, + { + name: 'kfreq', + description: 'Frequency of note played.', + type: 'performance' + }, + { + name: 'kvibf', + description: 'frequency of vibrato in Hertz. Suggested range is 0 to 12', + type: 'performance' + }, + { + name: 'kvamp', + description: 'amplitude of the vibrato', + type: 'performance' + }, + ], + seeAlso: ['Models and Emulations'] +}, +{ + name: 'guiro', + type: 'opcode', + category: 'Signal Generators:Models and Emulations', + description: 'Semi-physical model of a guiro sound.', + syntax: 'ares = guiro(kamp, idettack [, inum] [, idamp] [, imaxshake] [, ifreq] [, ifreq1])', + example: '--8<-- "examples/guiro.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'idettack', + description: 'period of time over which all sound is stopped', + type: 'initialization' + }, + { + name: 'kamp', + description: 'Amplitude of output. Note: As these instruments are stochastic, this is only an approximation.', + type: 'performance' + }, + ], + seeAlso: ['Models and Emulations'] +}, +{ + name: 'lorenz', + type: 'opcode', + category: 'Signal Generators:Models and Emulations', + description: 'Implements the Lorenz system of equations.', + syntax: 'ax, ay, az = lorenz(ksv, krv, kbv, kh, ix, iy, iz, iskip [, iskipinit])', + example: '--8<-- "examples/lorenz.csd"', + parameters: [ + { + name: 'ix', + description: 'the initial coordinates of the particle.', + type: 'initialization' + }, + { + name: 'iy', + description: 'the initial coordinates of the particle.', + type: 'initialization' + }, + { + name: 'iz', + description: 'the initial coordinates of the particle.', + type: 'initialization' + }, + { + name: 'iskip', + description: 'used to skip generated values. If _iskip_ is set to 5, only every fifth value generated is output. This is useful in generating higher pitched tones.', + type: 'initialization' + }, + { + name: 'ksv', + description: 'the Prandtl number or sigma', + type: 'performance' + }, + { + name: 'krv', + description: 'the Rayleigh number', + type: 'performance' + }, + { + name: 'kbv', + description: 'the ratio of the length and width of the box in which the convection currents are generated', + type: 'performance' + }, + { + name: 'kh', + description: 'the step size used in approximating the differential equation. This can be used to control the pitch of the systems. Values of .1-.001 are typical.', + type: 'performance' + }, + ], + seeAlso: ['Models and Emulations'] +}, +{ + name: 'mandel', + type: 'opcode', + category: 'Signal Generators:Models and Emulations', + description: 'Mandelbrot set.', + syntax: 'kiter, koutrig = mandel( ktrig, kx, ky, kmaxIter)', + example: '--8<-- "examples/mandel.csd"', + parameters: [ + { + name: 'kiter', + description: 'number of iterations', + type: 'performance' + }, + { + name: 'koutrig', + description: 'output trigger signal', + type: 'performance' + }, + { + name: 'ktrig', + description: 'input trigger signal', + type: 'performance' + }, + { + name: 'kx', + description: 'coordinates of a given point belonging to the complex plane', + type: 'performance' + }, + { + name: 'ky', + description: 'coordinates of a given point belonging to the complex plane', + type: 'performance' + }, + { + name: 'kmaxIter', + description: 'maximum iterations allowed', + type: 'performance' + }, + ], + seeAlso: ['Models and Emulations'] +}, +{ + name: 'mandol', + type: 'opcode', + category: 'Signal Generators:Models and Emulations', + description: 'An emulation of a mandolin.', + syntax: 'ares = mandol(kamp, kfreq, kpluck, kdetune, kgain, ksize \\\n [, ifn] [, iminfreq])', + example: '--8<-- "examples/mandol.csd"', + rates: ['a-rate', 'k-rate', 'i-rate'], + parameters: [ + { + name: 'ifn', + description: 'table number containing the pluck wave form. The file [mandpluk.aiff](../examples/mandpluk.aiff) is suitable for this. It is also available at [ftp://ftp.cs.bath.ac.uk/pub/dream/documentation/sounds/modelling/](ftp://ftp.cs.bath.ac.uk/pub/dream/documentation/sounds/modelling/).', + type: 'initialization' + }, + { + name: 'kamp', + description: 'Amplitude of note.', + type: 'performance' + }, + { + name: 'kfreq', + description: 'Frequency of note played.', + type: 'performance' + }, + { + name: 'kpluck', + description: 'The pluck position, in range 0 to 1. Suggest 0.4.', + type: 'performance' + }, + { + name: 'kdetune', + description: 'The proportional detuning between the two strings. Suggested range 0.9 to 1.', + type: 'performance' + }, + { + name: 'kgain', + description: 'the loop gain of the model, in the range 0.97 to 1.', + type: 'performance' + }, + { + name: 'ksize', + description: 'The size of the body of the mandolin. Range 0 to 2.', + type: 'performance' + }, + ], + seeAlso: ['Models and Emulations'] +}, +{ + name: 'marimba', + type: 'opcode', + category: 'Signal Generators:Models and Emulations', + description: 'Physical model related to the striking of a wooden block as found in a marimba.', + syntax: 'ares = marimba(kamp, kfreq, ihrd, ipos, imp, kvibf, kvamp, ivibfn, idec \\\n [, idoubles] [, itriples])', + example: '--8<-- "examples/marimba.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'ihrd', + description: 'the hardness of the stick used in the strike. A range of 0 to 1 is used. 0.5 is a suitable value.', + type: 'initialization' + }, + { + name: 'ipos', + description: 'where the block is hit, in the range 0 to 1.', + type: 'initialization' + }, + { + name: 'imp', + description: 'a table of the strike impulses. The file [marmstk1.wav](../examples/marmstk1.wav) is a suitable function from measurements and can be loaded with a [GEN01](../scoregens/gen01.md) table. It is also available at [ftp://ftp.cs.bath.ac.uk/pub/dream/documentation/sounds/modelling/](ftp://ftp.cs.bath.ac.uk/pub/dream/documentation/sounds/modelling/).', + type: 'initialization' + }, + { + name: 'ivfn', + description: 'shape of vibrato, usually a sine table, created by a function', + type: 'initialization' + }, + { + name: 'idec', + description: 'time before end of note when damping is introduced', + type: 'initialization' + }, + { + name: 'kamp', + description: 'Amplitude of note.', + type: 'performance' + }, + { + name: 'kfreq', + description: 'Frequency of note played.', + type: 'performance' + }, + { + name: 'kvibf', + description: 'frequency of vibrato in Hertz. Suggested range is 0 to 12', + type: 'performance' + }, + { + name: 'kvamp', + description: 'amplitude of the vibrato', + type: 'performance' + }, + ], + seeAlso: ['Models and Emulations'] +}, +{ + name: 'moog', + type: 'opcode', + category: 'Signal Generators:Models and Emulations', + description: 'An emulation of a mini-Moog synthesizer.', + syntax: 'ares = moog(kamp, kfreq, kfiltq, kfiltrate, kvibf, kvamp, iafn, iwfn, ivfn)', + example: '--8<-- "examples/moog.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'iafn', + description: 'three table numbers containing the attack waveform (unlooped), the main looping wave form, and the vibrato waveform. The files [mandpluk.aiff](../examples/mandpluk.aiff) and [impuls20.aiff](../examples/impuls20.aiff) are suitable for the first two, and a sine wave for the last.', + type: 'initialization' + }, + { + name: 'iwfn', + description: 'three table numbers containing the attack waveform (unlooped), the main looping wave form, and the vibrato waveform. The files [mandpluk.aiff](../examples/mandpluk.aiff) and [impuls20.aiff](../examples/impuls20.aiff) are suitable for the first two, and a sine wave for the last.', + type: 'initialization' + }, + { + name: 'ivfn', + description: 'three table numbers containing the attack waveform (unlooped), the main looping wave form, and the vibrato waveform. The files [mandpluk.aiff](../examples/mandpluk.aiff) and [impuls20.aiff](../examples/impuls20.aiff) are suitable for the first two, and a sine wave for the last.', + type: 'initialization' + }, + { + name: 'kamp', + description: 'Amplitude of note.', + type: 'performance' + }, + { + name: 'kfreq', + description: 'Frequency of note played.', + type: 'performance' + }, + { + name: 'kfiltq', + description: 'Q of the filter, in the range 0.8 to 0.9', + type: 'performance' + }, + { + name: 'kfiltrate', + description: 'rate control for the filter in the range 0 to 0.0002', + type: 'performance' + }, + { + name: 'kvibf', + description: 'frequency of vibrato in Hertz. Suggested range is 0 to 12', + type: 'performance' + }, + { + name: 'kvamp', + description: 'amplitude of the vibrato', + type: 'performance' + }, + ], + seeAlso: ['Models and Emulations'] +}, +{ + name: 'planet', + type: 'opcode', + category: 'Signal Generators:Models and Emulations', + description: 'Simulates a planet orbiting in a binary star system.', + syntax: 'ax, ay, az = planet(kmass1, kmass2, ksep, ix, iy, iz, ivx, ivy, ivz, idelta \\\n [, ifriction] [, iskip])', + example: '--8<-- "examples/planet.csd"', + parameters: [ + { + name: 'ix', + description: 'the initial x, y and z coordinates of the planet', + type: 'initialization' + }, + { + name: 'iy', + description: 'the initial x, y and z coordinates of the planet', + type: 'initialization' + }, + { + name: 'iz', + description: 'the initial x, y and z coordinates of the planet', + type: 'initialization' + }, + { + name: 'ivx', + description: 'the initial velocity vector components for the planet.', + type: 'initialization' + }, + { + name: 'ivy', + description: 'the initial velocity vector components for the planet.', + type: 'initialization' + }, + { + name: 'ivz', + description: 'the initial velocity vector components for the planet.', + type: 'initialization' + }, + { + name: 'idelta', + description: 'the step size used to approximate the differential equation.', + type: 'initialization' + }, + { + name: 'ax', + description: 'the output x, y, and z coodinates of the planet', + type: 'performance' + }, + { + name: 'ay', + description: 'the output x, y, and z coodinates of the planet', + type: 'performance' + }, + { + name: 'az', + description: 'the output x, y, and z coodinates of the planet', + type: 'performance' + }, + { + name: 'ksep', + description: 'the separation between the two stars', + type: 'performance' + }, + { + name: 'kmass1', + description: 'the mass of the first star', + type: 'performance' + }, + { + name: 'kmass2', + description: 'the mass of the second star', + type: 'performance' + }, + ], + seeAlso: ['Models and Emulations', 'http://www.csoundjournal.com/issue9/FlutesInOrbit.html'] +}, +{ + name: 'prepiano', + type: 'opcode', + category: 'Signal Generators:Models and Emulations', + description: 'Creates a tone similar to a piano string prepared in a Cageian fashion.', + syntax: 'ares = prepiano(ifreq, iNS, iD, iK, iT30, iB, kbcl, kbcr, imass, ihvfreq, \\\n iinit, ipos, ivel, isfreq, isspread[, irattles, irubbers])\n al, ar = prepiano(ifreq, iNS, iD, iK, iT30, iB, kbcl, kbcr, imass, ihvfreq, \\\n iinit, ipos, ivel, isfreq, isspread[, irattles, irubbers])', + example: '--8<-- "examples/prepiano.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'ifreq', + description: 'The base frequency of the string.', + type: 'initialization' + }, + { + name: 'iNS', + description: 'the number of strings involved. In a real piano 1, 2 or 3 strings are found in different frequency regions.', + type: 'initialization' + }, + { + name: 'iD', + description: 'the amount each string other that the first is detuned from the main frequency, measured in cents.', + type: 'initialization' + }, + { + name: 'iK', + description: 'dimensionless stiffness parameter.', + type: 'initialization' + }, + { + name: 'iT30', + description: '30 db decay time in seconds.', + type: 'initialization' + }, + { + name: 'ib', + description: 'high-frequency loss parameter (keep this small).', + type: 'initialization' + }, + { + name: 'imass', + description: 'the mass of the piano hammer.', + type: 'initialization' + }, + { + name: 'ihvfreq', + description: 'the frequency of the natural vibrations of the hammer.', + type: 'initialization' + }, + { + name: 'iinit', + description: 'the initial position of the hammer.', + type: 'initialization' + }, + { + name: 'ipos', + description: 'position along the string that the strike occurs.', + type: 'initialization' + }, + { + name: 'ivel', + description: 'normalized strike velocity.', + type: 'initialization' + }, + { + name: 'isfreq', + description: 'scanning frequency of the reading place.', + type: 'initialization' + }, + { + name: 'isspread', + description: 'scanning frequency spread.', + type: 'initialization' + }, + { + name: 'irattles', + description: 'table number giving locations of any rattle(s).', + type: 'initialization' + }, + { + name: 'irubbers', + description: 'table number giving locations of any rubbers(s).', + type: 'initialization' + }, + { + name: 'kbcL', + description: 'Boundary condition at left end of string (1 is clamped, 2 pivoting and 3 free).', + type: 'performance' + }, + { + name: 'kbcR', + description: 'Boundary condition at right end of string (1 is clamped, 2 pivoting and 3 free).', + type: 'performance' + }, + ], + seeAlso: ['Models and Emulations'] +}, +{ + name: 'sandpaper', + type: 'opcode', + category: 'Signal Generators:Models and Emulations', + description: 'Semi-physical model of a sandpaper sound.', + syntax: 'ares = sandpaper(iamp, idettack [, inum] [, idamp] [, imaxshake])', + example: '--8<-- "examples/sandpaper.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'iamp', + description: 'Amplitude of output. Note: As these instruments are stochastic, this is only a approximation.', + type: 'initialization' + }, + { + name: 'idettack', + description: 'period of time over which all sound is stopped', + type: 'initialization' + }, + ], + seeAlso: ['Models and Emulations'] +}, +{ + name: 'sekere', + type: 'opcode', + category: 'Signal Generators:Models and Emulations', + description: 'Semi-physical model of a sekere sound.', + syntax: 'ares = sekere(iamp, idettack [, inum] [, idamp] [, imaxshake])', + example: '--8<-- "examples/sekere.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'iamp', + description: 'Amplitude of output. Note: As these instruments are stochastic, this is only a approximation.', + type: 'initialization' + }, + { + name: 'idettack', + description: 'period of time over which all sound is stopped', + type: 'initialization' + }, + ], + seeAlso: ['Models and Emulations'] +}, +{ + name: 'shaker', + type: 'opcode', + category: 'Signal Generators:Models and Emulations', + description: 'Sounds like the shaking of a maraca or similar gourd instrument.', + syntax: 'ares = shaker(kamp, kfreq, kbeans, kdamp, ktimes [, idecay])', + example: '--8<-- "examples/shaker.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'idecay', + description: 'If present indicates for how long at the end of the note the shaker is to be damped. The default value is zero.', + type: 'initialization' + }, + { + name: 'kamp', + description: 'Amplitude of note.', + type: 'performance' + }, + { + name: 'kfreq', + description: 'Frequency of note played.', + type: 'performance' + }, + { + name: 'kbeans', + description: 'The number of beans in the gourd. A value of 8 seems suitable.', + type: 'performance' + }, + { + name: 'kdamp', + description: 'The damping value of the shaker. Values of 0.98 to 1 seems suitable, with 0.99 a reasonable default.', + type: 'performance' + }, + { + name: 'ktimes', + description: 'Number of times shaken.', + type: 'performance' + }, + ], + seeAlso: ['Models and Emulations'] +}, +{ + name: 'sleighbells', + type: 'opcode', + category: 'Signal Generators:Models and Emulations', + description: 'Semi-physical model of a sleighbell sound.', + syntax: 'ares = sleighbells(kamp, idettack [, inum] [, idamp] [, imaxshake] [, ifreq] \\\n [, ifreq1] [, ifreq2])', + example: '--8<-- "examples/sleighbells.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'idettack', + description: 'period of time over which all sound is stopped', + type: 'initialization' + }, + { + name: 'kamp', + description: 'Amplitude of output. Note: As these instruments are stochastic, this is only an approximation.', + type: 'performance' + }, + ], + seeAlso: ['Models and Emulations'] +}, +{ + name: 'stix', + type: 'opcode', + category: 'Signal Generators:Models and Emulations', + description: 'Semi-physical model of a stick sound.', + syntax: 'ares = stix(iamp, idettack [, inum] [, idamp] [, imaxshake])', + example: '--8<-- "examples/stix.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'iamp', + description: 'Amplitude of output. Note: As these instruments are stochastic, this is only a approximation.', + type: 'initialization' + }, + { + name: 'idettack', + description: 'period of time over which all sound is stopped', + type: 'initialization' + }, + ], + seeAlso: ['Models and Emulations'] +}, +] diff --git a/src/lib/csound-reference/signal-generators-phasors.ts b/src/lib/csound-reference/signal-generators-phasors.ts new file mode 100644 index 0000000..f98df03 --- /dev/null +++ b/src/lib/csound-reference/signal-generators-phasors.ts @@ -0,0 +1,63 @@ +import type { CsoundReference } from './types' + +// Signal Generators:Phasors +export const signalGeneratorsPhasors: CsoundReference[] = [ +{ + name: 'ephasor', + type: 'opcode', + category: 'Signal Generators:Phasors', + description: 'Produces two outputs: a periodic phase signal and a periodic exponential decaying signal.', + syntax: 'aexp,aph = ephasor(kfreq, kR)', + example: '--8<-- "examples/ephasor.csd"', + parameters: [ + { + name: 'kfreq', + description: 'the rate at which the phase and exponential signals are generated', + type: 'performance' + }, + { + name: 'kR', + description: 'a parameter controlling the decay rate of the exponential signal, 0 < kR < 1. Lower values produce faster decays.', + type: 'performance' + }, + ], + seeAlso: ['Phasors'] +}, +{ + name: 'phasor', + type: 'opcode', + category: 'Signal Generators:Phasors', + description: 'Produce a normalized moving phase value.', + syntax: 'ares = phasor(xcps [, iphs])\n kres = phasor(kcps [, iphs])', + example: '--8<-- "examples/phasor.csd"', + rates: ['a-rate', 'k-rate', 'i-rate'], + seeAlso: ['Phasors'] +}, +{ + name: 'phasorbnk', + type: 'opcode', + category: 'Signal Generators:Phasors', + description: 'Produce an arbitrary number of normalized moving phase values, accessable by an index.', + syntax: 'ares = phasorbnk(xcps, kndx, icnt [, iphs])\n kres = phasorbnk(kcps, kndx, icnt [, iphs])', + example: '--8<-- "examples/phasorbnk.csd"', + rates: ['a-rate', 'k-rate', 'i-rate'], + parameters: [ + { + name: 'icnt', + description: 'maximum number of phasors to be used.', + type: 'initialization' + }, + { + name: 'iphs', + description: 'initial phase, expressed as a fraction of a cycle (0 to 1). If -1 initialization is skipped. If _iphas_>1 each phasor will be initialized with a random value.', + type: 'initialization' + }, + { + name: 'kndx', + description: 'index value to access individual phasors', + type: 'performance' + }, + ], + seeAlso: ['Phasors'] +}, +] diff --git a/src/lib/csound-reference/signal-generators-random-noise-generators.ts b/src/lib/csound-reference/signal-generators-random-noise-generators.ts new file mode 100644 index 0000000..fc37a58 --- /dev/null +++ b/src/lib/csound-reference/signal-generators-random-noise-generators.ts @@ -0,0 +1,956 @@ +import type { CsoundReference } from './types' + +// Signal Generators:Random (Noise) Generators +export const signalGeneratorsRandomNoiseGenerators: CsoundReference[] = [ +{ + name: 'betarand', + type: 'opcode', + category: 'Signal Generators:Random (Noise) Generators', + description: 'Beta distribution random number generator (positive values only).', + syntax: 'ares = betarand(krange, kalpha, kbeta)\n ires = betarand(krange, kalpha, kbeta)\n kres = betarand(krange, kalpha, kbeta)', + example: '--8<-- "examples/betarand-modern.csd"', + rates: ['a-rate', 'k-rate', 'i-rate'], + parameters: [ + { + name: 'krange', + description: 'range of the random numbers (0 - _krange_).', + type: 'performance' + }, + { + name: 'kalpha', + description: 'alpha value. If _kalpha_ is smaller than one, smaller values favor values near 0.', + type: 'performance' + }, + { + name: 'kbeta', + description: 'beta value. If _kbeta_ is smaller than one, smaller values favor values near _krange_.', + type: 'performance' + }, + ], + seeAlso: ['Random (Noise) Generators'] +}, +{ + name: 'bexprnd', + type: 'opcode', + category: 'Signal Generators:Random (Noise) Generators', + description: 'Exponential distribution random number generator.', + syntax: 'ares = bexprnd(krange)\n ires = bexprnd(krange)\n kres = bexprnd(krange)', + example: '--8<-- "examples/bexprnd-modern.csd"', + rates: ['a-rate', 'k-rate', 'i-rate'], + parameters: [ + { + name: 'krange', + description: 'the range of the random numbers (-_krange_ to +_krange_)', + type: 'performance' + }, + ], + seeAlso: ['Random (Noise) Generators'] +}, +{ + name: 'cauchy', + type: 'opcode', + category: 'Signal Generators:Random (Noise) Generators', + description: 'Cauchy distribution random number generator.', + syntax: 'ares = cauchy(kalpha)\n ires = cauchy(kalpha)\n kres = cauchy(kalpha)', + example: '--8<-- "examples/cauchy-modern.csd"', + rates: ['a-rate', 'k-rate', 'i-rate'], + parameters: [ + { + name: 'kalpha', + description: 'controls the spread from zero (big _kalpha_ = big spread). Outputs both positive and negative numbers.', + type: 'performance' + }, + ], + seeAlso: ['Random (Noise) Generators'] +}, +{ + name: 'cauchyi', + type: 'opcode', + category: 'Signal Generators:Random (Noise) Generators', + description: 'Cauchy distribution random number generator with interpolation between values.', + syntax: 'ares = cauchyi(klambda, xamp, xcps)\n ires = cauchyi(klambda, xamp, xcps)\n kres = cauchyi(klambda, xamp, xcps)', + example: '--8<-- "examples/cauchyi-modern.csd"', + rates: ['a-rate', 'k-rate', 'i-rate'], + parameters: [ + { + name: 'kalpha', + description: 'controls the spread from zero (big _kalpha_ = big spread). Outputs both positive and negative numbers.', + type: 'performance' + }, + { + name: 'xamp', + description: 'range over which random numbers are distributed.', + type: 'performance' + }, + { + name: 'xcps', + description: 'the frequency which new random numbers are generated.', + type: 'performance' + }, + ], + seeAlso: ['Random (Noise) Generators'] +}, +{ + name: 'cuserrnd', + type: 'opcode', + category: 'Signal Generators:Random (Noise) Generators', + description: 'Continuous USER-defined-distribution RaNDom generator.', + syntax: 'aout = cuserrnd(kmin, kmax, ktableNum)\n iout = cuserrnd(imin, imax, itableNum)\n kout = cuserrnd(kmin, kmax, ktableNum)', + example: '--8<-- "examples/cuserrnd.csd"', + parameters: [ + { + name: 'imin', + description: 'minimum range limit', + type: 'initialization' + }, + { + name: 'imax', + description: 'maximum range limit', + type: 'initialization' + }, + { + name: 'itableNum', + description: 'number of table containing the random-distribution function. Such table is generated by the user. See [GEN40](../scoregens/gen40.md), [GEN41](../scoregens/gen41.md), and [GEN42](../scoregens/gen42.md). The table length does not need to be a power of 2.', + type: 'initialization' + }, + { + name: 'ktableNum', + description: 'number of table containing the random-distribution function. Such table is generated by the user. See [GEN40](../scoregens/gen40.md), [GEN41](../scoregens/gen41.md), and [GEN42](../scoregens/gen42.md). The table length does not need to be a power of 2.', + type: 'performance' + }, + { + name: 'kmin', + description: 'minimum range limit', + type: 'performance' + }, + { + name: 'kmax', + description: 'maximum range limit', + type: 'performance' + }, + ], + seeAlso: ['Random (Noise) Generators'] +}, +{ + name: 'duserrnd', + type: 'opcode', + category: 'Signal Generators:Random (Noise) Generators', + description: 'Discrete USER-defined-distribution RaNDom generator.', + syntax: 'aout = duserrnd(ktableNum)\n iout = duserrnd(itableNum)\n kout = duserrnd(ktableNum)', + example: '--8<-- "examples/duserrnd.csd"', + parameters: [ + { + name: 'itableNum', + description: 'number of table containing the random-distribution function. Such table is generated by the user. See [GEN40](../scoregens/gen40.md), [GEN41](../scoregens/gen41.md), and [GEN42](../scoregens/gen42.md). The table length does not need to be a power of 2', + type: 'initialization' + }, + { + name: 'ktableNum', + description: 'number of table containing the random-distribution function. Such table is generated by the user. See [GEN40](../scoregens/gen40.md), [GEN41](../scoregens/gen41.md), and [GEN42](../scoregens/gen42.md). The table length does not need to be a power of 2', + type: 'performance' + }, + ], + seeAlso: ['Random (Noise) Generators'] +}, +{ + name: 'dust', + type: 'opcode', + category: 'Signal Generators:Random (Noise) Generators', + description: 'Generates random impulses from 0 to 1.', + syntax: 'ares = dust(kamp, kdensity)\n kres = dust(kamp, kdensity)', + example: '--8<-- "examples/dust.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'kamp', + description: 'amplitude.', + type: 'performance' + }, + { + name: 'kdensity', + description: 'average number of impulses per second.', + type: 'performance' + }, + ], + seeAlso: ['Random (Noise) Generators'] +}, +{ + name: 'dust2', + type: 'opcode', + category: 'Signal Generators:Random (Noise) Generators', + description: 'Generates random impulses from -1 to 1.', + syntax: 'ares = dust2(kamp, kdensity)\n kres = dust2(kamp, kdensity)', + example: '--8<-- "examples/dust2.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'kamp', + description: 'amplitude.', + type: 'performance' + }, + { + name: 'kdensity', + description: 'average number of impulses per second.', + type: 'performance' + }, + ], + seeAlso: ['Random (Noise) Generators'] +}, +{ + name: 'exprand', + type: 'opcode', + category: 'Signal Generators:Random (Noise) Generators', + description: 'Exponential distribution random number generator (positive values only).', + syntax: 'ares = exprand(klambda)\n ires = exprand(klambda)\n kres = exprand(klambda)', + example: '--8<-- "examples/exprand.csd"', + rates: ['a-rate', 'k-rate', 'i-rate'], + parameters: [ + { + name: 'klambda', + description: 'reciprocal of lambda parameter for the exponential distribution.', + type: 'performance' + }, + ], + seeAlso: ['Random (Noise) Generators'] +}, +{ + name: 'exprandi', + type: 'opcode', + category: 'Signal Generators:Random (Noise) Generators', + description: 'Exponential distribution random number generator with interpolation (positive values only).', + syntax: 'ares = exprandi(klambda, xamp, xcps)\n ires = exprandi(klambda, xamp, xcps)\n kres = exprandi(klambda, xamp, xcps)', + example: '--8<-- "examples/exprandi.csd"', + rates: ['a-rate', 'k-rate', 'i-rate'], + parameters: [ + { + name: 'klambda', + description: 'lambda parameter for the exponential distribution.', + type: 'performance' + }, + { + name: 'xamp', + description: 'range over which random numbers are distributed.', + type: 'performance' + }, + { + name: 'xcps', + description: 'the frequency which new random numbers are generated.', + type: 'performance' + }, + ], + seeAlso: ['Random (Noise) Generators'] +}, +{ + name: 'fractalnoise', + type: 'opcode', + category: 'Signal Generators:Random (Noise) Generators', + description: 'A fractal noise generator.', + syntax: 'ares = fractalnoise(kamp, kbeta)', + example: '--8<-- "examples/fractalnoise.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'kamp', + description: 'amplitude.', + type: 'performance' + }, + { + name: 'kbeta', + description: 'spectral parameter related to the fractal dimension', + type: 'performance' + }, + ], + seeAlso: ['Random (Noise) Generators'] +}, +{ + name: 'gauss', + type: 'opcode', + category: 'Signal Generators:Random (Noise) Generators', + description: 'Gaussian distribution random number generator.', + syntax: 'ares = gauss(krange)\n ires = gauss(irange)\n kres = gauss(krange)\n ares = gauss(kmean, ksdev)\n ires = gauss(imean, isdev)\n kres = gauss(kmean, ksdev)', + example: '--8<-- "examples/gauss.csd"', + rates: ['a-rate', 'k-rate', 'i-rate'], + parameters: [ + { + name: 'krange', + description: 'the range of the random numbers (-_krange_ to +_krange_). Outputs both positive and negative numbers.', + type: 'performance' + }, + { + name: 'kmean', + description: 'normal distribution mean.', + type: 'performance' + }, + { + name: 'ksdev', + description: 'normal distribution standard deviation.', + type: 'performance' + }, + ], + seeAlso: ['Random (Noise) Generators'] +}, +{ + name: 'gaussi', + type: 'opcode', + category: 'Signal Generators:Random (Noise) Generators', + description: 'Gaussian distribution random number generator with controlled interpolation between values.', + syntax: 'ares = gaussi(krange, xamp, xcps)\n ires = gaussi(krange, xamp, xcps)\n kres = gaussi(krange, xamp, xcps)', + example: '--8<-- "examples/gaussi.csd"', + rates: ['a-rate', 'k-rate', 'i-rate'], + parameters: [ + { + name: 'krange', + description: 'the range of the random numbers (-_krange_ to +_krange_). Outputs both positive and negative numbers.', + type: 'performance' + }, + { + name: 'xamp', + description: 'range over which random numbers are distributed.', + type: 'performance' + }, + { + name: 'xcps', + description: 'the frequency which new random numbers are generated.', + type: 'performance' + }, + ], + seeAlso: ['Random (Noise) Generators'] +}, +{ + name: 'gausstrig', + type: 'opcode', + category: 'Signal Generators:Random (Noise) Generators', + description: 'Random impulses around a certain frequency.', + syntax: 'ares = gausstrig(kamp, kcps, kdev [, imode] [, ifrst1])\n kres = gausstrig(kamp, kcps, kdev [, imode] [, ifrst1])', + example: '--8<-- "examples/gausstrig.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'kamp', + description: 'amplitude.', + type: 'performance' + }, + { + name: 'kcps', + description: 'the mean frequency over which random impulses are distributed.', + type: 'performance' + }, + { + name: 'kdev', + description: 'random deviation from mean (0 <= dev < 1).', + type: 'performance' + }, + ], + seeAlso: ['Random (Noise) Generators'] +}, +{ + name: 'getseed', + type: 'opcode', + category: 'Signal Generators:Random (Noise) Generators', + description: 'Reads the global seed value.', + syntax: 'ians = getseed()\n kans = getseed()', + example: '--8<-- "examples/getseed.csd"', + seeAlso: ['Random (Noise) Generators'] +}, +{ + name: 'jitter', + type: 'opcode', + category: 'Signal Generators:Random (Noise) Generators', + description: 'Generates a segmented line whose segments are randomly generated.', + syntax: 'kout = jitter(kamp, kcpsMin, kcpsMax)', + example: '--8<-- "examples/jitter.csd"', + rates: ['k-rate'], + parameters: [ + { + name: 'kamp', + description: 'Amplitude of jitter deviation', + type: 'performance' + }, + { + name: 'kcpsMin', + description: 'Minimum speed of random frequency variations (expressed in cps)', + type: 'performance' + }, + { + name: 'kcpsMax', + description: 'Maximum speed of random frequency variations (expressed in cps)', + type: 'performance' + }, + ], + seeAlso: ['Random (Noise) Generators'] +}, +{ + name: 'jitter2', + type: 'opcode', + category: 'Signal Generators:Random (Noise) Generators', + description: 'Generates a segmented line with user-controllable random segments.', + syntax: 'kout = jitter2(ktotamp, kamp1, kcps1, kamp2, kcps2, kamp3, kcps3[ , iopt])', + example: '--8<-- "examples/jitter2.csd"', + parameters: [ + { + name: 'ktotamp', + description: 'Resulting amplitude of jitter2', + type: 'performance' + }, + { + name: 'kamp1', + description: 'Amplitude of the first jitter component', + type: 'performance' + }, + { + name: 'kcps1', + description: 'Speed of random variation of the first jitter component (expressed in cps)', + type: 'performance' + }, + { + name: 'kamp2', + description: 'Amplitude of the second jitter component', + type: 'performance' + }, + { + name: 'kcps2', + description: 'Speed of random variation of the second jitter component (expressed in cps)', + type: 'performance' + }, + { + name: 'kamp3', + description: 'Amplitude of the third jitter component', + type: 'performance' + }, + { + name: 'kcps3', + description: 'Speed of random variation of the third jitter component (expressed in cps)', + type: 'performance' + }, + ], + seeAlso: ['Random (Noise) Generators'] +}, +{ + name: 'jspline', + type: 'opcode', + category: 'Signal Generators:Random (Noise) Generators', + description: 'A jitter-spline generator.', + syntax: 'ares = jspline(xamp, kcpsMin, kcpsMax)\n kres = jspline(kamp, kcpsMin, kcpsMax)', + example: '--8<-- "examples/jspline.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'kres', + description: 'Output signal', + type: 'performance' + }, + { + name: 'ares', + description: 'Output signal', + type: 'performance' + }, + { + name: 'xamp', + description: 'Amplitude factor', + type: 'performance' + }, + { + name: 'kcpsMin', + description: 'Range of point-generation rate. Min and max limits are expressed in cps.', + type: 'performance' + }, + { + name: 'kcpsMax', + description: 'Range of point-generation rate. Min and max limits are expressed in cps.', + type: 'performance' + }, + { + name: 'cpsMin', + description: '_cpsMax_ interval is big, some little discontinuity could occurr, but it should not be a problem, in most cases. Maybe the algorithm will be improved in next versions.', + type: 'performance' + }, + ], + seeAlso: ['Linear and Exponential Generators'] +}, +{ + name: 'lfsr', + type: 'opcode', + category: 'Signal Generators:Random (Noise) Generators', + description: 'Linear Feedback Shift Register (LFSR).', + syntax: 'knum = lfsr(ilen, iprob [, iseed])', + example: '--8<-- "examples/lfsr.csd"', + parameters: [ + { + name: 'ilen', + description: 'length of shift register, valid values are 1-31 (inclusive). The larger the length, the larger the resulting integers in the output. You can use this to constrain the output to a suitable range.', + type: 'initialization' + }, + { + name: 'iprob', + description: 'probability, valid values 1-255 (inclusive). Controls the spread of the output; larger values result in a wider spread of values.', + type: 'initialization' + }, + { + name: 'knum', + description: 'integer output', + type: 'performance' + }, + ], + seeAlso: ['Random (Noise) Generators'] +}, +{ + name: 'linrand', + type: 'opcode', + category: 'Signal Generators:Random (Noise) Generators', + description: 'Linear distribution random number generator (positive values only).', + syntax: 'ares = linrand(krange)\n ires = linrand(krange)\n kres = linrand(krange)', + example: '--8<-- "examples/linrand.csd"', + rates: ['a-rate', 'k-rate', 'i-rate'], + parameters: [ + { + name: 'krange', + description: 'the range of the random numbers (0 - _krange_). Outputs only positive numbers.', + type: 'performance' + }, + ], + seeAlso: ['Random (Noise) Generators'] +}, +{ + name: 'noise', + type: 'opcode', + category: 'Signal Generators:Random (Noise) Generators', + description: 'A white noise generator with an IIR lowpass filter.', + syntax: 'ares = noise(xamp, kbeta)', + example: '--8<-- "examples/noise.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'xamp', + description: 'amplitude of final output', + type: 'performance' + }, + { + name: 'kbeta', + description: 'beta of the lowpass filter. Should be in the range of -1 to 1, exclusive of the end-points.', + type: 'performance' + }, + ], + seeAlso: ['Random (Noise) Generators'] +}, +{ + name: 'pcauchy', + type: 'opcode', + category: 'Signal Generators:Random (Noise) Generators', + description: 'Cauchy distribution random number generator (positive values only).', + syntax: 'ares = pcauchy(kalpha)\n ires = pcauchy(kalpha)\n kres = pcauchy(kalpha)', + example: '--8<-- "examples/pcauchy.csd"', + rates: ['a-rate', 'k-rate', 'i-rate'], + parameters: [ + { + name: 'pcauchy_ _kalpha', + description: 'controls the spread from zero (big kalpha = big spread). Outputs positive numbers only.', + type: 'performance' + }, + ], + seeAlso: ['Random (Noise) Generators'] +}, +{ + name: 'pinker', + type: 'opcode', + category: 'Signal Generators:Random (Noise) Generators', + description: 'Generates pink noise (-3dB/oct response) by the _NewShade of Pink_ algorithm of Stefan Stenzel.', + syntax: 'ares = pinker()', + example: '--8<-- "examples/pinker.csd"', + rates: ['a-rate'], + seeAlso: ['Random (Noise) Generators'] +}, +{ + name: 'pinkish', + type: 'opcode', + category: 'Signal Generators:Random (Noise) Generators', + description: 'Generates approximate pink noise (-3dB/oct response).', + syntax: 'ares = pinkish(xin [, imethod] [, inumbands] [, iseed] [, iskip])', + example: '--8<-- "examples/pinkish.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'xin', + description: 'for Gardner method: k- or a-rate amplitude. For Kellet filters: normally a-rate uniform random noise from rand (31-bit) or unirand, but can be any a-rate signal. The output peak value varies widely (±15%) even over long runs, and will usually be well below the input amplitude. Peak values may also occasionally overshoot input amplitude or noise.', + type: 'performance' + }, + ], + seeAlso: ['Random (Noise) Generators'] +}, +{ + name: 'poisson', + type: 'opcode', + category: 'Signal Generators:Random (Noise) Generators', + description: 'Poisson distribution random number generator (positive values only).', + syntax: 'ares = poisson(klambda)\n ires = poisson(klambda)\n kres = poisson(klambda)', + example: '--8<-- "examples/poisson.csd"', + rates: ['a-rate', 'k-rate', 'i-rate'], + parameters: [ + { + name: 'ares', + description: 'number of events occuring (always an integer).', + type: 'performance' + }, + { + name: 'kres', + description: 'number of events occuring (always an integer).', + type: 'performance' + }, + { + name: 'ires', + description: 'number of events occuring (always an integer).', + type: 'performance' + }, + { + name: 'klambda', + description: 'the expected number of occurrences that occur during the rate interval.', + type: 'performance' + }, + ], + seeAlso: ['Random (Noise) Generators'] +}, +{ + name: 'rand', + type: 'opcode', + category: 'Signal Generators:Random (Noise) Generators', + description: 'Output is a controlled random number series between -*amp* and +*amp*.', + syntax: 'ares = rand(xamp [, iseed] [, isel] [, ioffset])\n kres = rand(xamp [, iseed] [, isel] [, ioffset])', + example: '--8<-- "examples/rand.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'kamp', + description: 'range over which random numbers are distributed.', + type: 'performance' + }, + { + name: 'xamp', + description: 'range over which random numbers are distributed.', + type: 'performance' + }, + { + name: 'ares', + description: 'Random number produced.', + type: 'performance' + }, + { + name: 'kres', + description: 'Random number produced.', + type: 'performance' + }, + { + name: 'kamp_ to', + description: 'kamp_. _rand_ will thus generate uniform white noise with an R.M.S value of _kamp / root 2_.', + type: 'performance' + }, + ], + seeAlso: ['Random (Noise) Generators', 'randh', 'randi'] +}, +{ + name: 'randc', + type: 'opcode', + category: 'Signal Generators:Random (Noise) Generators', + description: 'Generates a controlled random number series with cubic interpolation between each new number.', + syntax: 'ares = randc(xamp, xcps [, iseed] [, isize] [, ioffset])\n kres = randc(kamp, kcps [, iseed] [, isize] [, ioffset])', + example: '--8<-- "examples/randc.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'kamp', + description: 'range over which random numbers are distributed.', + type: 'performance' + }, + { + name: 'xamp', + description: 'range over which random numbers are distributed.', + type: 'performance' + }, + { + name: 'kcps', + description: 'the frequency which new random numbers are generated.', + type: 'performance' + }, + { + name: 'xcps', + description: 'the frequency which new random numbers are generated.', + type: 'performance' + }, + { + name: 'kamp_ to', + description: 'kamp_. _rand_ will thus generate uniform white noise with an R.M.S value of _kamp / root 2_.', + type: 'performance' + }, + ], + seeAlso: ['Random (Noise) Generators', 'randh', 'rand'] +}, +{ + name: 'randh', + type: 'opcode', + category: 'Signal Generators:Random (Noise) Generators', + description: 'Generates random numbers and holds them for a period of time.', + syntax: 'ares = randh(xamp, xcps [, iseed] [, isize] [, ioffset])\n kres = randh(kamp, kcps [, iseed] [, isize] [, ioffset])', + example: '--8<-- "examples/randh.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'kamp', + description: 'range over which random numbers are distributed.', + type: 'performance' + }, + { + name: 'xamp', + description: 'range over which random numbers are distributed.', + type: 'performance' + }, + { + name: 'kcps', + description: 'the frequency which new random numbers are generated.', + type: 'performance' + }, + { + name: 'xcps', + description: 'the frequency which new random numbers are generated.', + type: 'performance' + }, + ], + seeAlso: ['Random (Noise) Generators', 'rand', 'randi'] +}, +{ + name: 'randi', + type: 'opcode', + category: 'Signal Generators:Random (Noise) Generators', + description: 'Generates a controlled random number series with interpolation between each new number.', + syntax: 'ares = randi(xamp, xcps [, iseed] [, isize] [, ioffset])\n kres = randi(kamp, kcps [, iseed] [, isize] [, ioffset])', + example: '--8<-- "examples/randi.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'kamp', + description: 'range over which random numbers are distributed.', + type: 'performance' + }, + { + name: 'xamp', + description: 'range over which random numbers are distributed.', + type: 'performance' + }, + { + name: 'kcps', + description: 'the frequency which new random numbers are generated.', + type: 'performance' + }, + { + name: 'xcps', + description: 'the frequency which new random numbers are generated.', + type: 'performance' + }, + { + name: 'kamp_ to', + description: 'kamp_. _rand_ will thus generate uniform white noise with an R.M.S value of _kamp / root 2_.', + type: 'performance' + }, + ], + seeAlso: ['Random (Noise) Generators', 'randh', 'rand'] +}, +{ + name: 'random', + type: 'opcode', + category: 'Signal Generators:Random (Noise) Generators', + description: 'Generates a controlled pseudo-random number series between min and max values.', + syntax: 'ares = random(kmin, kmax)\n ires = random(imin, imax)\n kres = random(kmin, kmax)', + example: '--8<-- "examples/random.csd"', + rates: ['a-rate', 'k-rate', 'i-rate'], + parameters: [ + { + name: 'imin', + description: 'minimum range limit', + type: 'initialization' + }, + { + name: 'imax', + description: 'maximum range limit', + type: 'initialization' + }, + { + name: 'kmin', + description: 'minimum range limit', + type: 'performance' + }, + { + name: 'kmax', + description: 'maximum range limit', + type: 'performance' + }, + ], + seeAlso: ['Random (Noise) Generators'] +}, +{ + name: 'randomh', + type: 'opcode', + category: 'Signal Generators:Random (Noise) Generators', + description: 'Generates random numbers with a user-defined limit and holds them for a period of time.', + syntax: 'ares = randomh(kmin, kmax, xcps [,imode] [,ifirstval])\n kres = randomh(kmin, kmax, kcps [,imode] [,ifirstval])', + example: '--8<-- "examples/randomh.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'kmin', + description: 'minimum range limit', + type: 'performance' + }, + { + name: 'kmax', + description: 'maximum range limit', + type: 'performance' + }, + { + name: 'kcps', + description: 'rate of random break-point generation', + type: 'performance' + }, + { + name: 'xcps', + description: 'rate of random break-point generation', + type: 'performance' + }, + ], + seeAlso: ['Random (Noise) Generators'] +}, +{ + name: 'randomi', + type: 'opcode', + category: 'Signal Generators:Random (Noise) Generators', + description: 'Generates a user-controlled random number series with interpolation between each new number.', + syntax: 'ares = randomi(kmin, kmax, xcps [,imode] [,ifirstval])\n kres = randomi(kmin, kmax, kcps [,imode] [,ifirstval])', + example: '--8<-- "examples/randomi.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'kmin', + description: 'minimum range limit', + type: 'performance' + }, + { + name: 'kmax', + description: 'maximum range limit', + type: 'performance' + }, + { + name: 'kcps', + description: 'rate of random break-point generation', + type: 'performance' + }, + { + name: 'xcps', + description: 'rate of random break-point generation', + type: 'performance' + }, + ], + seeAlso: ['Random (Noise) Generators'] +}, +{ + name: 'rnd31', + type: 'opcode', + category: 'Signal Generators:Random (Noise) Generators', + description: '31-bit bipolar random opcodes with controllable distribution.', + syntax: 'ax = rnd31(kscl, krpow [, iseed])\n ix = rnd31(iscl, irpow [, iseed])\n kx = rnd31(kscl, krpow [, iseed])', + example: '--8<-- "examples/rnd31.csd"', + parameters: [ + { + name: 'ix', + description: 'i-rate output value.', + type: 'initialization' + }, + { + name: 'iscl', + description: 'output scale. The generated random numbers are in the range -iscl to iscl.', + type: 'initialization' + }, + { + name: 'irpow', + description: 'controls the distribution of random numbers. If irpow is positive, the random distribution (x is in the range -1 to 1) is _abs(x) ˆ ((1 / irpow) - 1)_; for negative irpow values, it is _(1 - abs(x)) ˆ ((-1 / irpow) - 1)_. Setting _irpow_ to -1, 0, or 1 will result in uniform distribution (this is also faster to calculate).', + type: 'initialization' + }, + { + name: 'ax', + description: 'a-rate output value.', + type: 'performance' + }, + { + name: 'kx', + description: 'k-rate output value.', + type: 'performance' + }, + { + name: 'kscl', + description: 'output scale. The generated random numbers are in the range -kscl to kscl. It is the same as _iscl_, but can be varied at k-rate.', + type: 'performance' + }, + { + name: 'krpow', + description: 'controls the distribution of random numbers. It is the same as _irpow_, but can be varied at k-rate.', + type: 'performance' + }, + ], + seeAlso: ['Random (Noise) Generators'] +}, +{ + name: 'rndseed', + type: 'opcode', + category: 'Signal Generators:Random (Noise) Generators', + description: 'Sets the global seed value for [rnd](../opcodes/rnd.md) and [birnd](../opcodes/birnd.md).', + syntax: 'rndseed(ival)', + example: '--8<-- "examples/rndseed.csd"', + seeAlso: ['Random (Noise) Generators'] +}, +{ + name: 'rspline', + type: 'opcode', + category: 'Signal Generators:Random (Noise) Generators', + description: 'Generate random spline curves.', + syntax: 'ares = rspline(xrangeMin, xrangeMax, kcpsMin, kcpsMax)\n kres = rspline(krangeMin, krangeMax, kcpsMin, kcpsMax)', + example: '--8<-- "examples/rspline.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'kres', + description: 'Output signal', + type: 'performance' + }, + { + name: 'ares', + description: 'Output signal', + type: 'performance' + }, + { + name: 'xrangeMin', + description: 'Range of values of random-generated points', + type: 'performance' + }, + { + name: 'xrangeMax', + description: 'Range of values of random-generated points', + type: 'performance' + }, + { + name: 'kcpsMin', + description: 'Range of point-generation rate. Min and max limits are expressed in cps.', + type: 'performance' + }, + { + name: 'kcpsMax', + description: 'Range of point-generation rate. Min and max limits are expressed in cps.', + type: 'performance' + }, + ], + seeAlso: ['Linear and Exponential Generators'] +}, +{ + name: 'seed', + type: 'opcode', + category: 'Signal Generators:Random (Noise) Generators', + description: 'Sets the global seed value for all _x-class noise generators_, as well as other opcodes that use a random call, such as [grain](../opcodes/grain.md).', + syntax: 'seed(ival)', + example: '--8<-- "examples/seed.csd"', + seeAlso: ['Random (Noise) Generators', 'Orchestra Header Statements'] +}, +] diff --git a/src/lib/csound-reference/signal-generators-sample-playback.ts b/src/lib/csound-reference/signal-generators-sample-playback.ts new file mode 100644 index 0000000..e431fcc --- /dev/null +++ b/src/lib/csound-reference/signal-generators-sample-playback.ts @@ -0,0 +1,1133 @@ +import type { CsoundReference } from './types' + +// Signal Generators:Sample Playback +export const signalGeneratorsSamplePlayback: CsoundReference[] = [ +{ + name: 'bbcutm', + type: 'opcode', + category: 'Signal Generators:Sample Playback', + description: 'Generates breakbeat-style cut-ups of a mono audio stream.', + syntax: 'a1 = bbcutm(asource, ibps, isubdiv, ibarlength, iphrasebars, inumrepeats \\\n [, istutterspeed] [, istutterchance] [, ienvchoice ])', + example: '--8<-- "examples/bbcutm-modern.csd"', + parameters: [ + { + name: 'ibps', + description: 'Tempo to cut at, in beats per second.', + type: 'initialization' + }, + { + name: 'isubdiv', + description: 'Subdivisions unit, for a bar. So 8 is eighth notes (of a 4/4 bar).', + type: 'initialization' + }, + { + name: 'ibarlength', + description: 'How many beats per bar. Set to 4 for default 4/4 bar behaviour.', + type: 'initialization' + }, + { + name: 'iphrasebars', + description: 'The output cuts are generated in phrases, each phrase is up to iphrasebars long', + type: 'initialization' + }, + { + name: 'inumrepeats', + description: 'In normal use the algorithm would allow up to one additional repeat of a given cut at a time. This parameter allows that to be changed. Value 1 is normal- up to one extra repeat. 0 would avoid repeating, and you would always get back the original source except for enveloping and stuttering.', + type: 'initialization' + }, + { + name: 'istutterspeed', + description: '(optional, default=1) The stutter can be an integer multiple of the subdivision speed. For instance, if subdiv is 8 (quavers) and stutterspeed is 2, then the stutter is in semiquavers (sixteenth notes= subdiv 16). The default is 1.', + type: 'initialization' + }, + { + name: 'istutterchance', + description: '(optional, default=0) The tail of a phrase has this chance of becoming a single repeating one unit cell stutter (0.0 to 1.0). The default is 0.', + type: 'initialization' + }, + { + name: 'ienvchoice', + description: '(optional, default=1) choose 1 for on (exponential envelope for cut grains) or 0 for off. Off will cause clicking, but may give good noisy results, especially for percussive sources. The default is 1, on.', + type: 'initialization' + }, + { + name: 'asource', + description: 'The audio signal to be cut up. This version runs in real-time without knowledge of future audio.', + type: 'performance' + }, + ], + seeAlso: ['Sample Playback'] +}, +{ + name: 'bbcuts', + type: 'opcode', + category: 'Signal Generators:Sample Playback', + description: 'Generates breakbeat-style cut-ups of a stereo audio stream.', + syntax: 'a1,a2 = bbcuts(asource1, asource2, ibps, isubdiv, ibarlength, iphrasebars, \\\n inumrepeats [, istutterspeed] [, istutterchance] [, ienvchoice])', + example: '--8<-- "examples/bbcuts-modern.csd"', + parameters: [ + { + name: 'ibps', + description: 'Tempo to cut at, in beats per second.', + type: 'initialization' + }, + { + name: 'isubdiv', + description: 'Subdivisions unit, for a bar. So 8 is eighth notes (of a 4/4 bar).', + type: 'initialization' + }, + { + name: 'ibarlength', + description: 'How many beats per bar. Set to 4 for default 4/4 bar behaviour.', + type: 'initialization' + }, + { + name: 'iphrasebars', + description: 'The output cuts are generated in phrases, each phrase is up to iphrasebars long', + type: 'initialization' + }, + { + name: 'inumrepeats', + description: 'In normal use the algorithm would allow up to one additional repeat of a given cut at a time. This parameter allows that to be changed. Value 1 is normal- up to one extra repeat. 0 would avoid repeating, and you would always get back the original source except for enveloping and stuttering.', + type: 'initialization' + }, + { + name: 'istutterspeed', + description: '(optional, default=1) The stutter can be an integer multiple of the subdivision speed. For instance, if subdiv is 8 (quavers) and stutterspeed is 2, then the stutter is in semiquavers (sixteenth notes= subdiv 16). The default is 1.', + type: 'initialization' + }, + { + name: 'istutterchance', + description: '(optional, default=0) The tail of a phrase has this chance of becoming a single repeating one unit cell stutter (0.0 to 1.0). The default is 0.', + type: 'initialization' + }, + { + name: 'ienvchoice', + description: '(optional, default=1) choose 1 for on (exponential envelope for cut grains) or 0 for off. Off will cause clicking, but may give good noisy results, especially for percussive sources. The default is 1, on.', + type: 'initialization' + }, + { + name: 'asource', + description: 'The audio signal to be cut up. This version runs in real-time without knowledge of future audio.', + type: 'performance' + }, + ], + seeAlso: ['Sample Playback'] +}, +{ + name: 'flooper', + type: 'opcode', + category: 'Signal Generators:Sample Playback', + description: 'Function-table-based crossfading looper.', + syntax: 'asig1[, asig2] = flooper(kamp, kpitch, istart, idur, ifad, ifn)', + example: 'aout flooper 16000, 1, 1, 4, 0.05, 1 ; loop starts at 1 sec, for 4 secs, 0.05 crossfade\n out aout', + rates: ['k-rate', 'i-rate'], + parameters: [ + { + name: 'istart', + description: 'loop start pos in seconds', + type: 'initialization' + }, + { + name: 'idur', + description: 'loop duration in seconds', + type: 'initialization' + }, + { + name: 'ifad', + description: 'crossfade duration in seconds', + type: 'initialization' + }, + { + name: 'ifn', + description: 'function table number, generally created using GEN01', + type: 'initialization' + }, + { + name: 'kamp', + description: 'amplitude control', + type: 'performance' + }, + { + name: 'kpitch', + description: 'pitch control (transposition ratio); negative values play the loop back in reverse', + type: 'performance' + }, + ], + seeAlso: ['Sample Playback'] +}, +{ + name: 'flooper2', + type: 'opcode', + category: 'Signal Generators:Sample Playback', + description: 'Function-table-based crossfading looper.', + syntax: 'asig1[,asig2] = flooper2(kamp, kpitch, kloopstart, kloopend, kcrossfade, ifn \\\n [, istart, imode, ifenv, iskip])', + example: 'aout flooper2 16000, 1, 1, 5, 0.05, 1 ; loop starts at 1 sec, for 4 secs, 0.05 crossfade\n out aout', + rates: ['k-rate', 'i-rate'], + parameters: [ + { + name: 'ifn', + description: 'sound source function table number, generally created using GEN01', + type: 'initialization' + }, + { + name: 'istart', + description: 'playback start pos in seconds', + type: 'initialization' + }, + { + name: 'imode', + description: 'loop modes: 0 forward, 1 backward, 2 back-and-forth [def: 0]', + type: 'initialization' + }, + { + name: 'ifenv', + description: 'if non-zero, crossfade envelope shape table number. The default, 0, sets the crossfade to linear.', + type: 'initialization' + }, + { + name: 'iskip', + description: 'if 1, the opcode initialisation is skipped, for tied notes, performance continues from the position in the loop where the previous note stopped. The default, 0, does not skip initialisation', + type: 'initialization' + }, + { + name: 'kamp', + description: 'amplitude control', + type: 'performance' + }, + { + name: 'kpitch', + description: 'pitch control (transposition ratio); negative values are not allowed.', + type: 'performance' + }, + { + name: 'kloopstart', + description: 'loop start point (secs). Note that although k-rate, loop parameters such as this are only updated once per loop cycle.', + type: 'performance' + }, + { + name: 'kloopend', + description: 'loop end point (secs), updated once per loop cycle.', + type: 'performance' + }, + { + name: 'kcrossfade', + description: 'crossfade length (secs), updated once per loop cycle and limited to loop length.', + type: 'performance' + }, + ], + seeAlso: ['Sample Playback'] +}, +{ + name: 'loscil', + type: 'opcode', + category: 'Signal Generators:Sample Playback', + description: 'Read sampled sound (mono or stereo) from a table.', + syntax: 'ar1 [,ar2] = loscil(xamp, kcps, ifn [, ibas] [, imod1] [, ibeg1] [, iend1] \\\n [, imod2] [, ibeg2] [, iend2])\n aph, ar1 [,ar2] = loscilphs(xamp, kcps, ifn [, ibas] [, imod1] [, ibeg1] \\\n [, iend1] [, imod2] [, ibeg2] [, iend2])', + example: '--8<-- "examples/loscil.csd"', + rates: ['k-rate', 'i-rate'], + parameters: [ + { + name: 'ifn', + description: 'function table number, typically denoting an sampled sound segment with prescribed looping points loaded using [GEN01](../scoregens/gen01.md). The source file may be mono or stereo.', + type: 'initialization' + }, + { + name: 'aph', + description: 'the normalised table position corresponding to the output sample (loscilphs only).', + type: 'performance' + }, + { + name: 'ar1', + description: 'the output at audio-rate. There is just _ar1_ for mono output. However, there is both _ar1_ and _ar2_ for stereo output.', + type: 'performance' + }, + { + name: 'ar2', + description: 'the output at audio-rate. There is just _ar1_ for mono output. However, there is both _ar1_ and _ar2_ for stereo output.', + type: 'performance' + }, + { + name: 'xamp', + description: 'the amplitude of the output signal.', + type: 'performance' + }, + { + name: 'kcps', + description: 'the frequency of the output signal in cycles per second.', + type: 'performance' + }, + ], + seeAlso: ['Sample Playback'] +}, +{ + name: 'loscil3', + type: 'opcode', + category: 'Signal Generators:Sample Playback', + description: 'Read sampled sound from a table using cubic interpolation.', + syntax: 'ar1 [,ar2] = loscil3(xamp, kcps, ifn [, ibas] [, imod1] [, ibeg1] [, iend1] \\\n [, imod2] [, ibeg2] [, iend2])\n aph, ar1 [,ar2] = loscil3phs(xamp, kcps, ifn [, ibas] [, imod1] [, ibeg1] \\\n [, iend1] [, imod2] [, ibeg2] [, iend2])', + example: '--8<-- "examples/loscil3.csd"', + rates: ['k-rate', 'i-rate'], + parameters: [ + { + name: 'ifn', + description: 'function table number, typically denoting an sampled sound segment with prescribed looping points loaded using [GEN01](../scoregens/gen01.md). The source file may be mono or stereo.', + type: 'initialization' + }, + { + name: 'aph', + description: 'the normalised table position corresponding to the output sample (loscil3phs only).', + type: 'performance' + }, + { + name: 'ar1', + description: 'the output at audio-rate. There is just _ar1_ for mono output. However, there is both _ar1_ and _ar2_ for stereo output.', + type: 'performance' + }, + { + name: 'ar2', + description: 'the output at audio-rate. There is just _ar1_ for mono output. However, there is both _ar1_ and _ar2_ for stereo output.', + type: 'performance' + }, + { + name: 'xamp', + description: 'the amplitude of the output signal.', + type: 'performance' + }, + { + name: 'kcps', + description: 'the frequency of the output signal in cycles per second.', + type: 'performance' + }, + ], + seeAlso: ['Sample Playback'] +}, +{ + name: 'loscilx', + type: 'opcode', + category: 'Signal Generators:Sample Playback', + description: 'Read sampled sound (up to 16 channels) from a table, with optional sustain and release looping.', + syntax: 'ar1 [, ar2, ar3, ar4, ar5, ar6, ar7, ar8, ar9, ar10, ar11, ar12, ar13, ar14, \\\n ar15, ar16] = loscilx(xamp, kcps, ifn \\\n [, iwsize, ibas, istrt, imod, ibeg, iend])\n ar[] = loscilx(xamp, kcps, ifn \\\n [, iwsize, ibas, istrt, imod, ibeg, iend])', + example: '--8<-- "examples/loscilx.csd"', + rates: ['k-rate', 'i-rate'], + parameters: [ + { + name: 'ifn', + description: 'function table number, typically denoting an sampled sound segment with prescribed looping points loaded using [GEN01](../scoregens/gen01.md). The source file may have up to 16 channels.', + type: 'initialization' + }, + { + name: 'xamp', + description: 'the amplitude of the output signal.', + type: 'performance' + }, + { + name: 'kcps', + description: 'the factor to read the file. For example, a value of 1 has no pitch change, 1.5 is up a fifth and 2 an octave.', + type: 'performance' + }, + ], + seeAlso: ['Sample Playback'] +}, +{ + name: 'lphasor', + type: 'opcode', + category: 'Signal Generators:Sample Playback', + description: 'Generates a table index for sample playback (e.g. with [tablexkt](../opcodes/tablexkt.md)).', + syntax: 'ares = lphasor(xtrns [, ilps] [, ilpe] [, imode] [, istrt] [, istor])', + example: '--8<-- "examples/lphasor.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'ilps', + description: 'loop start.', + type: 'initialization' + }, + { + name: 'ilpe', + description: 'loop end (must be greater than _ilps_ to enable looping). The default value of _ilps_ and _ilpe_ is zero.', + type: 'initialization' + }, + { + name: 'ares', + description: 'a raw table index in samples (same unit for loop points). Can be used as index with the table opcodes.', + type: 'performance' + }, + { + name: 'xtrns', + description: 'transpose factor, expressed as a playback ratio. _ares_ is incremented by this value, and wraps around loop points. For example, 1.5 means a fifth above, 0.75 means fourth below. It is not allowed to be negative.', + type: 'performance' + }, + ], + seeAlso: ['Sample Playback'] +}, +{ + name: 'lposcil', + type: 'opcode', + category: 'Signal Generators:Sample Playback', + description: 'Read sampled sound (mono or stereo) from a table, with looping, and high precision.', + syntax: 'ares = lposcil(kamp, kfreqratio, kloop, kend, ifn [, iphs])', + example: '--8<-- "examples/lposcil.csd"', + rates: ['a-rate', 'k-rate', 'i-rate'], + parameters: [ + { + name: 'ifn', + description: 'function table number', + type: 'initialization' + }, + { + name: 'kamp', + description: 'amplitude', + type: 'performance' + }, + { + name: 'kfreqratio', + description: 'multiply factor of table frequency (for example: 1 = original frequency, 1.5 = a fifth up , .5 = an octave down)', + type: 'performance' + }, + { + name: 'kloop', + description: 'start loop point (in samples)', + type: 'performance' + }, + { + name: 'kend', + description: 'end loop point (in samples)', + type: 'performance' + }, + ], + seeAlso: ['Sample Playback'] +}, +{ + name: 'lposcil3', + type: 'opcode', + category: 'Signal Generators:Sample Playback', + description: 'Read sampled sound (mono or stereo) from a table, with looping, and high precision.', + syntax: 'ares = lposcil3(kamp, kfreqratio, kloop, kend, ifn [, iphs])', + example: '--8<-- "examples/lposcil3.csd"', + rates: ['a-rate', 'k-rate', 'i-rate'], + parameters: [ + { + name: 'ifn', + description: 'function table number', + type: 'initialization' + }, + { + name: 'kamp', + description: 'amplitude', + type: 'performance' + }, + { + name: 'kfreqratio', + description: 'multiply factor of table frequency (for example: 1 = original frequency, 1.5 = a fifth up , .5 = an octave down)', + type: 'performance' + }, + { + name: 'kloop', + description: 'start loop point (in samples)', + type: 'performance' + }, + { + name: 'kend', + description: 'end loop point (in samples)', + type: 'performance' + }, + ], + seeAlso: ['Sample Playback'] +}, +{ + name: 'lposcila', + type: 'opcode', + category: 'Signal Generators:Sample Playback', + description: 'Read sampled sound from a table with looping and high precision.', + syntax: 'ar = lposcila(aamp, kfreqratio, kloop, kend, ift [,iphs])', + example: '--8<-- "examples/lposcila.csd"', + rates: ['i-rate'], + parameters: [ + { + name: 'ift', + description: 'function table number', + type: 'initialization' + }, + { + name: 'iphs', + description: 'initial phase (in samples)', + type: 'initialization' + }, + { + name: 'ar', + description: 'output signal', + type: 'performance' + }, + { + name: 'aamp', + description: 'amplitude', + type: 'performance' + }, + { + name: 'kfreqratio', + description: 'multiply factor of table frequency (for example: 1 = original frequency, 1.5 = a fifth up , .5 = an octave down)', + type: 'performance' + }, + { + name: 'kloop', + description: 'start loop point (in samples)', + type: 'performance' + }, + { + name: 'kend', + description: 'end loop point (in samples)', + type: 'performance' + }, + ], + seeAlso: ['Sample Playback'] +}, +{ + name: 'lposcilsa', + type: 'opcode', + category: 'Signal Generators:Sample Playback', + description: 'Read stereo sampled sound from a table with looping and high precision.', + syntax: 'ar1, ar2 = lposcilsa(aamp, kfreqratio, kloop, kend, ift [,iphs])', + example: '--8<-- "examples/lposcilsa.csd"', + rates: ['i-rate'], + parameters: [ + { + name: 'ift', + description: 'function table number', + type: 'initialization' + }, + { + name: 'iphs', + description: 'initial phase (in samples)', + type: 'initialization' + }, + { + name: 'ar1', + description: 'output signal', + type: 'performance' + }, + { + name: 'ar2', + description: 'output signal', + type: 'performance' + }, + { + name: 'aamp', + description: 'amplitude', + type: 'performance' + }, + { + name: 'kfreqratio', + description: 'multiply factor of table frequency (for example: 1 = original frequency, 1.5 = a fifth up , .5 = an octave down)', + type: 'performance' + }, + { + name: 'kloop', + description: 'start loop point (in samples)', + type: 'performance' + }, + { + name: 'kend', + description: 'end loop point (in samples)', + type: 'performance' + }, + ], + seeAlso: ['Sample Playback'] +}, +{ + name: 'lposcilsa2', + type: 'opcode', + category: 'Signal Generators:Sample Playback', + description: 'Read stereo sampled sound from a table with looping and high precision.', + syntax: 'ar1, ar2 = lposcilsa2(aamp, kfreqratio, kloop, kend, ift [,iphs])', + example: '--8<-- "examples/lposcilsa2.csd"', + rates: ['i-rate'], + parameters: [ + { + name: 'ift', + description: 'function table number.', + type: 'initialization' + }, + { + name: 'iphs', + description: 'initial phase (in samples).', + type: 'initialization' + }, + { + name: 'ar1', + description: 'output signal.', + type: 'performance' + }, + { + name: 'ar2', + description: 'output signal.', + type: 'performance' + }, + { + name: 'aamp', + description: 'amplitude.', + type: 'performance' + }, + { + name: 'kfreqratio', + description: 'multiply factor of table frequency (for example: 1 = original frequency, 2 = an octave up). Only integers are allowed.', + type: 'performance' + }, + { + name: 'kloop', + description: 'start loop point (in samples).', + type: 'performance' + }, + { + name: 'kend', + description: 'end loop point (in samples).', + type: 'performance' + }, + ], + seeAlso: ['Sample Playback'] +}, +{ + name: 'sfilist', + type: 'opcode', + category: 'Signal Generators:Sample Playback', + description: 'Prints a list of all instruments of a previously loaded SoundFont2 (SF2) sample file.', + syntax: 'sfilist(ifilhandle [, Sprintprefix])', + example: '--8<-- "examples/sfilist.csd"', + parameters: [ + { + name: 'ifilhandle', + description: 'unique number generated by [sfload](../opcodes/sfload.md) opcode to be used as an identifier for a SF2 file. Several SF2 files can be loaded and activated at the same time.', + type: 'initialization' + }, + { + name: 'Sprintprefix', + description: 'A string prefix to prepend to each instrument row printed', + type: 'initialization' + }, + ], + seeAlso: ['Soundfonts', 'https://flossmanual.csound.com/midi/reading-midi-files', 'http://en.wikipedia.org/wiki/Soundfont'] +}, +{ + name: 'sfinstr', + type: 'opcode', + category: 'Signal Generators:Sample Playback', + description: 'Plays a SoundFont2 (SF2) sample instrument, generating a stereo sound.', + syntax: 'ar1, ar2 = sfinstr(ivel, inotenum, xamp, xfreq, instrnum, ifilhandle \\\n [, iflag] [, ioffset])', + example: '--8<-- "examples/sfinstr.csd"', + parameters: [ + { + name: 'ivel', + description: 'velocity value', + type: 'initialization' + }, + { + name: 'inotenum', + description: 'MIDI note number value', + type: 'initialization' + }, + { + name: 'instrnum', + description: 'number of an instrument of a SF2 file.', + type: 'initialization' + }, + { + name: 'ifilhandle', + description: 'unique number generated by _sfload_ opcode to be used as an identifier for a SF2 file. Several SF2 files can be loaded and activated at the same time.', + type: 'initialization' + }, + { + name: 'xamp', + description: 'amplitude correction factor', + type: 'performance' + }, + { + name: 'xfreq', + description: 'frequency value or frequency multiplier, depending by _iflag_. When _iflag_ = 0, _xfreq_ is a multiplier of a the default frequency, assigned by SF2 preset to the _inotenum_ value. When _iflag_ = 1, _xfreq_ is the absolute frequency of the output sound, in Hz. Default is 0.', + type: 'performance' + }, + ], + seeAlso: ['Soundfonts', 'https://flossmanual.csound.com/midi/reading-midi-files', 'http://en.wikipedia.org/wiki/Soundfont'] +}, +{ + name: 'sfinstr3', + type: 'opcode', + category: 'Signal Generators:Sample Playback', + description: 'Plays a SoundFont2 (SF2) sample instrument, generating a stereo sound with cubic interpolation.', + syntax: 'ar1, ar2 = sfinstr3(ivel, inotenum, xamp, xfreq, instrnum, ifilhandle \\\n [, iflag] [, ioffset])', + example: '--8<-- "examples/sfinstr3.csd"', + parameters: [ + { + name: 'ivel', + description: 'velocity value', + type: 'initialization' + }, + { + name: 'inotenum', + description: 'MIDI note number value', + type: 'initialization' + }, + { + name: 'instrnum', + description: 'number of an instrument of a SF2 file.', + type: 'initialization' + }, + { + name: 'ifilhandle', + description: 'unique number generated by _sfload_ opcode to be used as an identifier for a SF2 file. Several SF2 files can be loaded and activated at the same time.', + type: 'initialization' + }, + { + name: 'xamp', + description: 'amplitude correction factor', + type: 'performance' + }, + { + name: 'xfreq', + description: 'frequency value or frequency multiplier, depending by _iflag_. When _iflag_ = 0, _xfreq_ is a multiplier of a the default frequency, assigned by SF2 preset to the _inotenum_ value. When _iflag_ = 1, _xfreq_ is the absolute frequency of the output sound, in Hz. Default is 0.', + type: 'performance' + }, + ], + seeAlso: ['Soundfonts', 'https://flossmanual.csound.com/midi/reading-midi-files', 'http://en.wikipedia.org/wiki/Soundfont'] +}, +{ + name: 'sfinstr3m', + type: 'opcode', + category: 'Signal Generators:Sample Playback', + description: 'Plays a SoundFont2 (SF2) sample instrument, generating a mono sound with cubic interpolation.', + syntax: 'ares = sfinstr3m(ivel, inotenum, xamp, xfreq, instrnum, ifilhandle \\\n [, iflag] [, ioffset])', + example: '--8<-- "examples/sfinstr3m.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'ivel', + description: 'velocity value', + type: 'initialization' + }, + { + name: 'inotenum', + description: 'MIDI note number value', + type: 'initialization' + }, + { + name: 'instrnum', + description: 'number of an instrument of a SF2 file.', + type: 'initialization' + }, + { + name: 'ifilhandle', + description: 'unique number generated by _sfload_ opcode to be used as an identifier for a SF2 file. Several SF2 files can be loaded and activated at the same time.', + type: 'initialization' + }, + { + name: 'xamp', + description: 'amplitude correction factor', + type: 'performance' + }, + { + name: 'xfreq', + description: 'frequency value or frequency multiplier, depending by _iflag_. When _iflag_ = 0, _xfreq_ is a multiplier of a the default frequency, assigned by SF2 preset to the _inotenum_ value. When _iflag_ = 1, _xfreq_ is the absolute frequency of the output sound, in Hz. Default is 0.', + type: 'performance' + }, + ], + seeAlso: ['Soundfonts', 'https://flossmanual.csound.com/midi/reading-midi-files', 'http://en.wikipedia.org/wiki/Soundfont'] +}, +{ + name: 'sfinstrm', + type: 'opcode', + category: 'Signal Generators:Sample Playback', + description: 'Plays a SoundFont2 (SF2) sample instrument, generating a mono sound.', + syntax: 'ares = sfinstrm(ivel, inotenum, xamp, xfreq, instrnum, ifilhandle \\\n [, iflag] [, ioffset])', + rates: ['a-rate'], + parameters: [ + { + name: 'ivel', + description: 'velocity value', + type: 'initialization' + }, + { + name: 'inotenum', + description: 'MIDI note number value', + type: 'initialization' + }, + { + name: 'instrnum', + description: 'number of an instrument of a SF2 file.', + type: 'initialization' + }, + { + name: 'ifilhandle', + description: 'unique number generated by _sfload_ opcode to be used as an identifier for a SF2 file. Several SF2 files can be loaded and activated at the same time.', + type: 'initialization' + }, + { + name: 'xamp', + description: 'amplitude correction factor', + type: 'performance' + }, + { + name: 'xfreq', + description: 'frequency value or frequency multiplier, depending by _iflag_. When _iflag_ = 0, _xfreq_ is a multiplier of a the default frequency, assigned by SF2 preset to the _inotenum_ value. When _iflag_ = 1, _xfreq_ is the absolute frequency of the output sound, in Hz. Default is 0.', + type: 'performance' + }, + ], + seeAlso: ['Soundfonts', 'https://flossmanual.csound.com/midi/reading-midi-files', 'http://en.wikipedia.org/wiki/Soundfont'] +}, +{ + name: 'sfload', + type: 'opcode', + category: 'Signal Generators:Sample Playback', + description: 'Loads an entire SoundFont2 (SF2) sample file into memory.', + syntax: 'ir = sfload("filename")', + example: '--8<-- "examples/sfload.csd"', + parameters: [ + { + name: 'ir', + description: 'output to be used by other SF2 opcodes. For _sfload_, _ir_ is _ifilhandle_.', + type: 'initialization' + }, + ], + seeAlso: ['Soundfonts', 'https://flossmanual.csound.com/midi/reading-midi-files', 'http://en.wikipedia.org/wiki/Soundfont'] +}, +{ + name: 'sflooper', + type: 'opcode', + category: 'Signal Generators:Sample Playback', + description: 'Plays a SoundFont2 (SF2) sample preset, generating a stereo sound, with user-defined time-varying crossfade looping.', + syntax: 'ar1, ar2 = sflooper(ivel, inotenum, kamp, kpitch, ipreindex, kloopstart, \\\n kloopend, kcrossfade [, istart, imode, ifenv, iskip, iflag])', + example: '--8<-- "examples/sflooper.csd"', + rates: ['k-rate'], + parameters: [ + { + name: 'ivel', + description: 'velocity value', + type: 'initialization' + }, + { + name: 'inotenum', + description: 'MIDI note number value', + type: 'initialization' + }, + { + name: 'ipreindex', + description: 'preset index', + type: 'initialization' + }, + { + name: 'istart', + description: 'playback start pos in seconds', + type: 'initialization' + }, + { + name: 'imode', + description: 'loop modes: 0 forward, 1 backward, 2 back-and-forth [def: 0]', + type: 'initialization' + }, + { + name: 'ifenv', + description: 'if non-zero, crossfade envelope shape table number. The default, 0, sets the crossfade to linear.', + type: 'initialization' + }, + { + name: 'iskip', + description: 'if 1, the opcode initialisation is skipped, for tied notes, performance continues from the position in the loop where the previous note stopped. The default, 0, does not skip initialisation', + type: 'initialization' + }, + { + name: 'iflag', + description: 'flag regarding the behavior of _kpitch_ and _inotenum_', + type: 'initialization' + }, + { + name: 'kamp', + description: 'amplitude scaling', + type: 'performance' + }, + { + name: 'kpitch', + description: 'pitch control (transposition ratio, negative values are not allowed) or frequency multiplier, depending by iflag. When iflag = 0, kpitch is a multiplier of a the default frequency, assigned by SF2 preset to the inotenum value. When iflag = 1, kpitch is the absolute frequency of the output sound, in Hz. Default is 0. When iflag = 0, inotenum sets the frequency of the output according to the MIDI note number used, and kpitch is used as a multiplier. When iflag = 1, the frequency of the output, is set directly by kpitch. This allows the user to use any kind of micro-tuning based scales. However, this method is designed to work correctly only with presets tuned to the default equal temperament. Attempts to use this method with a preset already having non-standard tunings, or with drum-kit-based presets, could give unexpected results.', + type: 'performance' + }, + { + name: 'kloopstart', + description: 'loop start point (secs). Note that although k-rate, loop parameters such as this are only updated once per loop cycle. If loop start is set beyond the end of the sample, no looping will result.', + type: 'performance' + }, + { + name: 'kloopend', + description: 'loop end point (secs), updated once per loop cycle.', + type: 'performance' + }, + { + name: 'kcrossfade', + description: 'crossfade length (secs), updated once per loop cycle and limited to loop length.', + type: 'performance' + }, + ], + seeAlso: ['Soundfonts', 'https://flossmanual.csound.com/midi/reading-midi-files', 'http://en.wikipedia.org/wiki/Soundfont'] +}, +{ + name: 'sfpassign', + type: 'opcode', + category: 'Signal Generators:Sample Playback', + description: 'Assigns all presets of a SoundFont2 (SF2) sample file to a sequence of progressive index numbers.', + syntax: 'sfpassign(istartindex, ifilhandle[, imsgs])', + example: '--8<-- "examples/sfpassign.csd"', + parameters: [ + { + name: 'istartindex', + description: 'starting index preset by the user in bulk preset assignments.', + type: 'initialization' + }, + { + name: 'ifilhandle', + description: 'unique number generated by _sfload_ opcode to be used as an identifier for a SF2 file. Several SF2 files can be loaded and activated at the same time.', + type: 'initialization' + }, + { + name: 'imsgs', + description: 'if non-zero messages are suppressed.', + type: 'initialization' + }, + ], + seeAlso: ['Soundfonts', 'https://flossmanual.csound.com/midi/reading-midi-files', 'http://en.wikipedia.org/wiki/Soundfont'] +}, +{ + name: 'sfplay', + type: 'opcode', + category: 'Signal Generators:Sample Playback', + description: 'Plays a SoundFont2 (SF2) sample preset, generating a stereo sound.', + syntax: 'ar1, ar2 = sfplay(ivel, inotenum, xamp, xfreq, ipreindex [, iflag] \\\n [, ioffset] [, ienv])', + parameters: [ + { + name: 'ivel', + description: 'velocity value', + type: 'initialization' + }, + { + name: 'inotenum', + description: 'MIDI note number value', + type: 'initialization' + }, + { + name: 'ipreindex', + description: 'preset index', + type: 'initialization' + }, + { + name: 'xamp', + description: 'amplitude correction factor', + type: 'performance' + }, + { + name: 'xfreq', + description: 'frequency value or frequency multiplier, depending by _iflag_. When _iflag_ = 0, _xfreq_ is a multiplier of a the default frequency, assigned by SF2 preset to the _inotenum_ value. When _iflag_ = 1, _xfreq_ is the absolute frequency of the output sound, in Hz. Default is 0.', + type: 'performance' + }, + ], + seeAlso: ['Soundfonts', 'https://flossmanual.csound.com/midi/reading-midi-files', 'http://en.wikipedia.org/wiki/Soundfont'] +}, +{ + name: 'sfplay3', + type: 'opcode', + category: 'Signal Generators:Sample Playback', + description: 'Plays a SoundFont2 (SF2) sample preset, generating a stereo sound with cubic interpolation.', + syntax: 'ar1, ar2 = sfplay3(ivel, inotenum, xamp, xfreq, ipreindex [, iflag] \\\n [, ioffset] [, ienv])', + example: '--8<-- "examples/sfplay3.csd"', + parameters: [ + { + name: 'ivel', + description: 'velocity value', + type: 'initialization' + }, + { + name: 'inotenum', + description: 'MIDI note number value', + type: 'initialization' + }, + { + name: 'ipreindex', + description: 'preset index', + type: 'initialization' + }, + { + name: 'xamp', + description: 'amplitude correction factor', + type: 'performance' + }, + { + name: 'xfreq', + description: 'frequency value or frequency multiplier, depending by _iflag_. When _iflag_ = 0, _xfreq_ is a multiplier of a the default frequency, assigned by SF2 preset to the _inotenum_ value. When _iflag_ = 1, _xfreq_ is the absolute frequency of the output sound, in Hz. Default is 0.', + type: 'performance' + }, + ], + seeAlso: ['Soundfonts', 'https://flossmanual.csound.com/midi/reading-midi-files', 'http://en.wikipedia.org/wiki/Soundfont'] +}, +{ + name: 'sfplay3m', + type: 'opcode', + category: 'Signal Generators:Sample Playback', + description: 'Plays a SoundFont2 (SF2) sample preset, generating a mono sound with cubic interpolation.', + syntax: 'ares = sfplay3m(ivel, inotenum, xamp, xfreq, ipreindex [, iflag] \\\n [, ioffset] [, ienv])', + example: '--8<-- "examples/sfplay3m.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'ivel', + description: 'velocity value', + type: 'initialization' + }, + { + name: 'inotenum', + description: 'MIDI note number value', + type: 'initialization' + }, + { + name: 'ipreindex', + description: 'preset index', + type: 'initialization' + }, + { + name: 'xamp', + description: 'amplitude correction factor', + type: 'performance' + }, + { + name: 'xfreq', + description: 'frequency value or frequency multiplier, depending by _iflag_. When _iflag_ = 0, _xfreq_ is a multiplier of a the default frequency, assigned by SF2 preset to the _inotenum_ value. When _iflag_ = 1, _xfreq_ is the absolute frequency of the output sound, in Hz. Default is 0.', + type: 'performance' + }, + ], + seeAlso: ['Soundfonts', 'https://flossmanual.csound.com/midi/reading-midi-files', 'http://en.wikipedia.org/wiki/Soundfont'] +}, +{ + name: 'sfplaym', + type: 'opcode', + category: 'Signal Generators:Sample Playback', + description: 'Plays a SoundFont2 (SF2) sample preset, generating a mono sound.', + syntax: 'ares = sfplaym(ivel, inotenum, xamp, xfreq, ipreindex [, iflag] \\\n [, ioffset] [, ienv])', + example: '--8<-- "examples/sfplaym.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'ivel', + description: 'velocity value', + type: 'initialization' + }, + { + name: 'inotenum', + description: 'MIDI note number value', + type: 'initialization' + }, + { + name: 'ipreindex', + description: 'preset index', + type: 'initialization' + }, + { + name: 'xamp', + description: 'amplitude correction factor', + type: 'performance' + }, + { + name: 'xfreq', + description: 'frequency value or frequency multiplier, depending by _iflag_. When _iflag_ = 0, _xfreq_ is a multiplier of a the default frequency, assigned by SF2 preset to the _inotenum_ value. When _iflag_ = 1, _xfreq_ is the absolute frequency of the output sound, in Hz. Default is 0.', + type: 'performance' + }, + ], + seeAlso: ['Soundfonts', 'https://flossmanual.csound.com/midi/reading-midi-files', 'http://en.wikipedia.org/wiki/Soundfont'] +}, +{ + name: 'sfplist', + type: 'opcode', + category: 'Signal Generators:Sample Playback', + description: 'Prints a list of all presets of a previously loaded SoundFont2 (SF2) sample file.', + syntax: 'sfplist(ifilhandle)', + example: '--8<-- "examples/sfplist.csd"', + parameters: [ + { + name: 'ifilhandle', + description: 'unique number generated by _sfload_ opcode to be used as an identifier for a SF2 file. Several SF2 files can be loaded and activated at the same time.', + type: 'initialization' + }, + ], + seeAlso: ['Soundfonts', 'https://flossmanual.csound.com/midi/reading-midi-files', 'http://en.wikipedia.org/wiki/Soundfont'] +}, +{ + name: 'sfpreset', + type: 'opcode', + category: 'Signal Generators:Sample Playback', + description: 'Assigns an existing preset of a previously loaded SoundFont2 (SF2) sample file to an index number.', + syntax: 'ir = sfpreset(iprog, ibank, ifilhandle, ipreindex)', + example: '--8<-- "examples/sfpreset.csd"', + parameters: [ + { + name: 'ir', + description: 'output to be used by other SF2 opcodes. For _sfpreset_, _ir_ is _ipreindex_.', + type: 'initialization' + }, + { + name: 'iprog', + description: 'program number of a bank of presets in a SF2 file', + type: 'initialization' + }, + { + name: 'ibank', + description: 'number of a specific bank of a SF2 file', + type: 'initialization' + }, + { + name: 'ifilhandle', + description: 'unique number generated by _sfload_ opcode to be used as an identifier for a SF2 file. Several SF2 files can be loaded and activated at the same time.', + type: 'initialization' + }, + { + name: 'ipreindex', + description: 'preset index', + type: 'initialization' + }, + ], + seeAlso: ['Soundfonts', 'https://flossmanual.csound.com/midi/reading-midi-files', 'http://en.wikipedia.org/wiki/Soundfont'] +}, +{ + name: 'sndloop', + type: 'opcode', + category: 'Signal Generators:Sample Playback', + description: 'A sound looper with pitch control.', + syntax: 'asig, krec = sndloop(ain, kpitch, ktrig, idur, ifad)', + example: '--8<-- "examples/sndloop.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'idur', + description: 'loop duration in seconds', + type: 'initialization' + }, + { + name: 'ifad', + description: 'crossfade duration in seconds', + type: 'initialization' + }, + { + name: 'asig', + description: 'output sig', + type: 'performance' + }, + { + name: 'krec', + description: '\'rec on\' signal, 1 when recording, 0 otherwise', + type: 'performance' + }, + { + name: 'kpitch', + description: 'pitch control (transposition ratio); negative values play the loop back in reverse', + type: 'performance' + }, + { + name: 'ktrig', + description: 'trigger signal: when 0, processing is bypassed. When switched on (ktrig >= 1), the opcode starts recording until the loop memory is full. It then plays the looped sound until it is switched off again (ktrig = 0). Another recording can start again with ktrig >= 1.', + type: 'performance' + }, + ], + seeAlso: ['Sample Playback'] +}, +] diff --git a/src/lib/csound-reference/signal-generators-scanned-synthesis.ts b/src/lib/csound-reference/signal-generators-scanned-synthesis.ts new file mode 100644 index 0000000..e54bc67 --- /dev/null +++ b/src/lib/csound-reference/signal-generators-scanned-synthesis.ts @@ -0,0 +1,381 @@ +import type { CsoundReference } from './types' + +// Signal Generators:Scanned Synthesis +export const signalGeneratorsScannedSynthesis: CsoundReference[] = [ +{ + name: 'scanhammer', + type: 'opcode', + category: 'Signal Generators:Scanned Synthesis', + description: 'Copies from one table to another with a gain control.', + syntax: 'scanhammer(isrc, idst, ipos, imult)', + example: '--8<-- "examples/scanhammer.csd"', + parameters: [ + { + name: 'isrc', + description: 'source function table.', + type: 'initialization' + }, + { + name: 'idst', + description: 'destination function table.', + type: 'initialization' + }, + { + name: 'ipos', + description: 'starting position (in points).', + type: 'initialization' + }, + { + name: 'imult', + description: 'gain multiplier. A value of 0 will leave values unchanged.', + type: 'initialization' + }, + ], + seeAlso: ['Scanned Synthesis', 'Working with Scanned Synthesis', 'tutorials'] +}, +{ + name: 'scanmap', + type: 'opcode', + category: 'Signal Generators:Scanned Synthesis', + description: 'Allows the position and velocity of a node in a scanned process to be read.', + syntax: 'kpos, kvel = scanmap(iscan, kamp, kvamp [, iwhich])', + example: '--8<-- "examples/scanmap.csd"', + rates: ['k-rate'], + parameters: [ + { + name: 'iscan', + description: 'which scan process to read', + type: 'initialization' + }, + { + name: 'kamp', + description: 'amount to amplify the _kpos_ value.', + type: 'performance' + }, + { + name: 'kvamp', + description: 'amount to amplify the _kvel_ value.', + type: 'performance' + }, + ], + seeAlso: ['Scanned Synthesis', 'Working with Scanned Synthesis', 'tutorials'] +}, +{ + name: 'scans', + type: 'opcode', + category: 'Signal Generators:Scanned Synthesis', + description: 'Generate audio output using scanned synthesis.', + syntax: 'ares = scans(kamp, kfreq, ifn, id [, iorder])', + example: '--8<-- "examples/scans.csd"', + rates: ['a-rate', 'k-rate', 'i-rate'], + parameters: [ + { + name: 'ifn', + description: 'ftable containing the scanning trajectory. This is a series of numbers that contains addresses of masses. The order of these addresses is used as the scan path. It should not contain values greater than the number of masses, or negative numbers. See the [introduction to the scanned synthesis section](../siggen/scantop.md).', + type: 'initialization' + }, + { + name: 'id', + description: 'ID number of the [scanu](../opcodes/scanu.md) opcode\'s waveform to use', + type: 'initialization' + }, + { + name: 'kamp', + description: 'output amplitude. Note that the resulting amplitude is also dependent on instantaneous value in the wavetable. This number is effectively the scaling factor of the wavetable.', + type: 'performance' + }, + { + name: 'kfreq', + description: 'frequency of the scan rate', + type: 'performance' + }, + ], + seeAlso: ['Scanned Synthesis', 'Working with Scanned Synthesis', 'tutorials'] +}, +{ + name: 'scansmap', + type: 'opcode', + category: 'Signal Generators:Scanned Synthesis', + description: 'Allows the position and velocity of a node in a scanned process to be written.', + syntax: 'scansmap(kpos, kvel, iscan, kamp, kvamp [, iwhich])', + example: '--8<-- "examples/scansmap.csd"', + rates: ['k-rate'], + parameters: [ + { + name: 'iscan', + description: 'which scan process to write', + type: 'initialization' + }, + { + name: 'kpos', + description: 'the node\'s position.', + type: 'performance' + }, + { + name: 'kvel', + description: 'the node\'s velocity.', + type: 'performance' + }, + { + name: 'kamp', + description: 'amount to amplify the _kpos_ value.', + type: 'performance' + }, + { + name: 'kvamp', + description: 'amount to amplify the _kvel_ value.', + type: 'performance' + }, + ], + seeAlso: ['Scanned Synthesis', 'Working with Scanned Synthesis', 'tutorials'] +}, +{ + name: 'scantable', + type: 'opcode', + category: 'Signal Generators:Scanned Synthesis', + description: 'A simpler scanned synthesis implementation.', + syntax: 'aout = scantable(kamp, kpch, ipos, imass, istiff, idamp, ivel)', + example: '--8<-- "examples/scantable.csd"', + rates: ['k-rate'], + parameters: [ + { + name: 'ipos', + description: 'table containing position array.', + type: 'initialization' + }, + { + name: 'imass', + description: 'table containing the mass of the string.', + type: 'initialization' + }, + { + name: 'istiff', + description: 'table containing the stiffness of the string.', + type: 'initialization' + }, + { + name: 'idamp', + description: 'table containing the damping factors of the string.', + type: 'initialization' + }, + { + name: 'ivel', + description: 'table containing the velocities.', + type: 'initialization' + }, + { + name: 'kamp', + description: 'amplitude (gain) of the string.', + type: 'performance' + }, + { + name: 'kpch', + description: 'the string\'s scanned frequency.', + type: 'performance' + }, + ], + seeAlso: ['Scanned Synthesis', 'Working with Scanned Synthesis', 'tutorials'] +}, +{ + name: 'scanu', + type: 'opcode', + category: 'Signal Generators:Scanned Synthesis', + description: 'Compute the waveform and the wavetable for use in scanned synthesis.', + syntax: 'scanu(init, irate, ifndisplace, ifnmass, ifnmatrix, ifncentr, ifndamp, \\\n kmass, kmtrxstiff, kcentr, kdamp, ileft, iright, kpos, kdisplace, \\\n ain, idisp, id)', + example: '--8<-- "examples/scanu.csd"', + parameters: [ + { + name: 'init', + description: 'the initial position of the masses. If this is a negative number, then the absolute of _init_ signifies the table to use as a hammer shape. If _init_ > 0, the length of it should be the same as the intended mass number, otherwise it can be anything.', + type: 'initialization' + }, + { + name: 'irate', + description: 'the amount of time between successive updates of the mass state. Kind of like the sample period of the system. If the number is big, the string will update at a slow rate showing little timbral variability; otherwise it will change rapidly resulting in a more dynamic sound.', + type: 'initialization' + }, + { + name: 'ifndisplace', + description: 'the ftable that contains the initial velocity for each mass. It should have the same size as the intended mass number.', + type: 'initialization' + }, + { + name: 'ifnmass', + description: 'ftable that contains the mass of each mass. It should have the same size as the intended mass number.', + type: 'initialization' + }, + { + name: 'ifnmatrix', + description: 'ftable that contains the spring stiffness of each connection. It should have the same size as the square of the intended mass number. The data ordering is a row after row dump of the connection matrix of the system.', + type: 'initialization' + }, + { + name: 'ifncentr', + description: 'ftable that contains the centering force of each mass. It should have the same size as the intended mass number.', + type: 'initialization' + }, + { + name: 'ifndamp', + description: 'the ftable that contains the damping factor of each mass. It should have the same size as the intended mass number.', + type: 'initialization' + }, + { + name: 'ileft', + description: 'If _init_ < 0, the position of the left hammer (_ileft_ = 0 is hit at leftmost, _ileft_ = 1 is hit at rightmost). Ignored when _init_ > 0.', + type: 'initialization' + }, + { + name: 'iright', + description: 'If _init_ < 0, the position of the right hammer (_iright_ = 0 is hit at leftmost, _iright_ = 1 is hit at rightmost). Ignored when _init_ > 0.', + type: 'initialization' + }, + { + name: 'idisp', + description: 'If 0, no display of the masses is provided.', + type: 'initialization' + }, + { + name: 'id', + description: 'If positive, the ID of the opcode. This will be used to point the scanning opcode to the proper waveform maker. If this value is negative, the absolute of this value is the wavetable on which to write the waveshape. That wavetable can be used later from an other opcode to generate sound. The initial contents of this table will be destroyed.', + type: 'initialization' + }, + { + name: 'kmass', + description: 'scales the masses', + type: 'performance' + }, + { + name: 'kmtrxstiff', + description: 'scales the spring stiffness.', + type: 'performance' + }, + { + name: 'kcentr', + description: 'scales the centering force', + type: 'performance' + }, + { + name: 'kdamp', + description: 'scales the damping', + type: 'performance' + }, + { + name: 'kpos', + description: 'position of an active hammer along the string (_kpos_ = 0 is leftmost, _kpos_ = 1 is rightmost). The shape of the hammer is determined by _init_ and the power it pushes with is _kdisplace_.', + type: 'performance' + }, + { + name: 'kdisplace', + description: 'power that the active hammer uses.', + type: 'performance' + }, + { + name: 'ain', + description: 'audio input that adds to the velocity of the masses. Amplitude should not be too great.', + type: 'performance' + }, + ], + seeAlso: ['Scanned Synthesis', 'Working with Scanned Synthesis', 'tutorials'] +}, +{ + name: 'scanu2', + type: 'opcode', + category: 'Signal Generators:Scanned Synthesis', + description: 'Compute the waveform and the wavetable for use in scanned synthesis.', + syntax: 'scanu2(init, irate, ifndisplace,ifnmass, ifnmatrix, ifncentr, ifndamp, \\\n kmass, kmtrxstiff, kcentr, kdamp, ileft, iright, kpos, kdisplace, \\\n ain, idisp, id)', + example: '--8<-- "examples/scanu2.csd"', + parameters: [ + { + name: 'init', + description: 'the initial position of the masses. If this is a negative number, then the absolute of _init_ signifies the table to use as a hammer shape. If _init_ > 0, the length of it should be the same as the intended mass number, otherwise it can be anything. If _init_ is not an integer the initial state is white noise with the fractional part being a scaling..', + type: 'initialization' + }, + { + name: 'irate', + description: 'the amount of time between successive updates of the mass state. Kind of like the sample period of the system. If the number is big, the string will update at a slow rate showing little timbral variability; otherwise it will change rapidly resulting in a more dynamic sound.', + type: 'initialization' + }, + { + name: 'ifndisplace', + description: 'the ftable that contains the initial velocity for each mass. It should have the same size as the intended mass number.', + type: 'initialization' + }, + { + name: 'ifnmass', + description: 'ftable that contains the mass of each mass. It should have the same size as the intended mass number.', + type: 'initialization' + }, + { + name: 'ifnmatrix', + description: 'ftable that contains the spring stiffness of each connection. It should have the same size as the square of the intended mass number. The data ordering is a row after row dump of the connection matrix of the system.', + type: 'initialization' + }, + { + name: 'ifncentr', + description: 'ftable that contains the centering force of each mass. It should have the same size as the intended mass number.', + type: 'initialization' + }, + { + name: 'ifndamp', + description: 'the ftable that contains the damping factor of each mass. It should have the same size as the intended mass number.', + type: 'initialization' + }, + { + name: 'ileft', + description: 'If _init_ < 0, the position of the positive pluck in the range 0 to 1. Ignored when _init_ > 0.', + type: 'initialization' + }, + { + name: 'iright', + description: 'If _init_ < 0, the position of the negative pluck in the range 0 to 1. Ignored when _init_ > 0.', + type: 'initialization' + }, + { + name: 'idisp', + description: 'If 0, no display of the masses is provided.', + type: 'initialization' + }, + { + name: 'id', + description: 'If positive, the ID of the opcode. This will be used to point the scanning opcode to the proper waveform maker. If this value is negative, the absolute of this value is the wavetable on which to write the waveshape. That wavetable can be used later from an other opcode to generate sound. The initial contents of this table will be destroyed.', + type: 'initialization' + }, + { + name: 'kmass', + description: 'scales the masses', + type: 'performance' + }, + { + name: 'kmtrxstiff', + description: 'scales the spring stiffness. Note that larger numbers slow the evolution of the vibration, which is the reciprocal of the coresponding parameter in scanu.', + type: 'performance' + }, + { + name: 'kcentr', + description: 'scales the centering force', + type: 'performance' + }, + { + name: 'kdamp', + description: 'scales the damping', + type: 'performance' + }, + { + name: 'kpos', + description: 'position of an active hammer along the string (_kpos_ = 0 is leftmost, _kpos_ = 1 is rightmost). The shape of the hammer is determined by _init_ and the power it pushes with is _kdisplace_.', + type: 'performance' + }, + { + name: 'kdisplace', + description: 'power that the active hammer uses.', + type: 'performance' + }, + { + name: 'ain', + description: 'audio input that adds to the velocity of the masses. Amplitude should not be too great.', + type: 'performance' + }, + ], + seeAlso: ['Scanned Synthesis', 'Working with Scanned Synthesis', 'tutorials'] +}, +] diff --git a/src/lib/csound-reference/signal-generators-table-access.ts b/src/lib/csound-reference/signal-generators-table-access.ts new file mode 100644 index 0000000..7812ab3 --- /dev/null +++ b/src/lib/csound-reference/signal-generators-table-access.ts @@ -0,0 +1,69 @@ +import type { CsoundReference } from './types' + +// Signal Generators:Table Access +export const signalGeneratorsTableAccess: CsoundReference[] = [ +{ + name: 'oscil1', + type: 'opcode', + category: 'Signal Generators:Table Access', + description: 'Accesses table values by incremental sampling.', + syntax: 'kres = oscil1(idel, kamp, idur [, ifn])', + example: '--8<-- "examples/oscil1.csd"', + rates: ['k-rate', 'i-rate'], + parameters: [ + { + name: 'idel', + description: 'delay in seconds before _oscil1_ incremental sampling begins.', + type: 'initialization' + }, + { + name: 'idur', + description: 'duration in seconds to sample through the _oscil1_ table just once. A negative value will make the table be read from the end to the beginning.', + type: 'initialization' + }, + { + name: 'ifn', + description: '(optional) function table number. _tablei, oscil1i_ require the extended guard point. The number defaults to -1 which indicates a sinewave.', + type: 'initialization' + }, + { + name: 'kamp', + description: 'amplitude factor.', + type: 'performance' + }, + ], + seeAlso: ['Table Access'] +}, +{ + name: 'oscil1i', + type: 'opcode', + category: 'Signal Generators:Table Access', + description: 'Accesses table values by incremental sampling with linear interpolation.', + syntax: 'kres = oscil1i(idel, kamp, idur [, ifn])', + example: '--8<-- "examples/oscil1i.csd"', + rates: ['k-rate', 'i-rate'], + parameters: [ + { + name: 'idel', + description: 'delay in seconds before _oscil1i_ incremental sampling begins.', + type: 'initialization' + }, + { + name: 'idur', + description: 'duration in seconds to sample through the _oscil1i_ table just once. A negative value will make the table be read from the end to the beginning.', + type: 'initialization' + }, + { + name: 'ifn', + description: '(optional) function table number. _oscil1i_ requires the extended guard point. The default value is -1 indicating a sine wave.', + type: 'initialization' + }, + { + name: 'kamp', + description: 'amplitude factor', + type: 'performance' + }, + ], + seeAlso: ['Table Access'] +}, +] diff --git a/src/lib/csound-reference/signal-generators-wave-terrain-synthesis.ts b/src/lib/csound-reference/signal-generators-wave-terrain-synthesis.ts new file mode 100644 index 0000000..2d954bf --- /dev/null +++ b/src/lib/csound-reference/signal-generators-wave-terrain-synthesis.ts @@ -0,0 +1,67 @@ +import type { CsoundReference } from './types' + +// Signal Generators:Wave Terrain Synthesis +export const signalGeneratorsWaveTerrainSynthesis: CsoundReference[] = [ +{ + name: 'sterrain', + type: 'opcode', + category: 'Signal Generators:Wave Terrain Synthesis', + description: 'A wave-terrain synthesis opcode using curves computed with the superformula.', + syntax: 'aout = sterrain(kamp, kcps, kx, ky, krx, kry, krot, ktab0, ktab1, km1, km2, \\\n kn1, kn2, kn3, ka, kb, kperiod)', + example: '--8<-- "examples/sterrain.csd"', + rates: ['k-rate'], + parameters: [ + { + name: 'ktabx', + description: 'The two tables that define the terrain - they can be changed at krate.', + type: 'performance' + }, + { + name: 'ktaby', + description: 'The two tables that define the terrain - they can be changed at krate.', + type: 'performance' + }, + { + name: 'kn1', + description: '!=0 and continous.', + type: 'performance' + }, + { + name: 'ka', + description: '!=0 and continous.', + type: 'performance' + }, + { + name: 'kb', + description: '!=0 and continous.', + type: 'performance' + }, + { + name: 'kn2', + description: 'continous.', + type: 'performance' + }, + { + name: 'kn3', + description: 'continous.', + type: 'performance' + }, + { + name: 'km1', + description: 'positive integer > 0: note that the curves are not on all combinations of km1,km2 closed and have poles (closed in infinity) for example if kn1>0 and there exists an n,m in Z with 2*km1/km2 = 2m+1/n i.e curves with (3,2) (5,2) (7,2) etc and (5,4) (6,4) (7,4) (9,4) etc. have a pole which is noticeable when listening. If kn1 < 0 then the curve is reversed and the poles go towards zero in this case. If km1 and km2 are zero silence is produced (a plain circ - same effect occurs with the tuple 2,2,2,2,2,1,1).', + type: 'performance' + }, + { + name: 'km2', + description: 'positive integer > 0: note that the curves are not on all combinations of km1,km2 closed and have poles (closed in infinity) for example if kn1>0 and there exists an n,m in Z with 2*km1/km2 = 2m+1/n i.e curves with (3,2) (5,2) (7,2) etc and (5,4) (6,4) (7,4) (9,4) etc. have a pole which is noticeable when listening. If kn1 < 0 then the curve is reversed and the poles go towards zero in this case. If km1 and km2 are zero silence is produced (a plain circ - same effect occurs with the tuple 2,2,2,2,2,1,1).', + type: 'performance' + }, + { + name: 'kperiod', + description: 'some km1 and km2 ratios may cause pitch shifts. With the kperiod parameter this can be fixed. If the ratio is 1 then the kperiod value should also be set to km1 to get the incoming pitch out.', + type: 'performance' + }, + ], + seeAlso: ['Wave Terrain Synthesis'] +}, +] diff --git a/src/lib/csound-reference/signal-generators-waveguide-physical-modeling.ts b/src/lib/csound-reference/signal-generators-waveguide-physical-modeling.ts new file mode 100644 index 0000000..4002c61 --- /dev/null +++ b/src/lib/csound-reference/signal-generators-waveguide-physical-modeling.ts @@ -0,0 +1,106 @@ +import type { CsoundReference } from './types' + +// Signal Generators:Waveguide Physical Modeling +export const signalGeneratorsWaveguidePhysicalModeling: CsoundReference[] = [ +{ + name: 'pluck', + type: 'opcode', + category: 'Signal Generators:Waveguide Physical Modeling', + description: 'Produces a naturally decaying plucked string or drum sound.', + syntax: 'ares = pluck(kamp, kcps, icps, ifn, imeth [, iparm1] [, iparm2])', + example: '--8<-- "examples/pluck.csd"', + rates: ['a-rate', 'k-rate', 'i-rate'], + parameters: [ + { + name: 'icps', + description: 'intended pitch value in Hz, used to set up a buffer of 1 cycle of audio samples which will be smoothed over time by a chosen decay method. _icps_ normally anticipates the value of _kcps_, but may be set artificially high or low to influence the size of the sample buffer.', + type: 'initialization' + }, + { + name: 'ifn', + description: 'table number of a stored function used to initialize the cyclic decay buffer. If _ifn_ = 0, a random sequence will be used instead.', + type: 'initialization' + }, + { + name: 'imeth', + description: 'method of natural decay. There are six, some of which use parameters values that follow.', + type: 'initialization' + }, + { + name: 'kamp', + description: 'the output amplitude.', + type: 'performance' + }, + { + name: 'kcps', + description: 'the resampling frequency in cycles-per-second.', + type: 'performance' + }, + ], + seeAlso: ['Waveguide Physical Modeling'] +}, +{ + name: 'repluck', + type: 'opcode', + category: 'Signal Generators:Waveguide Physical Modeling', + description: 'Physical model of the plucked string.', + syntax: 'ares = repluck(iplk, kamp, icps, kpick, krefl, axcite)', + example: '--8<-- "examples/repluck.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'iplk', + description: 'The point of pluck is _iplk_, which is a fraction of the way up the string (0 to 1). A pluck point of zero means no initial pluck.', + type: 'initialization' + }, + { + name: 'icps', + description: 'The string plays at _icps_ pitch.', + type: 'initialization' + }, + { + name: 'kamp', + description: 'Amplitude of note.', + type: 'performance' + }, + { + name: 'kpick', + description: 'Proportion of the way along the string to sample the output.', + type: 'performance' + }, + { + name: 'krefl', + description: 'the coefficient of reflection, indicating the lossiness and the rate of decay. It must be strictly between 0 and 1 (it will complain about both 0 and 1).', + type: 'performance' + }, + ], + seeAlso: ['Waveguide Physical Modeling'] +}, +{ + name: 'streson', + type: 'opcode', + category: 'Signal Generators:Waveguide Physical Modeling', + description: 'A string resonator with variable fundamental frequency.', + syntax: 'ares = streson(asig, kfr, kfdbgain)', + example: '--8<-- "examples/streson.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'asig', + description: 'the input audio signal.', + type: 'performance' + }, + { + name: 'kfr', + description: 'the fundamental frequency of the string.', + type: 'performance' + }, + { + name: 'kfdbgain', + description: 'feedback gain, typically between 0 and 1, of the internal delay line. A value close to 1 creates a slower decay and a more pronounced resonance. Small values may leave the input signal unaffected. Depending on the filter frequency, typical values are > 0.9. Values down to -1 are also useful.', + type: 'performance' + }, + ], + seeAlso: ['Waveguides'] +}, +] diff --git a/src/lib/csound-reference/signal-i-o-file-i-o.ts b/src/lib/csound-reference/signal-i-o-file-i-o.ts new file mode 100644 index 0000000..97e9ba4 --- /dev/null +++ b/src/lib/csound-reference/signal-i-o-file-i-o.ts @@ -0,0 +1,603 @@ +import type { CsoundReference } from './types' + +// Signal I/O:File I/O +export const signalIOFileIO: CsoundReference[] = [ +{ + name: 'dumpk', + type: 'opcode', + category: 'Signal I/O:File I/O', + description: 'Periodically writes an orchestra control-signal value to a named external file in a specific format.', + syntax: 'dumpk(ksig, ifilname, iformat, iprd)', + example: '--8<-- "examples/dumpk.csd"', + parameters: [ + { + name: 'ifilname', + description: 'character string (in double quotes, spaces permitted) denoting the external file name. May either be a full path name with target directory specified or a simple filename to be created within the current directory', + type: 'initialization' + }, + { + name: 'iformat', + description: 'specifies the output data format:', + type: 'initialization' + }, + { + name: 'iprd', + description: 'the period of _ksig_ output in seconds, rounded to the nearest orchestra control period. A value of 0 implies one control period (the enforced minimum), which will create an output file sampled at the orchestra control rate.', + type: 'initialization' + }, + { + name: 'ksig', + description: 'a control-rate signal', + type: 'performance' + }, + ], + seeAlso: ['File Input and Output'] +}, +{ + name: 'dumpk2', + type: 'opcode', + category: 'Signal I/O:File I/O', + description: 'Periodically writes two orchestra control-signal values to a named external file in a specific format.', + syntax: 'dumpk2(ksig1, ksig2, ifilname, iformat, iprd)', + example: '--8<-- "examples/dumpk2.csd"', + parameters: [ + { + name: 'ifilname', + description: 'character string (in double quotes, spaces permitted) denoting the external file name. May either be a full path name with target directory specified or a simple filename to be created within the current directory', + type: 'initialization' + }, + { + name: 'iformat', + description: 'specifies the output data format:', + type: 'initialization' + }, + { + name: 'iprd', + description: 'the period of _ksig_ output in seconds, rounded to the nearest orchestra control period. A value of 0 implies one control period (the enforced minimum), which will create an output file sampled at the orchestra control rate.', + type: 'initialization' + }, + { + name: 'ksig1', + description: 'control-rate signals.', + type: 'performance' + }, + { + name: 'ksig2', + description: 'control-rate signals.', + type: 'performance' + }, + ], + seeAlso: ['File Input and Output'] +}, +{ + name: 'dumpk3', + type: 'opcode', + category: 'Signal I/O:File I/O', + description: 'Periodically writes three orchestra control-signal values to a named external file in a specific format.', + syntax: 'dumpk3(ksig1, ksig2, ksig3, ifilname, iformat, iprd)', + example: '--8<-- "examples/dumpk3.csd"', + parameters: [ + { + name: 'ifilname', + description: 'character string (in double quotes, spaces permitted) denoting the external file name. May either be a full path name with target directory specified or a simple filename to be created within the current directory', + type: 'initialization' + }, + { + name: 'iformat', + description: 'specifies the output data format:', + type: 'initialization' + }, + { + name: 'iprd', + description: 'the period of _ksig_ output in seconds, rounded to the nearest orchestra control period. A value of 0 implies one control period (the enforced minimum), which will create an output file sampled at the orchestra control rate.', + type: 'initialization' + }, + { + name: 'ksig1', + description: 'control-rate signals', + type: 'performance' + }, + { + name: 'ksig2', + description: 'control-rate signals', + type: 'performance' + }, + { + name: 'ksig3', + description: 'control-rate signals', + type: 'performance' + }, + ], + seeAlso: ['File Input and Output'] +}, +{ + name: 'dumpk4', + type: 'opcode', + category: 'Signal I/O:File I/O', + description: 'Periodically writes four orchestra control-signal values to a named external file in a specific format.', + syntax: 'dumpk4(ksig1, ksig2, ksig3, ksig4, ifilname, iformat, iprd)', + example: '--8<-- "examples/dumpk4.csd"', + parameters: [ + { + name: 'ifilname', + description: 'character string (in double quotes, spaces permitted) denoting the external file name. May either be a full path name with target directory specified or a simple filename to be created within the current directory', + type: 'initialization' + }, + { + name: 'iformat', + description: 'specifies the output data format:', + type: 'initialization' + }, + { + name: 'iprd', + description: 'the period of _ksig_ output in seconds, rounded to the nearest orchestra control period. A value of 0 implies one control period (the enforced minimum), which will create an output file sampled at the orchestra control rate.', + type: 'initialization' + }, + { + name: 'ksig1', + description: 'control-rate signals', + type: 'performance' + }, + { + name: 'ksig2', + description: 'control-rate signals', + type: 'performance' + }, + { + name: 'ksig3', + description: 'control-rate signals', + type: 'performance' + }, + { + name: 'ksig4', + description: 'control-rate signals', + type: 'performance' + }, + ], + seeAlso: ['File Input and Output'] +}, +{ + name: 'ficlose', + type: 'opcode', + category: 'Signal I/O:File I/O', + description: 'Closes a previously opened file.', + syntax: 'ficlose(ihandle)\n ficlose(Sfilename)', + example: '--8<-- "examples/ficlose.csd"', + parameters: [ + { + name: 'ihandle', + description: 'a number which identifies this file (generated by a previous [fiopen](../opcodes/fiopen.md)).', + type: 'initialization' + }, + { + name: 'Sfilename', + description: 'A string in double quotes or string variable with the filename. The full path must be given if the file directory is not in the system PATH and is not present in the current directory.', + type: 'initialization' + }, + ], + seeAlso: ['File Input and Output'] +}, +{ + name: 'fin', + type: 'opcode', + category: 'Signal I/O:File I/O', + description: 'Read signals from a file at a-rate.', + syntax: 'fin(ifilename, iskipframes, iformat, ain1 [, ain2] [, ain3] [,...])\n fin(ifilename, iskipframes, iformat, arr[])', + example: '--8<-- "examples/fin.csd"', + parameters: [ + { + name: 'ifilename', + description: 'input file name (can be a string or a handle number generated by [fiopen](../opcodes/fiopen.md)).', + type: 'initialization' + }, + { + name: 'iskipframes', + description: 'number of frames to skip at the start (every frame contains a sample of each channel)', + type: 'initialization' + }, + { + name: 'iformat', + description: 'a number specifying the input file format for headerless files.', + type: 'initialization' + }, + ], + seeAlso: ['File Input and Output'] +}, +{ + name: 'fini', + type: 'opcode', + category: 'Signal I/O:File I/O', + description: 'Read signals from a file at i-rate.', + syntax: 'fini(ifilename, iskipframes, iformat, in1 [, in2] [, in3] [, ...])', + example: '--8<-- "examples/fini.csd"', + parameters: [ + { + name: 'ifilename', + description: 'input file name (can be a string or a handle number generated by [fiopen](../opcodes/fiopen.md))', + type: 'initialization' + }, + { + name: 'iskipframes', + description: 'number of frames to skip at the start (every frame contains a sample of each channel)', + type: 'initialization' + }, + { + name: 'iformat', + description: 'a number specifying the input file format. If a header is found, this argument is ignored.', + type: 'initialization' + }, + ], + seeAlso: ['File Input and Output'] +}, +{ + name: 'fink', + type: 'opcode', + category: 'Signal I/O:File I/O', + description: 'Read signals from a file at k-rate.', + syntax: 'fink(ifilename, iskipframes, iformat, kin1 [, kin2] [, kin3] [,...])', + example: '--8<-- "examples/fink.csd"', + parameters: [ + { + name: 'ifilename', + description: 'input file name (can be a string or a handle number generated by [fiopen](../opcodes/fiopen.md))', + type: 'initialization' + }, + { + name: 'iskipframes', + description: 'number of frames to skip at the start (every frame contains a sample of each channel)', + type: 'initialization' + }, + { + name: 'iformat', + description: 'a number specifying the input file format. If a header is found, this argument is ignored.', + type: 'initialization' + }, + ], + seeAlso: ['File Input and Output'] +}, +{ + name: 'fiopen', + type: 'opcode', + category: 'Signal I/O:File I/O', + description: 'Opens a file in a specific mode.', + syntax: 'ihandle = fiopen(ifilename, imode)', + example: '--8<-- "examples/fiopen.csd"', + parameters: [ + { + name: 'ihandle', + description: 'a number which specifies this file.', + type: 'initialization' + }, + { + name: 'ifilename', + description: 'the target file\'s name (in double-quotes).', + type: 'initialization' + }, + { + name: 'imode', + description: 'choose the mode of opening the file. _imode_ can be a value chosen among the following:', + type: 'initialization' + }, + ], + seeAlso: ['File Input and Output'] +}, +{ + name: 'fout', + type: 'opcode', + category: 'Signal I/O:File I/O', + description: 'Outputs a-rate signals to a specified file of an arbitrary number of channels.', + syntax: 'fout(ifilename, iformat, aout1 [, aout2, aout3,...,aoutN])\n fout(ifilename, iformat, array[])', + example: '--8<-- "examples/fout.csd"', + parameters: [ + { + name: 'ifilename', + description: 'the output file\'s name (in double-quotes).', + type: 'initialization' + }, + { + name: 'iformat', + description: 'a flag to choose output file format (note: Csound versions older than 5.0 may only support formats 0, 1, and 2):', + type: 'initialization' + }, + ], + seeAlso: ['File Input and Output'] +}, +{ + name: 'fouti', + type: 'opcode', + category: 'Signal I/O:File I/O', + description: 'Outputs i-rate signals of an arbitrary number of channels to a specified file.', + syntax: 'fouti(ihandle, iformat, iflag, iout1 [, iout2, iout3,....,ioutN])', + example: '--8<-- "examples/fouti.csd"', + parameters: [ + { + name: 'ihandle', + description: 'a number which specifies this file.', + type: 'initialization' + }, + { + name: 'iformat', + description: 'a flag to choose output file format:', + type: 'initialization' + }, + { + name: 'iflag', + description: 'choose the mode of writing to the ASCII file (valid only in ASCII mode; in binary mode _iflag_ has no meaning, but it must be present anyway). _iflag_ can be a value chosen among the following:', + type: 'initialization' + }, + ], + seeAlso: ['File Input and Output'] +}, +{ + name: 'foutir', + type: 'opcode', + category: 'Signal I/O:File I/O', + description: 'Outputs i-rate signals from an arbitrary number of channels to a specified file.', + syntax: 'foutir(ihandle, iformat, iflag, iout1 [, iout2, iout3,....,ioutN])', + example: '--8<-- "examples/foutir.csd"', + parameters: [ + { + name: 'ihandle', + description: 'a number which specifies this file.', + type: 'initialization' + }, + { + name: 'iformat', + description: 'a flag to choose output file format:', + type: 'initialization' + }, + { + name: 'iflag', + description: 'choose the mode of writing to the ASCII file (valid only in ASCII mode; in binary mode _iflag_ has no meaning, but it must be present anyway). _iflag_ can be a value chosen among the following:', + type: 'initialization' + }, + ], + seeAlso: ['File Input and Output'] +}, +{ + name: 'foutk', + type: 'opcode', + category: 'Signal I/O:File I/O', + description: 'Outputs k-rate signals of an arbitrary number of channels to a specified file, in raw (headerless) format.', + syntax: 'foutk(ifilename, iformat, kout1 [, kout2, kout3,....,koutN])', + example: '--8<-- "examples/foutk.csd"', + parameters: [ + { + name: 'ifilename', + description: 'the output file\'s name (in double-quotes).', + type: 'initialization' + }, + { + name: 'iformat', + description: 'a flag to choose output file format (note: Csound versions older than 5.0 may only support formats 0 and 1):', + type: 'initialization' + }, + ], + seeAlso: ['File Input and Output'] +}, +{ + name: 'fprintks', + type: 'opcode', + category: 'Signal I/O:File I/O', + description: 'Similar to [printks](../opcodes/printks.md) but prints to a file.', + syntax: 'fprintks("filename", "string", [, kval1] [, kval2] [...])', + example: '--8<-- "examples/fprintks.csd"', + seeAlso: ['File Input and Output'] +}, +{ + name: 'fprints', + type: 'opcode', + category: 'Signal I/O:File I/O', + description: 'Similar to [prints](../opcodes/prints.md) but prints to a file.', + syntax: 'fprints("filename", "string" [, ival1] [, ival2] [...])', + example: '--8<-- "examples/fprints.csd"', + seeAlso: ['File Input and Output'] +}, +{ + name: 'readf', + type: 'opcode', + category: 'Signal I/O:File I/O', + description: 'Read a line of text from an external file once each k-cycle.', + syntax: 'Sres, kline = readf(ifilname)', + example: '--8<-- "examples/readf.csd"', + parameters: [ + { + name: 'ifilname', + description: 'an integer N denoting a file named "input.N" or a character string (in double quotes, spaces permitted) denoting the external file name. For a string, it may either be a full path name with directory specified or a simple filename. In the later case, the file is sought first in the current directory, then in SSDIR, and finally in SFDIR.', + type: 'initialization' + }, + { + name: 'Sres', + description: 'output of the line read from _ifilname_.', + type: 'performance' + }, + { + name: 'kline', + description: 'line number, or -1 when end of file has been reached.', + type: 'performance' + }, + ], + seeAlso: ['File Input and Output'] +}, +{ + name: 'readfi', + type: 'opcode', + category: 'Signal I/O:File I/O', + description: 'Read a line of text from an external file once on initialisation.', + syntax: 'Sres, iline = readfi(ifilname)', + example: '--8<-- "examples/readfi.csd"', + parameters: [ + { + name: 'ifilname', + description: 'an integer N denoting a file named "input.N" or a character string (in double quotes, spaces permitted) denoting the external file name. For a string, it may either be a full path name with directory specified or a simple filename. In the later case, the file is sought first in the current directory, then in SSDIR, and finally in SFDIR.', + type: 'initialization' + }, + { + name: 'iline', + description: 'line number, or -1 when end of file has been reached.', + type: 'initialization' + }, + { + name: 'Sres', + description: 'output of the line read from _ifilname_.', + type: 'initialization' + }, + ], + seeAlso: ['File Input and Output'] +}, +{ + name: 'readk', + type: 'opcode', + category: 'Signal I/O:File I/O', + description: 'Periodically reads an orchestra control-signal value from a named external file in a specific format.', + syntax: 'kres = readk(ifilname, iformat, iprd)', + example: '--8<-- "examples/readk.csd"', + rates: ['k-rate'], + parameters: [ + { + name: 'ifilname', + description: 'an integer N denoting a file named "readk.N" or a character string (in double quotes, spaces permitted) denoting the external file name. For a string, it may either be a full path name with directory specified or a simple filename. In the later case, the file is sought first in the current directory, then in SSDIR, and finally in SFDIR.', + type: 'initialization' + }, + { + name: 'iformat', + description: 'specifies the input data format:', + type: 'initialization' + }, + { + name: 'iprd', + description: 'the rate (period) in seconds, rounded to the nearest orchestra control period, at which the signal is read from the input file. A value of 0 implies one control period (the enforced minimum), which will read new values at the orchestra control rate. Longer periods will cause the same values to repeat for more than one control period.', + type: 'initialization' + }, + { + name: 'kres', + description: 'output of the signal read from _ifilname_.', + type: 'performance' + }, + ], + seeAlso: ['File Input and Output'] +}, +{ + name: 'readk2', + type: 'opcode', + category: 'Signal I/O:File I/O', + description: 'Periodically reads two orchestra control-signal values from an external file.', + syntax: 'kr1, kr2 = readk2(ifilname, iformat, iprd)', + example: '--8<-- "examples/readk2.csd"', + parameters: [ + { + name: 'ifilname', + description: 'an integer N denoting a file named "readk.N" or a character string (in double quotes, spaces permitted) denoting the external file name. For a string, it may either be a full path name with directory specified or a simple filename. In the later case, the file is sought first in the current directory, then in [SSDIR](../invoke/environment-variables.md), and finally in [SFDIR](../invoke/environment-variables.md).', + type: 'initialization' + }, + { + name: 'iformat', + description: 'specifies the input data format:', + type: 'initialization' + }, + { + name: 'iprd', + description: 'the rate (period) in seconds, rounded to the nearest orchestra control period, at which the signals are read from the input file. A value of 0 implies one control period (the enforced minimum), which will read new values at the orchestra control rate. Longer periods will cause the same values to repeat for more than one control period.', + type: 'initialization' + }, + { + name: 'kr1', + description: 'output of the signals read from _ifilname_.', + type: 'performance' + }, + { + name: 'kr2', + description: 'output of the signals read from _ifilname_.', + type: 'performance' + }, + ], + seeAlso: ['File Input and Output'] +}, +{ + name: 'readk3', + type: 'opcode', + category: 'Signal I/O:File I/O', + description: 'Periodically reads three orchestra control-signal values from an external file.', + syntax: 'kr1, kr2, kr3 = readk3(ifilname, iformat, iprd)', + example: '--8<-- "examples/readk3.csd"', + parameters: [ + { + name: 'ifilname', + description: 'an integer N denoting a file named "readk.N" or a character string (in double quotes, spaces permitted) denoting the external file name. For a string, it may either be a full path name with directory specified or a simple filename. In the later case, the file is sought first in the current directory, then in [SSDIR](../invoke/environment-variables.md), and finally in [SFDIR](../invoke/environment-variables.md).', + type: 'initialization' + }, + { + name: 'iformat', + description: 'specifies the input data format:', + type: 'initialization' + }, + { + name: 'iprd', + description: 'the rate (period) in seconds, rounded to the nearest orchestra control period, at which the signals are read from the input file. A value of 0 implies one control period (the enforced minimum), which will read new values at the orchestra control rate. Longer periods will cause the same values to repeat for more than one control period.', + type: 'initialization' + }, + { + name: 'kr1', + description: 'output of the signals read from _ifilname_.', + type: 'performance' + }, + { + name: 'kr2', + description: 'output of the signals read from _ifilname_.', + type: 'performance' + }, + { + name: 'kr3', + description: 'output of the signals read from _ifilname_.', + type: 'performance' + }, + ], + seeAlso: ['File Input and Output'] +}, +{ + name: 'readk4', + type: 'opcode', + category: 'Signal I/O:File I/O', + description: 'Periodically reads four orchestra control-signal values from an external file.', + syntax: 'kr1, kr2, kr3, kr4 = readk4(ifilname, iformat, iprd)', + example: '--8<-- "examples/readk4.csd"', + parameters: [ + { + name: 'ifilname', + description: 'an integer N denoting a file named "readk.N" or a character string (in double quotes, spaces permitted) denoting the external file name. For a string, it may either be a full path name with directory specified or a simple filename. In the later case, the file is sought first in the current directory, then in [SSDIR](../invoke/environment-variables.md), and finally in [SFDIR](../invoke/environment-variables.md).', + type: 'initialization' + }, + { + name: 'iformat', + description: 'specifies the input data format:', + type: 'initialization' + }, + { + name: 'iprd', + description: 'the rate (period) in seconds, rounded to the nearest orchestra control period, at which the signals are read from the input file. A value of 0 implies one control period (the enforced minimum), which will read new values at the orchestra control rate. Longer periods will cause the same values to repeat for more than one control period.', + type: 'initialization' + }, + { + name: 'kr1', + description: 'output of the signals read from _ifilname_.', + type: 'performance' + }, + { + name: 'kr2', + description: 'output of the signals read from _ifilname_.', + type: 'performance' + }, + { + name: 'kr3', + description: 'output of the signals read from _ifilname_.', + type: 'performance' + }, + { + name: 'kr4', + description: 'output of the signals read from _ifilname_.', + type: 'performance' + }, + ], + seeAlso: ['File Input and Output'] +}, +] diff --git a/src/lib/csound-reference/signal-i-o-printing-and-display.ts b/src/lib/csound-reference/signal-i-o-printing-and-display.ts new file mode 100644 index 0000000..73e0008 --- /dev/null +++ b/src/lib/csound-reference/signal-i-o-printing-and-display.ts @@ -0,0 +1,221 @@ +import type { CsoundReference } from './types' + +// Signal I/O:Printing and Display +export const signalIOPrintingAndDisplay: CsoundReference[] = [ +{ + name: 'dispfft', + type: 'opcode', + category: 'Signal I/O:Printing and Display', + description: 'Displays the Fourier Transform of an audio or control signal.', + syntax: 'dispfft(xsig, iprd, iwsiz [, iwtyp] [, idbout] [, iwtflg] [,imin] [,imax])', + example: '--8<-- "examples/dispfft.csd"', + parameters: [ + { + name: 'iprd', + description: 'the period of display in seconds.', + type: 'initialization' + }, + { + name: 'iwsiz', + description: 'size of the input window in samples. A window of _iwsiz_ points will produce a Fourier transform of _iwsiz_/2 points, spread linearly in frequency from 0 to sr/2. _iwsiz_ must be a power of 2, with a minimum of 16 and a maximum of 4096. The windows are permitted to overlap.', + type: 'initialization' + }, + { + name: 'dispfft', + description: 'displays the Fourier Transform of an audio or control signal (_asig_ or _ksig_) every _iprd_ seconds using the Fast Fourier Transform method.', + type: 'performance' + }, + ], + seeAlso: ['Printing and Display'] +}, +{ + name: 'display', + type: 'opcode', + category: 'Signal I/O:Printing and Display', + description: 'Displays the audio or control signals as an amplitude vs. time graph.', + syntax: 'display(xsig, iprd [, inprds] [, iwtflg])', + example: '--8<-- "examples/display.csd"', + parameters: [ + { + name: 'iprd', + description: 'the period of display in seconds.', + type: 'initialization' + }, + { + name: 'inprds_ is a scaling factor for the displayed waveform', + description: 'sized frames of samples are drawn in the window (the default and minimum value is 1.0). Higher _inprds_ values are slower to draw (more points to draw) but will show the waveform scrolling through the window, which is useful with low _iprd_ values.', + type: 'initialization' + }, + { + name: 'controlling how many _iprd', + description: 'sized frames of samples are drawn in the window (the default and minimum value is 1.0). Higher _inprds_ values are slower to draw (more points to draw) but will show the waveform scrolling through the window, which is useful with low _iprd_ values.', + type: 'initialization' + }, + { + name: 'display', + description: 'displays the audio or control signal _xsig_ every _iprd_ seconds, as an amplitude vs. time graph.', + type: 'performance' + }, + ], + seeAlso: ['Printing and Display'] +}, +{ + name: 'flashtxt', + type: 'opcode', + category: 'Signal I/O:Printing and Display', + description: 'Allows text to be displayed from instruments like sliders etc. (only on Unix and Windows at present)', + syntax: 'flashtxt( iwhich, String)', + example: '--8<-- "examples/flashtxt.csd"', + parameters: [ + { + name: 'iwhich', + description: 'the number of the window.', + type: 'initialization' + }, + { + name: 'String', + description: 'the string to be displayed.', + type: 'initialization' + }, + ], + seeAlso: ['Sensing and Control: TCL/TK widgets'] +}, +{ + name: 'print', + type: 'opcode', + category: 'Signal I/O:Printing and Display', + description: 'Displays the values of init (i-rate) variables.', + syntax: 'print(iarg [, iarg1] [, iarg2] [...])', + example: '--8<-- "examples/print.csd"', + parameters: [ + { + name: 'print', + description: 'print the current value of the i-time arguments (or expressions) _iarg_ at every i-pass through the instrument.', + type: 'performance' + }, + ], + seeAlso: ['Printing and Display'] +}, +{ + name: 'printf', + type: 'opcode', + category: 'Signal I/O:Printing and Display', + description: 'printf-style formatted output.', + syntax: 'printf_i(Sfmt, itrig, [iarg1[, iarg2[, ... ]]])\n printf(Sfmt, ktrig, [xarg1[, xarg2[, ... ]]])', + example: '--8<-- "examples/printf.csd"', + parameters: [ + { + name: 'Sfmt', + description: 'format string, has the same format as in printf() and other similar C functions, except length modifiers (l, ll, h, etc.) are not supported. The following conversion specifiers are allowed:', + type: 'initialization' + }, + { + name: 'itrig', + description: 'if greater than zero the opcode performs the printing; otherwise it is an null operation.', + type: 'initialization' + }, + { + name: 'ktrig', + description: 'if greater than zero and different from the value on the previous control cycle the opcode performs the requested printing. Initially this previous value is taken as zero.', + type: 'performance' + }, + ], + seeAlso: ['Printing and Display', 'http://www.cplusplus.com/reference/clibrary/cstdio/printf/'] +}, +{ + name: 'printk', + type: 'opcode', + category: 'Signal I/O:Printing and Display', + description: 'Prints one k-rate value at specified intervals.', + syntax: 'printk(itime, kval [, ispace] [, inamed])', + example: '--8<-- "examples/printk.csd"', + parameters: [ + { + name: 'itime', + description: 'time in seconds between printings.', + type: 'initialization' + }, + { + name: 'kval', + description: 'The k-rate values to be printed.', + type: 'performance' + }, + ], + seeAlso: ['Printing and Display'] +}, +{ + name: 'printk2', + type: 'opcode', + category: 'Signal I/O:Printing and Display', + description: 'Prints a new value every time a control variable changes.', + syntax: 'printk2(kvar [, inumspaces] [, inamed])', + example: '--8<-- "examples/printk2.csd"', + parameters: [ + { + name: 'kvar', + description: 'signal to be printed', + type: 'performance' + }, + ], + seeAlso: ['Printing and Display'] +}, +{ + name: 'printks', + type: 'opcode', + category: 'Signal I/O:Printing and Display', + description: 'Prints at k-rate using a printf() style syntax.', + syntax: 'printks("string", itime [, xval1] [, xval2] [...])', + example: '--8<-- "examples/printks.csd"', + parameters: [ + { + name: 'itime', + description: 'time in seconds between printings.', + type: 'initialization' + }, + ], + seeAlso: ['Printing and Display'] +}, +{ + name: 'printks2', + type: 'opcode', + category: 'Signal I/O:Printing and Display', + description: 'Prints a new value every time a control variable changes using a printf() style syntax.', + syntax: 'printks2("string", kval)', + example: '--8<-- "examples/printks2.csd"', + parameters: [ + { + name: 'kval', + description: 'signal to be printed. The style of printing is specified in _“string”_ with the standard C value specifier (%f, %d, etc.).', + type: 'performance' + }, + ], + seeAlso: ['Printing and Display'] +}, +{ + name: 'println', + type: 'opcode', + category: 'Signal I/O:Printing and Display', + description: 'Prints at k-rate using a printf() style syntax like [printks](../opcodes/printks.md), appends a new line.', + syntax: 'println("string", [, xval1] [, xval2] [...])', + example: '--8<-- "examples/println.csd"', + seeAlso: ['Printing and Display'] +}, +{ + name: 'prints', + type: 'opcode', + category: 'Signal I/O:Printing and Display', + description: 'Prints at init-time using a printf() style syntax.', + syntax: 'prints("string" [, xval1] [, xval2] [...])', + example: '--8<-- "examples/prints.csd"', + seeAlso: ['Printing and Display'] +}, +{ + name: 'printsk', + type: 'opcode', + category: 'Signal I/O:Printing and Display', + description: 'Prints at k-rate using a printf() style syntax.', + syntax: 'printsk("string", [, xval1] [, xval2] [...])', + example: '--8<-- "examples/printsk.csd"', + seeAlso: ['Printing and Display'] +}, +] diff --git a/src/lib/csound-reference/signal-i-o-signal-input.ts b/src/lib/csound-reference/signal-i-o-signal-input.ts new file mode 100644 index 0000000..8baf221 --- /dev/null +++ b/src/lib/csound-reference/signal-i-o-signal-input.ts @@ -0,0 +1,218 @@ +import type { CsoundReference } from './types' + +// Signal I/O:Signal Input +export const signalIOSignalInput: CsoundReference[] = [ +{ + name: 'diskin', + type: 'opcode', + category: 'Signal I/O:Signal Input', + description: 'Reads audio data from an external device or stream and can alter its pitch.', + syntax: 'ar1 [, ar2 [, ar3 [, ... arN]]] = diskin(ifilcod[, kpitch[, iskiptim \\\n [, iwraparound[, iformat[, iskipinit]]]]])', + example: '--8<-- "examples/diskin.csd"', + parameters: [ + { + name: 'ifilcod', + description: 'integer or character-string denoting the source soundfile name. An integer denotes the file soundin.filcod ; a character-string (in double quotes, spaces permitted) gives the filename itself, optionally a full pathname. If not a full path, the named file is sought first in the current directory, then in that given by the environment variable [SSDIR](../invoke/environment-variables.md) (if defined) then by [SFDIR](../invoke/environment-variables.md). See also [GEN01](../scoregens/gen01.md).', + type: 'initialization' + }, + { + name: 'iwraparound', + description: '1 = on, 0 = off (wraps around to end of file either direction, enabling looping)', + type: 'initialization' + }, + { + name: 'kpitch', + description: 'can be any real number. A negative number signifies backwards playback. The given number is a pitch ratio, where:', + type: 'performance' + }, + ], + seeAlso: ['Signal Input'] +}, +{ + name: 'diskin2', + type: 'opcode', + category: 'Signal I/O:Signal Input', + description: 'Reads audio data from a file, and can alter its pitch using one of several available interpolation types, as well as convert the sample rate to match the orchestra sr setting.', + syntax: 'a1[, a2[, ... aN]] = diskin2(ifilcod[, kpitch[, iskiptim \\\n [, iwrap[, iformat[, iwsize[, ibufsize[, iskipinit]]]]]]])\n ar1[] = diskin2(ifilcod[, kpitch[, iskiptim \\\n [, iwrap[, iformat[, iwsize[, ibufsize[, iskipinit]]]]]]])', + example: '--8<-- "examples/diskin2.csd"', + parameters: [ + { + name: 'ifilcod', + description: 'integer or character-string denoting the source soundfile name. An integer denotes the file soundin.ifilcod; a character-string (in double quotes, spaces permitted) gives the filename itself, optionally a full pathname. If not a full path, the named file is sought first in the current directory, then in those given by the environment variable [SSDIR](../invoke/environment-variables.md) (if defined) then by [SFDIR](../invoke/environment-variables.md). See also [GEN01](../scoregens/gen01.md). Note: files longer than 231-1 sample frames may not be played correctly on 32-bit platforms; this means a maximum length about 3 hours with a sample rate of 192000 Hz.', + type: 'initialization' + }, + { + name: 'kpitch', + description: 'transpose the pitch of input sound by this factor (e.g. 0.5 means one octave lower, 2 is one octave higher, and 1 is the original pitch, which is the default value). Fractional and negative values are allowed (the latter results in playing the file backwards, however, in this case the skip time parameter should be set to some positive value, e.g. the length of the file, or _iwrap_ should be non-zero, otherwise nothing would be played). If interpolation is enabled, and the sample rate of the file differs from the orchestra sample rate, the transpose ratio is automatically adjusted to make sure that _kpitch_=1 plays at the original pitch. Using a high _iwsize_ setting (40 or more) can significantly improve sound quality when transposing up, although at the expense of high CPU usage.', + type: 'performance' + }, + ], + seeAlso: ['Signal Input'] +}, +{ + name: 'in', + type: 'opcode', + category: 'Signal I/O:Signal Input', + description: 'Reads mono audio data from an external device or stream.', + syntax: 'ar1 = in()\n aarray = in()', + example: '--8<-- "examples/in.csd"', + seeAlso: ['Signal Input'] +}, +{ + name: 'in32', + type: 'opcode', + category: 'Signal I/O:Signal Input', + description: 'Reads a 32-channel audio signal from an external device or stream.', + syntax: 'ar1, ar2, ar3, ar4, ar5, ar6, ar7, ar8, ar9, ar10, ar11, ar12, ar13, ar14, \\\n ar15, ar16, ar17, ar18, ar19, ar20, ar21, ar22, ar23, ar24, ar25, ar26, \\\n ar27, ar28, ar29, ar30, ar31, ar32 = in32()', + seeAlso: ['Signal Input'] +}, +{ + name: 'inch', + type: 'opcode', + category: 'Signal I/O:Signal Input', + description: 'Reads from numbered channels in an external audio signal or stream.', + syntax: 'ain1[, ...] = inch(kchan1[,...])', + example: '--8<-- "examples/inch.csd"', + parameters: [ + { + name: 'inch_ can also be used to receive audio in realtime from the audio interface using', + description: 'iadc_.', + type: 'performance' + }, + ], + seeAlso: ['Signal Input'] +}, +{ + name: 'inh', + type: 'opcode', + category: 'Signal I/O:Signal Input', + description: 'Reads six-channel audio data from an external device or stream.', + syntax: 'ar1, ar2, ar3, ar4, ar5, ar6 = inh()', + seeAlso: ['Signal Input'] +}, +{ + name: 'ino', + type: 'opcode', + category: 'Signal I/O:Signal Input', + description: 'Reads eight-channel audio data from an external device or stream.', + syntax: 'ar1, ar2, ar3, ar4, ar5, ar6, ar7, ar8 = ino()', + seeAlso: ['Signal Input'] +}, +{ + name: 'inq', + type: 'opcode', + category: 'Signal I/O:Signal Input', + description: 'Reads quad audio data from an external device or stream.', + syntax: 'ar1, ar2, ar3, a4 = inq()', + example: '--8<-- "examples/inq.csd"', + seeAlso: ['Signal Input'] +}, +{ + name: 'inrg', + type: 'opcode', + category: 'Signal I/O:Signal Input', + description: 'Reads audio from a range of adjacent audio channels from the audio input device.', + syntax: 'inrg(kstart, ain1 [,ain2, ain3, ..., ainN])', + parameters: [ + { + name: 'kstart', + description: 'the number of the first channel of the input device to be accessed (channel numbers starts with 1, which is the first channel)', + type: 'performance' + }, + ], + seeAlso: ['Signal Input'] +}, +{ + name: 'ins', + type: 'opcode', + category: 'Signal I/O:Signal Input', + description: 'Reads stereo audio data from an external device or stream.', + syntax: 'ar1, ar2 = ins()', + example: '--8<-- "examples/ins.csd"', + seeAlso: ['Signal Input'] +}, +{ + name: 'invalue', + type: 'opcode', + category: 'Signal I/O:Signal Input', + description: 'Reads a k-rate or i-rate signal or string from a user-defined channel.', + syntax: 'ivalue = invalue("channel name")\n kvalue = invalue("channel name")\n Sname = invalue("channel name")', + example: '--8<-- "examples/invalue.csd"', + parameters: [ + { + name: 'ivalue', + description: 'The value that is read from the channel.', + type: 'performance' + }, + { + name: 'kvalue', + description: 'The value that is read from the channel.', + type: 'performance' + }, + { + name: 'Sname', + description: 'The string variable that is read from the channel.', + type: 'performance' + }, + ], + seeAlso: ['Signal Input'] +}, +{ + name: 'inx', + type: 'opcode', + category: 'Signal I/O:Signal Input', + description: 'Reads a 16-channel audio signal from an external device or stream.', + syntax: 'ar1, ar2, ar3, ar4, ar5, ar6, ar7, ar8, ar9, ar10, ar11, ar12, \\\n ar13, ar14, ar15, ar16 = inx()', + seeAlso: ['Signal Input'] +}, +{ + name: 'inz', + type: 'opcode', + category: 'Signal I/O:Signal Input', + description: 'Reads multi-channel audio samples into a ZAK array from an external device or stream.', + syntax: 'inz(ksig1)', + seeAlso: ['Signal Input'] +}, +{ + name: 'mp3in', + type: 'opcode', + category: 'Signal I/O:Signal Input', + description: 'Reads mono or stereo audio data from an external MP3 file.', + syntax: 'ar1, ar2 = mp3in(ifilcod[, iskptim, iformat, iskipinit, ibufsize])\n ar1 = mp3in(ifilcod[, iskptim, iformat, iskipinit, ibufsize])', + example: '--8<-- "examples/mp3in.csd"', + parameters: [ + { + name: 'ifilcod', + description: 'integer or character-string denoting the source soundfile name. An integer denotes the file soundin.filcod ; a character-string (in double quotes, spaces permitted) gives the filename itself, optionally a full pathname. If not a full path, the named file is sought first in the current directory, then in that given by the environment variable [SSDIR](../invoke/environment-variables.md) (if defined) then by [SFDIR](../invoke/environment-variables.md).', + type: 'initialization' + }, + ], + seeAlso: ['Signal Input'] +}, +{ + name: 'soundin', + type: 'opcode', + category: 'Signal I/O:Signal Input', + description: 'Reads audio data from an external device or stream.', + syntax: 'ar1[, ar2[, ar3[, ... a24]]] = soundin(ifilcod [, iskptim] [, iformat] \\\n [, iskipinit] [, ibufsize])', + example: '--8<-- "examples/soundin.csd"', + parameters: [ + { + name: 'ifilcod', + description: 'integer or character-string denoting the source soundfile name. An integer denotes the file soundin.filcod; a character-string (in double quotes, spaces permitted) gives the filename itself, optionally a full pathname. If not a full path, the named file is sought first in the current directory, then in that given by the environment variable [SSDIR](../invoke/environment-variables.md) (if defined) then by [SFDIR](../invoke/environment-variables.md). See also [GEN01](../scoregens/gen01.md).', + type: 'initialization' + }, + { + name: 'iskipinit', + description: 'switches off all initialisation if non zero (default=0). This was introduced in 4_23f13 and csound5.', + type: 'initialization' + }, + { + name: 'ibufsize', + description: 'buffer size in mono samples (not sample frames). Not available in Csound versions older than 5.00. The default buffer size is 2048.', + type: 'initialization' + }, + ], + seeAlso: ['Signal Input'] +}, +] diff --git a/src/lib/csound-reference/signal-i-o-signal-output.ts b/src/lib/csound-reference/signal-i-o-signal-output.ts new file mode 100644 index 0000000..b604209 --- /dev/null +++ b/src/lib/csound-reference/signal-i-o-signal-output.ts @@ -0,0 +1,277 @@ +import type { CsoundReference } from './types' + +// Signal I/O:Signal Output +export const signalIOSignalOutput: CsoundReference[] = [ +{ + name: 'mdelay', + type: 'opcode', + category: 'Signal I/O:Signal Output', + description: 'A MIDI delay opcode.', + syntax: 'mdelay(kstatus, kchan, kd1, kd2, kdelay)', + example: '--8<-- "examples/mdelay.csd"', + parameters: [ + { + name: 'kstatus', + description: 'status byte of MIDI message to be delayed', + type: 'performance' + }, + { + name: 'kchan', + description: 'MIDI channel (1-16)', + type: 'performance' + }, + { + name: 'kd1', + description: 'first MIDI data byte', + type: 'performance' + }, + { + name: 'kd2', + description: 'second MIDI data byte', + type: 'performance' + }, + { + name: 'kdelay', + description: 'delay time in seconds', + type: 'performance' + }, + ], + seeAlso: ['MIDI Message Output'] +}, +{ + name: 'monitor', + type: 'opcode', + category: 'Signal I/O:Signal Output', + description: 'Returns the audio spout frame (if active), otherwise it returns zero.', + syntax: 'aout1 [,aout2 ... aoutX] = monitor()\n aarra = monitor()', + example: '--8<-- "examples/monitor.csd"', + seeAlso: ['Signal Output'] +}, +{ + name: 'out', + type: 'opcode', + category: 'Signal I/O:Signal Output', + description: 'Writes audio data to an external device or stream, either from audio variables or from an audio array.', + syntax: 'out(asig1[, asig2,....])\n out(aarray)', + example: '--8<-- "examples/out.csd"', + seeAlso: ['Signal Output'] +}, +{ + name: 'out32', + type: 'opcode', + category: 'Signal I/O:Signal Output', + description: 'Writes 32-channel audio data to an external device or stream.', + syntax: 'out32(asig1, asig2, asig3, asig4, asig5, asig6, asig7, asig8, asig10, \\\n asig11, asig12, asig13, asig14, asig15, asig16, asig17, asig18, \\\n asig19, asig20, asig21, asig22, asig23, asig24, asig25, asig26, \\\n asig27, asig28, asig29, asig30, asig31, asig32)', + seeAlso: ['Signal Output'] +}, +{ + name: 'outall', + type: 'opcode', + category: 'Signal I/O:Signal Output', + description: 'Writes a single audio value to all available audio channels.', + syntax: 'outall(asig)', + example: '--8<-- "examples/outall.csd"', + rates: ['a-rate'], + seeAlso: ['Signal Output'] +}, +{ + name: 'outc', + type: 'opcode', + category: 'Signal I/O:Signal Output', + description: 'Writes audio data with an arbitrary number of channels to an external device or stream.', + syntax: 'outc(asig1 [, asig2] [...])', + example: '--8<-- "examples/outc.csd"', + seeAlso: ['Signal Output'] +}, +{ + name: 'outch', + type: 'opcode', + category: 'Signal I/O:Signal Output', + description: 'Writes multi-channel audio data, with user-controllable channels, to an external device or stream.', + syntax: 'outch(kchan1, asig1 [, kchan2] [, asig2] [...])', + example: '--8<-- "examples/outch.csd"', + seeAlso: ['Signal Output', 'http://www.csoundjournal.com/issue16/audiorouting.html'] +}, +{ + name: 'outh', + type: 'opcode', + category: 'Signal I/O:Signal Output', + description: 'Writes 6-channel audio data to an external device or stream.', + syntax: 'outh(asig1, asig2, asig3, asig4, asig5, asig6)', + seeAlso: ['Signal Output'] +}, +{ + name: 'outo', + type: 'opcode', + category: 'Signal I/O:Signal Output', + description: 'Writes 8-channel audio data to an external device or stream.', + syntax: 'outo(asig1, asig2, asig3, asig4, asig5, asig6, asig7, asig8)', + seeAlso: ['Signal Output'] +}, +{ + name: 'outq', + type: 'opcode', + category: 'Signal I/O:Signal Output', + description: 'Writes 4-channel audio data to an external device or stream.', + syntax: 'outq(asig1, asig2, asig3, asig4)', + example: '--8<-- "examples/outq.csd"', + seeAlso: ['Signal Output'] +}, +{ + name: 'outq1', + type: 'opcode', + category: 'Signal I/O:Signal Output', + description: 'Writes samples to quad channel 1 of an external device or stream.', + syntax: 'outq1(asig)', + example: '--8<-- "examples/outq1.csd"', + rates: ['a-rate'], + seeAlso: ['Signal Output'] +}, +{ + name: 'outq2', + type: 'opcode', + category: 'Signal I/O:Signal Output', + description: 'Writes samples to quad channel 2 of an external device or stream.', + syntax: 'outq2(asig)', + example: '--8<-- "examples/outq2.csd"', + rates: ['a-rate'], + seeAlso: ['Signal Output'] +}, +{ + name: 'outq3', + type: 'opcode', + category: 'Signal I/O:Signal Output', + description: 'Writes samples to quad channel 3 of an external device or stream.', + syntax: 'outq3(asig)', + example: '--8<-- "examples/outq3.csd"', + rates: ['a-rate'], + seeAlso: ['Signal Output'] +}, +{ + name: 'outq4', + type: 'opcode', + category: 'Signal I/O:Signal Output', + description: 'Writes samples to quad channel 4 of an external device or stream.', + syntax: 'outq4(asig)', + example: '--8<-- "examples/outq4.csd"', + rates: ['a-rate'], + seeAlso: ['Signal Output'] +}, +{ + name: 'outrg', + type: 'opcode', + category: 'Signal I/O:Signal Output', + description: 'Outputs audio to a range of adjacent audio channels on the audio output device.', + syntax: 'outrg(kstart, aout1 [,aout2, aout3, ..., aoutN])', + example: '--8<-- "examples/outrg.csd"', + parameters: [ + { + name: 'kstart', + description: 'the number of the first channel of the output device to be accessed (channel numbers starts with 1, which is the first channel)', + type: 'performance' + }, + ], + seeAlso: ['Signal Output'] +}, +{ + name: 'outs', + type: 'opcode', + category: 'Signal I/O:Signal Output', + description: 'Writes stereo audio data to an external device or stream.', + syntax: 'outs(asig1, asig2)', + example: '--8<-- "examples/outs.csd"', + seeAlso: ['Signal Output'] +}, +{ + name: 'outs1', + type: 'opcode', + category: 'Signal I/O:Signal Output', + description: 'Writes samples to stereo channel 1 of an external device or stream.', + syntax: 'outs1(asig)', + example: '--8<-- "examples/outs1.csd"', + rates: ['a-rate'], + seeAlso: ['Signal Output'] +}, +{ + name: 'outs2', + type: 'opcode', + category: 'Signal I/O:Signal Output', + description: 'Writes samples to stereo channel 2 of an external device or stream.', + syntax: 'outs2(asig)', + example: '--8<-- "examples/outs2.csd"', + rates: ['a-rate'], + seeAlso: ['Signal Output'] +}, +{ + name: 'outvalue', + type: 'opcode', + category: 'Signal I/O:Signal Output', + description: 'Sends an i-rate or k-rate signal or string to a user-defined channel.', + syntax: 'outvalue("channel name", ivalue)\n outvalue("channel name", kvalue)\n outvalue("channel name", "string")', + example: '--8<-- "examples/outvalue.csd"', + parameters: [ + { + name: 'ivalue', + description: 'The value that is sent to the channel.', + type: 'performance' + }, + { + name: 'kvalue', + description: 'The value that is sent to the channel.', + type: 'performance' + }, + { + name: 'string', + description: 'The string or string variable that is sent to the channel.', + type: 'performance' + }, + ], + seeAlso: ['Signal Output'] +}, +{ + name: 'outx', + type: 'opcode', + category: 'Signal I/O:Signal Output', + description: 'Writes 16-channel audio data to an external device or stream.', + syntax: 'outx(asig1, asig2, asig3, asig4, asig5, asig6, asig7, asig8, \\\n asig9, asig10, asig11, asig12, asig13, asig14, asig15, asig16)', + seeAlso: ['Signal Output'] +}, +{ + name: 'outz', + type: 'opcode', + category: 'Signal I/O:Signal Output', + description: 'Writes multi-channel audio data from a ZAK array to an external device or stream.', + syntax: 'outz(ksig1)', + seeAlso: ['Signal Output'] +}, +{ + name: 'soundout', + type: 'opcode', + category: 'Signal I/O:Signal Output', + description: 'Deprecated. Writes audio output to a disk file.', + syntax: 'soundout(asig1, ifilcod [, iformat])', + parameters: [ + { + name: 'ifilcod', + description: 'integer or character-string denoting the destination soundfile name. An integer denotes the file soundin.filcod; a character-string (in double quotes, spaces permitted) gives the filename itself, optionally a full pathname. If not a full path, the named file is sought first in the current directory, then in that given by the environment variable [SSDIR](../invoke/environment-variables.md) (if defined) then by [SFDIR](../invoke/environment-variables.md). See also [GEN01](../scoregens/gen01.md).', + type: 'initialization' + }, + ], + seeAlso: ['Signal Output'] +}, +{ + name: 'soundouts', + type: 'opcode', + category: 'Signal I/O:Signal Output', + description: 'Deprecated. Writes audio output to a disk file.', + syntax: 'soundouts(asigl, asigr, ifilcod [, iformat])', + parameters: [ + { + name: 'ifilcod', + description: 'integer or character-string denoting the destination soundfile name. An integer denotes the file soundout.ifilcod; a character-string (in double quotes, spaces permitted) gives the filename itself, optionally a full pathname. If not a full path, the named file is written relative to the directory given by the SFDIR environment variable if defined, or the current directory. See also [GEN01](../scoregens/gen01.md).', + type: 'initialization' + }, + ], + seeAlso: ['Signal Output'] +}, +] diff --git a/src/lib/csound-reference/signal-i-o-software-bus.ts b/src/lib/csound-reference/signal-i-o-software-bus.ts new file mode 100644 index 0000000..673d787 --- /dev/null +++ b/src/lib/csound-reference/signal-i-o-software-bus.ts @@ -0,0 +1,306 @@ +import type { CsoundReference } from './types' + +// Signal I/O:Software Bus +export const signalIOSoftwareBus: CsoundReference[] = [ +{ + name: 'chani', + type: 'opcode', + category: 'Signal I/O:Software Bus', + description: 'Reads data from a channel of the inward software bus.', + syntax: 'kval = chani(kchan)\n aval = chani(kchan)', + example: 'sr = 44100\nkr = 100\nksmps = 1\n\ninstr 1\n kc chani 1\n a1 oscil p4, p5, 100\n a2 lowpass2 a1, kc, 200\n out a2\nendin', + parameters: [ + { + name: 'kchan', + description: 'a positive integer that indicates which channel of the software bus to read', + type: 'performance' + }, + ], + seeAlso: ['Software Bus'] +}, +{ + name: 'chano', + type: 'opcode', + category: 'Signal I/O:Software Bus', + description: 'Send data to a channel of the outward software bus.', + syntax: 'chano(kval, kchan)\n chano(aval, kchan)', + example: 'sr = 44100\nkr = 100\nksmps = 1\n\ninstr 1\n a1 oscil p4, p5, 100\n chano 1, a1\nendin', + parameters: [ + { + name: 'xval', + description: 'value to transmit', + type: 'performance' + }, + { + name: 'kchan', + description: 'a positive integer that indicates which channel of the software bus to write', + type: 'performance' + }, + ], + seeAlso: ['Software Bus'] +}, +{ + name: 'chn', + type: 'opcode', + category: 'Signal I/O:Software Bus', + description: 'Declare a channel of the named software bus.', + syntax: 'chn_k(Sname, imode[, itype, idflt, imin, ima, ix, iy, iwidth, iheight, Sattributes])\n chn_a(Sname, imode)\n chn_S(Sname, imode)\n chn_S(Sname, Smode)\n chn_array(Sname, imode, Stype, iSizes[])', + example: 'sr = 44100\nkr = 100\nksmps = 1\n\nchn_k "cutoff", 1, 3, 1000, 500, 2000\n\ninstr 1\n kc chnget "cutoff"\n a1 oscil p4, p5, 100\n a2 lowpass2 a1, kc, 200\n out a2\nendin', + parameters: [ + { + name: 'imode', + description: 'sum of at least one of 1 for input and 2 for output.', + type: 'initialization' + }, + { + name: 'Smode', + description: 'The mode can also be set with a string: "r" for input, "w" for output or "rw" for input/output', + type: 'initialization' + }, + { + name: 'Stypes', + description: 'the array channel type ("k", "a", "S").', + type: 'initialization' + }, + { + name: 'ix', + description: 'suggested x position for controller.', + type: 'initialization' + }, + { + name: 'iy', + description: 'suggested y position for controller.', + type: 'initialization' + }, + { + name: 'iwidth', + description: 'suggested width position for controller.', + type: 'initialization' + }, + { + name: 'iheight', + description: 'suggested height position for controller.', + type: 'initialization' + }, + { + name: 'Sattributes', + description: 'attributes for controller.', + type: 'initialization' + }, + ], + seeAlso: ['Software Bus'] +}, +{ + name: 'chnclear', + type: 'opcode', + category: 'Signal I/O:Software Bus', + description: 'Clears a number of audio output channel of the named software bus.', + syntax: 'chnclear(Sname1[, Sname2,...])', + example: '--8<-- "examples/chnclear-modern.csd"', + seeAlso: ['Software Bus'] +}, +{ + name: 'chnexport', + type: 'opcode', + category: 'Signal I/O:Software Bus', + description: 'Export a global variable as a channel of the bus.', + syntax: 'gival = chnexport(Sname, imode[, itype, idflt, imin, imax])\n gkval = chnexport(Sname, imode[, itype, idflt, imin, imax])\n gaval = chnexport(Sname, imode)\n gSval = chnexport(Sname, imode)', + example: 'sr = 44100\nkr = 100\nksmps = 1\n\ngkc init 1000 ; set default value\ngkc chnexport "cutoff", 1, 3, i(gkc), 500, 2000\n\ninstr 1\n a1 oscil p4, p5, 100\n a2 lowpass2 a1, gkc, 200\n out a2\nendin', + parameters: [ + { + name: 'imode', + description: 'sum of at least one of 1 for input and 2 for output.', + type: 'initialization' + }, + ], + seeAlso: ['Software Bus'] +}, +{ + name: 'chnget', + type: 'opcode', + category: 'Signal I/O:Software Bus', + description: 'Reads data from a channel of the inward named software bus.', + syntax: 'ival = chnget(Sname)\n kval = chnget(Sname)\n aval = chnget(Sname)\n Sval = chnget(Sname)\n Sval = chngetks(Sname)\n ival[] = chngeti(Sname[])\n kval[] = chngetk(Sname[])\n aval[] = chngeta(Sname[])\n Sval[] = chngets(Sname[])', + example: 'sr = 44100\nkr = 100\nksmps = 1\n\ninstr 1\n kc chnget "cutoff"\n a1 oscil p4, p5, 100\n a2 lowpass2 a1, kc, 200\n out a2\nendin', + parameters: [ + { + name: 'Sname', + description: 'a string that identifies a channel of the named software bus to read.', + type: 'initialization' + }, + { + name: 'ival', + description: 'the control value read at i-time.', + type: 'initialization' + }, + { + name: 'Sval', + description: 'the string value read at i-time.', + type: 'initialization' + }, + { + name: 'kval', + description: 'the control value read at performance time.', + type: 'performance' + }, + { + name: 'aval', + description: 'the audio signal read at performance time.', + type: 'performance' + }, + { + name: 'Sval', + description: 'the string value read at k-rate. The chnget opcode works both at i-time and perf-time, whereas chngetks works only at perf-time. String variables are only updated if the channel has changed.', + type: 'performance' + }, + ], + seeAlso: ['Software Bus'] +}, +{ + name: 'chnmix', + type: 'opcode', + category: 'Signal I/O:Software Bus', + description: 'Writes audio data to the named software bus, mixing to the previous output.', + syntax: 'chnmix(aval, Sname)', + example: '--8<-- "examples/chnmix-modern.csd"', + parameters: [ + { + name: 'Sname', + description: 'a string that indicates which named channel of the software bus to write.', + type: 'initialization' + }, + { + name: 'aval', + description: 'the audio signal to write at performance time.', + type: 'performance' + }, + ], + seeAlso: ['Software Bus'] +}, +{ + name: 'chnparams', + type: 'opcode', + category: 'Signal I/O:Software Bus', + description: 'Query parameters of a channel (if it does not exist, all returned values are zero).', + syntax: 'itype, imode, ictltype, idflt, imin, imax = chnparams(Sname)', + parameters: [ + { + name: 'itype', + description: 'channel data type (1: control, 2: audio, 3: string)', + type: 'initialization' + }, + { + name: 'imode', + description: 'sum of 1 for input and 2 for output', + type: 'initialization' + }, + { + name: 'ictltype', + description: 'special parameter for control channel only; if not available, set to zero.', + type: 'initialization' + }, + { + name: 'idflt', + description: 'special parameter for control channel only; if not available, set to zero.', + type: 'initialization' + }, + { + name: 'imin', + description: 'special parameter for control channel only; if not available, set to zero.', + type: 'initialization' + }, + { + name: 'imax', + description: 'special parameter for control channel only; if not available, set to zero.', + type: 'initialization' + }, + { + name: 'Sname', + description: 'string identifying the channel.', + type: 'initialization' + }, + ], + seeAlso: ['Software Bus'] +}, +{ + name: 'chnset', + type: 'opcode', + category: 'Signal I/O:Software Bus', + description: 'Writes data to a channel of the named software bus.', + syntax: 'chnset(ival, Sname)\n chnset(kval, Sname)\n chnset(aval, Sname)\n chnset(Sval, Sname)\n chnsetks(Sval, Sname)\n chnseti(ival[], []Sname)\n chnsetk(kval[], []Sname)\n chnseta(aval[], []Sname)\n chnsets(Sval[], []Sname)', + example: 'sr = 44100\nkr = 100\nksmps = 1\n\ninstr 1\n a1 in\n kp,ka pitchamdf a1\n chnset kp, "pitch"\nendin', + parameters: [ + { + name: 'Sname', + description: 'a string that indicates which named channel of the software bus to write.', + type: 'initialization' + }, + { + name: 'ival', + description: 'the control value to write at i-time.', + type: 'initialization' + }, + { + name: 'Sval', + description: 'the string value to write at i-time.', + type: 'initialization' + }, + { + name: 'kval', + description: 'the control value to write at performance time.', + type: 'performance' + }, + { + name: 'aval', + description: 'the audio signal to write at performance time.', + type: 'performance' + }, + { + name: 'Sval', + description: 'the string value to write at perf-time. The opcode chnset with strings works at both i- and perf-time, whereas chnsetks works only a perf-time. Channel contents are only updated if the string variable is modified.', + type: 'performance' + }, + ], + seeAlso: ['Software Bus'] +}, +{ + name: 'oversample', + type: 'opcode', + category: 'Signal I/O:Software Bus', + description: 'Sets the local sampling rate value in a user-defined opcode block.', + syntax: 'oversample(ifactor [,icvt_in, icvt_out])', + parameters: [ + { + name: 'ifactor', + description: 'sets the oversampling factor. It needs to be a positive integer > 1. A factor of 1 is a non-op, zero or negative factors are illegal. The local sampling rate is set as ifactor * sr. The value of the sr variable is then changed locally. Local kr is also changed accordingly, local ksmps remains unchanged.', + type: 'initialization' + }, + { + name: 'icvt_in', + description: 'converter used for input: if Secret Rabbit Code is used, then 0 - best quality sync (default); 1 - medium quality sync; 2 - fast sync; 3 - zero-order hold; and 4 - linear.', + type: 'initialization' + }, + { + name: 'icvt_out', + description: 'converter used for output, defaults to the input converter, but can be different.', + type: 'initialization' + }, + ], + seeAlso: ['User Defined Opcodes (UDO)'] +}, +{ + name: 'setksmps', + type: 'opcode', + category: 'Signal I/O:Software Bus', + description: 'Sets the local ksmps value in an instrument or user-defined opcode block.', + syntax: 'setksmps(iksmps)', + parameters: [ + { + name: 'iksmps', + description: 'sets the local ksmps value.', + type: 'initialization' + }, + ], + seeAlso: ['User Defined Opcodes (UDO)'] +}, +] diff --git a/src/lib/csound-reference/signal-i-o-soundfile-queries.ts b/src/lib/csound-reference/signal-i-o-soundfile-queries.ts new file mode 100644 index 0000000..d6e1b74 --- /dev/null +++ b/src/lib/csound-reference/signal-i-o-soundfile-queries.ts @@ -0,0 +1,147 @@ +import type { CsoundReference } from './types' + +// Signal I/O:Soundfile Queries +export const signalIOSoundfileQueries: CsoundReference[] = [ +{ + name: 'filebit', + type: 'opcode', + category: 'Signal I/O:Soundfile Queries', + description: 'Returns the number of bits in each sample in a sound file.', + syntax: 'ir = filebit(ifilcod [, iallowraw])', + example: '--8<-- "examples/filebit.csd"', + parameters: [ + { + name: 'ifilcod', + description: 'sound file to be queried', + type: 'initialization' + }, + { + name: 'iallowraw', + description: '(Optional) Allow raw sound files (default=1)', + type: 'initialization' + }, + ], + seeAlso: ['Sound File Queries'] +}, +{ + name: 'filelen', + type: 'opcode', + category: 'Signal I/O:Soundfile Queries', + description: 'Returns the length of a sound file.', + syntax: 'ir = filelen(ifilcod, [iallowraw])', + example: '--8<-- "examples/filelen.csd"', + parameters: [ + { + name: 'ifilcod', + description: 'sound file to be queried', + type: 'initialization' + }, + { + name: 'iallowraw', + description: 'Allow raw sound files (default=1)', + type: 'initialization' + }, + ], + seeAlso: ['Sound File Queries'] +}, +{ + name: 'filenchnls', + type: 'opcode', + category: 'Signal I/O:Soundfile Queries', + description: 'Returns the number of channels in a sound file.', + syntax: 'ir = filenchnls(ifilcod [, iallowraw])', + example: '--8<-- "examples/filenchnls.csd"', + parameters: [ + { + name: 'ifilcod', + description: 'sound file to be queried', + type: 'initialization' + }, + { + name: 'iallowraw', + description: '(Optional) Allow raw sound files (default=1)', + type: 'initialization' + }, + ], + seeAlso: ['Sound File Queries'] +}, +{ + name: 'filepeak', + type: 'opcode', + category: 'Signal I/O:Soundfile Queries', + description: 'Returns the peak absolute value of a sound file.', + syntax: 'ir = filepeak(ifilcod [, ichnl])', + example: '--8<-- "examples/filepeak.csd"', + parameters: [ + { + name: 'ifilcod', + description: 'sound file to be queried', + type: 'initialization' + }, + ], + seeAlso: ['Sound File Queries'] +}, +{ + name: 'filesr', + type: 'opcode', + category: 'Signal I/O:Soundfile Queries', + description: 'Returns the sample rate of a sound file.', + syntax: 'ir = filesr(ifilcod [, iallowraw])', + example: '--8<-- "examples/filesr.csd"', + parameters: [ + { + name: 'ifilcod', + description: 'sound file to be queried', + type: 'initialization' + }, + { + name: 'iallowraw', + description: '(Optional) Allow raw sound files (default=1)', + type: 'initialization' + }, + ], + seeAlso: ['Sound File Queries'] +}, +{ + name: 'filevalid', + type: 'opcode', + category: 'Signal I/O:Soundfile Queries', + description: 'Checks that a file can be read at initialisation or performance time.', + syntax: 'ir = filevalid(ifilcod)\n kr = filevalid(ifilcod)', + example: '--8<-- "examples/filevalid.csd"', + parameters: [ + { + name: 'ifilcod', + description: 'sound file to be queried', + type: 'initialization' + }, + { + name: 'ir', + description: 'return code (1 if the sound file _ifilcod_ can be read).', + type: 'initialization' + }, + { + name: 'kr', + description: 'return code (1 if the sound file _ifilcod_ can be read).', + type: 'performance' + }, + ], + seeAlso: ['Sound File Queries'] +}, +{ + name: 'mp3len', + type: 'opcode', + category: 'Signal I/O:Soundfile Queries', + description: 'Returns the length of an MP3 sound file.', + syntax: 'ir = mp3len(ifilcod)', + example: '--8<-- "examples/mp3len.csd"', + parameters: [ + { + name: 'ifilcod', + description: 'sound file to be queried', + type: 'initialization' + }, + ], + seeAlso: ['Sound File Queries'] +}, +] diff --git a/src/lib/csound-reference/signal-modifiers-amplitude-modifiers.ts b/src/lib/csound-reference/signal-modifiers-amplitude-modifiers.ts new file mode 100644 index 0000000..5546638 --- /dev/null +++ b/src/lib/csound-reference/signal-modifiers-amplitude-modifiers.ts @@ -0,0 +1,207 @@ +import type { CsoundReference } from './types' + +// Signal Modifiers:Amplitude Modifiers +export const signalModifiersAmplitudeModifiers: CsoundReference[] = [ +{ + name: 'balance', + type: 'opcode', + category: 'Signal Modifiers:Amplitude Modifiers', + description: 'Adjust one audio signal according to the values of another.', + syntax: 'ares = balance(asig, acomp [, ihp] [, iskip])', + example: '--8<-- "examples/balance-modern.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'asig', + description: 'input audio signal', + type: 'performance' + }, + { + name: 'acomp', + description: 'the comparator signal', + type: 'performance' + }, + ], + seeAlso: ['Amplitude Modifiers and Dynamic processing'] +}, +{ + name: 'balance2', + type: 'opcode', + category: 'Signal Modifiers:Amplitude Modifiers', + description: 'Adjust one audio signal according to the values of another.', + syntax: 'ares = balance2(asig, acomp [, ihp] [, iskip])', + example: '--8<-- "examples/balance2-modern.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'asig', + description: 'input audio signal', + type: 'performance' + }, + { + name: 'acomp', + description: 'the comparator signal', + type: 'performance' + }, + ], + seeAlso: ['Amplitude Modifiers and Dynamic processing'] +}, +{ + name: 'clip', + type: 'opcode', + category: 'Signal Modifiers:Amplitude Modifiers', + description: 'Clips an a-rate signal to a predefined limit, in a “soft” manner, using one of three methods.', + syntax: 'ares = clip(asig, imeth, ilimit [, iarg])', + example: '--8<-- "examples/clip-modern.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'imeth', + description: 'selects the clipping method. The default is 0. The methods are:', + type: 'initialization' + }, + { + name: 'ilimit', + description: 'limiting value', + type: 'initialization' + }, + { + name: 'asig', + description: 'a-rate input signal', + type: 'performance' + }, + ], + seeAlso: ['Amplitude Modifiers and Dynamic processing', 'Waveshaping'] +}, +{ + name: 'compress', + type: 'opcode', + category: 'Signal Modifiers:Amplitude Modifiers', + description: 'Compress, limit, expand, duck or gate an audio signal.', + syntax: 'ar = compress(aasig, acsig, kthresh, kloknee, khiknee, kratio, katt, krel, ilook)', + example: '--8<-- "examples/compress-modern.csd"', + parameters: [ + { + name: 'ilook', + description: 'lookahead time in seconds, by which an internal envelope release can sense what is coming. This induces a delay between input and output, but a small amount of lookahead improves the performance of the envelope detector. Typical value is .05 seconds, sufficient to sense the peaks of the lowest frequency in _acsig_.', + type: 'initialization' + }, + { + name: 'kthresh', + description: 'sets the lowest decibel level that will be allowed through. This is a threshold of a separate noise gate, normally 0 or less, but if higher the threshold will begin removing low-level signal energy such as background noise.', + type: 'performance' + }, + { + name: 'kloknee', + description: 'decibel break-points denoting where compression or expansion will begin. These set the boundaries of a soft-knee curve joining the low-amplitude 1:1 line and the higher-amplitude compression ratio line. Typical values are 48 and 60 db. If the two breakpoints are equal, a hard-knee (angled) map will result.', + type: 'performance' + }, + { + name: 'khiknee', + description: 'decibel break-points denoting where compression or expansion will begin. These set the boundaries of a soft-knee curve joining the low-amplitude 1:1 line and the higher-amplitude compression ratio line. Typical values are 48 and 60 db. If the two breakpoints are equal, a hard-knee (angled) map will result.', + type: 'performance' + }, + { + name: 'kratio', + description: 'ratio of compression when the signal level is above the knee. The value 2 will advance the output just one decibel for every input gain of two; 3 will advance just one in three; 20 just one in twenty, etc. Inverse ratios will cause signal expansion: .5 gives two for one, .25 four for one, etc. The value 1 will result in no change.', + type: 'performance' + }, + ], + seeAlso: ['Amplitude Modifiers and Dynamic processing'] +}, +{ + name: 'compress2', + type: 'opcode', + category: 'Signal Modifiers:Amplitude Modifiers', + description: 'Compress, limit, expand, duck or gate an audio signal.', + syntax: 'ar = compress2(aasig, acsig, kthresh, kloknee, khiknee, kratio, katt, krel, ilook)', + example: '--8<-- "examples/compress2-modern.csd"', + parameters: [ + { + name: 'ilook', + description: 'lookahead time in seconds, by which an internal envelope release can sense what is coming. This induces a delay between input and output, but a small amount of lookahead improves the performance of the envelope detector. Typical value is .05 seconds, sufficient to sense the peaks of the lowest frequency in _acsig_.', + type: 'initialization' + }, + { + name: 'kthresh', + description: 'sets the lowest decibel level that will be allowed through. This is a threshold of a separate noise gate, normally set at -90 dB or less, but if higher the threshold will begin removing low-level signal energy such as background noise.', + type: 'performance' + }, + { + name: 'kloknee', + description: 'decibel break-points denoting where compression or expansion will begin. These set the boundaries of a soft-knee curve joining the low-amplitude 1:1 line and the higher-amplitude compression ratio line. Typical values are -52 and -30 dB. If the two breakpoints are equal, a hard-knee (angled) map will result.', + type: 'performance' + }, + { + name: 'khiknee', + description: 'decibel break-points denoting where compression or expansion will begin. These set the boundaries of a soft-knee curve joining the low-amplitude 1:1 line and the higher-amplitude compression ratio line. Typical values are -52 and -30 dB. If the two breakpoints are equal, a hard-knee (angled) map will result.', + type: 'performance' + }, + { + name: 'kratio', + description: 'ratio of compression when the signal level is above the knee. The value 2 will advance the output just one decibel for every input gain of two; 3 will advance just one in three; 20 just one in twenty, etc. Inverse ratios will cause signal expansion: .5 gives two for one, .25 four for one, etc. The value 1 will result in no change.', + type: 'performance' + }, + ], + seeAlso: ['Amplitude Modifiers and Dynamic processing'] +}, +{ + name: 'dam', + type: 'opcode', + category: 'Signal Modifiers:Amplitude Modifiers', + description: 'A dynamic compressor/expander.', + syntax: 'ares = dam(asig, kthreshold, icomp1, icomp2, irtime, iftime)', + example: '--8<-- "examples/dam.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'icomp1', + description: 'compression ratio for upper zone.', + type: 'initialization' + }, + { + name: 'icomp2', + description: 'compression ratio for lower zone', + type: 'initialization' + }, + { + name: 'irtime', + description: 'gain rise time in seconds. Time over which the gain factor is allowed to raise of one unit.', + type: 'initialization' + }, + { + name: 'iftime', + description: 'gain fall time in seconds. Time over which the gain factor is allowed to decrease of one unit.', + type: 'initialization' + }, + { + name: 'asig', + description: 'input signal to be modified', + type: 'performance' + }, + { + name: 'kthreshold', + description: 'level of input signal which acts as the threshold. Can be changed at k-time (e.g. for ducking)', + type: 'performance' + }, + ], + seeAlso: ['Amplitude Modifiers and Dynamic processing'] +}, +{ + name: 'gain', + type: 'opcode', + category: 'Signal Modifiers:Amplitude Modifiers', + description: 'Adjusts the amplitude audio signal according to a root-mean-square value.', + syntax: 'ares = gain(asig, krms [, ihp] [, iskip])', + example: '--8<-- "examples/gain.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'asig', + description: 'input audio signal', + type: 'performance' + }, + ], + seeAlso: ['Amplitude Modifiers and Dynamic processing'] +}, +] diff --git a/src/lib/csound-reference/signal-modifiers-comparators-and-accumulators.ts b/src/lib/csound-reference/signal-modifiers-comparators-and-accumulators.ts new file mode 100644 index 0000000..e8b4d01 --- /dev/null +++ b/src/lib/csound-reference/signal-modifiers-comparators-and-accumulators.ts @@ -0,0 +1,188 @@ +import type { CsoundReference } from './types' + +// Signal Modifiers:Comparators and Accumulators +export const signalModifiersComparatorsAndAccumulators: CsoundReference[] = [ +{ + name: 'cmp', + type: 'opcode', + category: 'Signal Modifiers:Comparators and Accumulators', + description: 'Compares audio signals or arrays.', + syntax: 'aout = cmp(a1, S_operator, a2)\n aout = cmp(a1, S_operator, kb)\n kOut[] = cmp(kA[], S_operator, kb)\n kOut[] = cmp(kA[], S_operator, kB[])\n kOut[] = cmp(k1, S_operator1, kIn[], S_operator2, k2)', + example: '--8<-- "examples/cmp.csd"', + parameters: [ + { + name: 'operator', + description: 'Math operator, one of ">", ">=", "<", "<=", "=="', + type: 'initialization' + }, + { + name: 'a1', + description: 'Input signals', + type: 'performance' + }, + { + name: 'a2', + description: 'Input signals', + type: 'performance' + }, + { + name: 'kb', + description: 'Scalar term', + type: 'performance' + }, + { + name: 'ib', + description: 'Scalar term', + type: 'performance' + }, + ], + seeAlso: ['Arithmetic and Logic Operations', 'Comparators and Accumulators', 'Array opcodes'] +}, +{ + name: 'max', + type: 'opcode', + category: 'Signal Modifiers:Comparators and Accumulators', + description: 'Produces a signal that is the maximum of any number of input signals.', + syntax: 'amax = max(ain1, ain2 [, ain3] [, ain4] [...])\n kmax = max(kin1, kin2 [, kin3] [, kin4] [...])\n imax = max(iin1, iin2 [, iin3] [, iin4] [...])', + example: '--8<-- "examples/max.csd"', + seeAlso: ['Comparators and Accumulators'] +}, +{ + name: 'max_k', + type: 'opcode', + category: 'Signal Modifiers:Comparators and Accumulators', + description: 'Local maximum (or minimum) value of an incoming asig signal, checked in the time interval between ktrig has become true twice.', + syntax: 'knumkout = max_k(asig, ktrig, itype)', + example: '--8<-- "examples/max_k.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'itype', + description: 'itype determinates the behaviour of max_k (see below)', + type: 'initialization' + }, + { + name: 'asig', + description: 'incoming (input) signal', + type: 'performance' + }, + { + name: 'ktrig', + description: 'trigger signal', + type: 'performance' + }, + ], + seeAlso: ['Comparators and Accumulators'] +}, +{ + name: 'maxabs', + type: 'opcode', + category: 'Signal Modifiers:Comparators and Accumulators', + description: 'Produces a signal that is the maximum of the absolute values of any number of input signals.', + syntax: 'amax = maxabs(ain1, ain2 [, ain3] [, ain4] [...])\n kmax = maxabs(kin1, kin2 [, kin3] [, kin4] [...])', + example: '--8<-- "examples/maxabs.csd"', + seeAlso: ['Comparators and Accumulators'] +}, +{ + name: 'maxabsaccum', + type: 'opcode', + category: 'Signal Modifiers:Comparators and Accumulators', + description: 'Accumulates the maximum of the absolute values of audio signals.', + syntax: 'maxabsaccum(aAccumulator, aInput)', + example: '--8<-- "examples/maxabsaccum.csd"', + parameters: [ + { + name: 'aAccumulator', + description: 'audio variable to store the maximum value', + type: 'performance' + }, + { + name: 'aInput', + description: 'signal that aAccumulator is compared to', + type: 'performance' + }, + ], + seeAlso: ['Comparators and Accumulators'] +}, +{ + name: 'maxaccum', + type: 'opcode', + category: 'Signal Modifiers:Comparators and Accumulators', + description: 'Accumulates the maximum value of audio signals.', + syntax: 'maxaccum(aAccumulator, aInput)', + example: '--8<-- "examples/maxaccum.csd"', + parameters: [ + { + name: 'aAccumulator', + description: 'audio variable to store the maximum value', + type: 'performance' + }, + { + name: 'aInput', + description: 'signal that aAccumulator is compared to', + type: 'performance' + }, + ], + seeAlso: ['Comparators and Accumulators'] +}, +{ + name: 'min', + type: 'opcode', + category: 'Signal Modifiers:Comparators and Accumulators', + description: 'Produces a signal that is the minimum of any number of input signals.', + syntax: 'amin = min(ain1, ain2 [, ain3] [, ain4] [...])\n kmin = min(kin1, kin2 [, kin3] [, kin4] [...])\n imin = min(iin1, iin2 [, iin3] [, iin4] [...])', + example: '--8<-- "examples/min.csd"', + seeAlso: ['Comparators and Accumulators'] +}, +{ + name: 'minabs', + type: 'opcode', + category: 'Signal Modifiers:Comparators and Accumulators', + description: 'Produces a signal that is the minimum of the absolute values of any number of input signals.', + syntax: 'amin = minabs(ain1, ain2 [, ain3] [, ain4] [...])\n kmin = minabs(kin1, kin2 [, kin3] [, kin4] [...])', + example: '--8<-- "examples/minabs.csd"', + seeAlso: ['Comparators and Accumulators'] +}, +{ + name: 'minabsaccum', + type: 'opcode', + category: 'Signal Modifiers:Comparators and Accumulators', + description: 'Accumulates the minimum of the absolute values of audio signals.', + syntax: 'minabsaccum(aAccumulator, aInput)', + example: '--8<-- "examples/minabsaccum.csd"', + parameters: [ + { + name: 'aAccumulator', + description: 'audio variable to store the minimum value', + type: 'performance' + }, + { + name: 'aInput', + description: 'signal that aAccumulator is compared to', + type: 'performance' + }, + ], + seeAlso: ['Comparators and Accumulators'] +}, +{ + name: 'minaccum', + type: 'opcode', + category: 'Signal Modifiers:Comparators and Accumulators', + description: 'Accumulates the minimum value of audio signals.', + syntax: 'minaccum(aAccumulator, aInput)', + example: '--8<-- "examples/minaccum.csd"', + parameters: [ + { + name: 'aAccumulator', + description: 'audio variable to store the minimum value', + type: 'performance' + }, + { + name: 'aInput', + description: 'signal that aAccumulator is compared to', + type: 'performance' + }, + ], + seeAlso: ['Comparators and Accumulators'] +}, +] diff --git a/src/lib/csound-reference/signal-modifiers-convolution-and-morphing.ts b/src/lib/csound-reference/signal-modifiers-convolution-and-morphing.ts new file mode 100644 index 0000000..c9b83f6 --- /dev/null +++ b/src/lib/csound-reference/signal-modifiers-convolution-and-morphing.ts @@ -0,0 +1,211 @@ +import type { CsoundReference } from './types' + +// Signal Modifiers:Convolution and Morphing +export const signalModifiersConvolutionAndMorphing: CsoundReference[] = [ +{ + name: 'convle', + type: 'opcode', + category: 'Signal Modifiers:Convolution and Morphing', + description: 'Same as the [convolve](../opcodes/convolve.md) opcode.', +}, +{ + name: 'convolve', + type: 'opcode', + category: 'Signal Modifiers:Convolution and Morphing', + description: 'Convolves a signal and an impulse response.', + syntax: 'ar1 [, ar2] [, ar3] [, ar4] = convolve(ain, ifilcod [, ichannel])', + example: 'csound -Ucvanal l1_44.wav l1_44.cv', + parameters: [ + { + name: 'ifilcod', + description: 'integer or character-string denoting an impulse response data file. An integer denotes the suffix of a file _convolve.m_; a character string (in double quotes) gives a filename, optionally a full pathname. If not a fullpath, the file is sought first in the current directory, then in the one given by the environment variable SADIR (if defined). The data file contains the Fourier transform of an impulse response. Memory usage depends on the size of the data file, which is read and held entirely in memory during computation, but which is shared by multiple calls.', + type: 'initialization' + }, + { + name: 'ain', + description: 'input audio signal.', + type: 'performance' + }, + ], + seeAlso: ['Convolution and Morphing'] +}, +{ + name: 'cross2', + type: 'opcode', + category: 'Signal Modifiers:Convolution and Morphing', + description: 'Cross synthesis using FFT\'s.', + syntax: 'ares = cross2(ain1, ain2, isize, ioverlap, iwin, kbias)', + example: '--8<-- "examples/cross2.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'isize', + description: 'This is the size of the FFT to be performed. The larger the size the better the frequency response but a sloppy time response.', + type: 'initialization' + }, + { + name: 'ioverlap', + description: 'This is the overlap factor of the FFT\'s, must be a power of two. The best settings are 2 and 4. A big overlap takes a long time to compile.', + type: 'initialization' + }, + { + name: 'iwin', + description: 'This is the function table that contains the window to be used in the analysis. One can use the [GEN20](../scoregens/gen20.md) routine to create this window.', + type: 'initialization' + }, + { + name: 'ain1', + description: 'The stimulus sound. Must have high frequencies for best results.', + type: 'performance' + }, + { + name: 'ain2', + description: 'The modulating sound. Must have a moving frequency response (like speech) for best results.', + type: 'performance' + }, + { + name: 'kbias', + description: 'The amount of cross synthesis. 1 is the normal, 0 is no cross synthesis.', + type: 'performance' + }, + ], + seeAlso: ['Convolution and Morphing'] +}, +{ + name: 'dconv', + type: 'opcode', + category: 'Signal Modifiers:Convolution and Morphing', + description: 'A direct convolution opcode.', + syntax: 'ares = dconv(asig, isize, ifn)', + example: '--8<-- "examples/dconv.csd"', + rates: ['a-rate', 'i-rate'], + parameters: [ + { + name: 'isize', + description: 'the size of the convolution buffer to use. If the buffer size is smaller than the size of _ifn_, then only the first _isize_ values will be used from the table.', + type: 'initialization' + }, + { + name: 'ifn', + description: 'table number of a stored function containing the impulse response for convolution.', + type: 'initialization' + }, + ], + seeAlso: ['Convolution and Morphing'] +}, +{ + name: 'ftconv', + type: 'opcode', + category: 'Signal Modifiers:Convolution and Morphing', + description: 'Low latency multichannel convolution, using a function table as impulse response source.', + syntax: 'a1[, a2[, a3[, ... a8]]] = ftconv(ain, ift, iplen[, iskipsamples \\\n [, iirlen[, iskipinit]]])', + example: '--8<-- "examples/ftconv.csd"', + parameters: [ + { + name: 'ift', + description: 'source ftable number. The table is expected to contain interleaved multichannel audio data, with the number of channels equal to the number of output variables (a1, a2, etc.). An interleaved table can be created from a set of mono tables with [GEN52](../scoregens/gen52.md).', + type: 'initialization' + }, + { + name: 'iplen', + description: 'length of impulse response partitions, in sample frames; must be an integer power of two. Lower settings allow for shorter output delay, but will increase CPU usage.', + type: 'initialization' + }, + { + name: 'ain', + description: 'input signal.', + type: 'performance' + }, + ], + seeAlso: ['Convolution and Morphing'] +}, +{ + name: 'ftmorf', + type: 'opcode', + category: 'Signal Modifiers:Convolution and Morphing', + description: 'Uses an index into a table of ftable numbers to morph between adjacent tables in the list. This morphed function is written into the table referenced by _iresfn_ on every k-cycle.', + syntax: 'ftmorf(kftndx, iftfn, iresfn)', + example: '--8<-- "examples/ftmorf.csd"', + parameters: [ + { + name: 'iftfn', + description: 'The table containing the numbers of any existing tables which are used for the morphing.', + type: 'initialization' + }, + { + name: 'iresfn', + description: 'Table number of the morphed function', + type: 'initialization' + }, + { + name: 'kftndx', + description: 'the index into the _iftfn_ table.', + type: 'performance' + }, + ], + seeAlso: ['Convolution and Morphing', 'Read/Write Operations'] +}, +{ + name: 'liveconv', + type: 'opcode', + category: 'Signal Modifiers:Convolution and Morphing', + description: 'Partitioned convolution with dynamically reloadable impulse response.', + syntax: 'ares = liveconv(ain, ift, iplen, kupdate, kclear)', + example: '--8<-- "examples/liveconv.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'ift', + description: 'table number for storing the impulse response (IR) for convolution. The table may be filled with new data at any time while the convolution is running.', + type: 'initialization' + }, + { + name: 'iplen', + description: 'length of impulse response partition in samples; must be an integer power of two. Lower settings allow for shorter output delay, but will increase CPU usage.', + type: 'initialization' + }, + { + name: 'ain', + description: 'input signal.', + type: 'performance' + }, + { + name: 'ares', + description: 'output signal.', + type: 'performance' + }, + { + name: 'kupdate', + description: 'flag indicating whether the IR table should be updated. If kupdate=1 the IR table ift is loaded partition by partition, starting with the next partition. If kupdate=-1 the IR table ift is unloaded (cleared to zero) partition by partition, starting with the next partition. Other values have no effect.', + type: 'performance' + }, + { + name: 'kclear', + description: 'flag for clearing all internal buffers. If kclear has any value != zero, the internal buffers are cleared immediately. This operation is not free of artifacts.', + type: 'performance' + }, + ], + seeAlso: ['Convolution and Morphing'] +}, +{ + name: 'pconvolve', + type: 'opcode', + category: 'Signal Modifiers:Convolution and Morphing', + description: 'Convolution based on a uniformly partitioned overlap-save algorithm.', + syntax: 'ar1 [, ar2 [, ar3 [, ar4]]] = pconvolve(ain, ifilcod [, ipartitionsize [, ichannel]])', + example: '--8<-- "examples/pconvolve.csd"', + parameters: [ + { + name: 'ifilcod', + description: 'integer or character-string denoting an impulse response soundfile. Multichannel files are supported, the file must have the same sample-rate as the orc. [Note: _cvanal_ files cannot be used!] Keep in mind that longer files require more calculation time [and probably larger partition sizes and more latency]. At current processor speeds, files longer than a few seconds may not render in real-time.', + type: 'initialization' + }, + { + name: 'ain', + description: 'input audio signal.', + type: 'performance' + }, + ], + seeAlso: ['Convolution and Morphing'] +}, +] diff --git a/src/lib/csound-reference/signal-modifiers-delay.ts b/src/lib/csound-reference/signal-modifiers-delay.ts new file mode 100644 index 0000000..845e359 --- /dev/null +++ b/src/lib/csound-reference/signal-modifiers-delay.ts @@ -0,0 +1,235 @@ +import type { CsoundReference } from './types' + +// Signal Modifiers:Delay +export const signalModifiersDelay: CsoundReference[] = [ +{ + name: 'delay', + type: 'opcode', + category: 'Signal Modifiers:Delay', + description: 'Delays an input signal by some time interval.', + syntax: 'ares = delay(asig, idlt [, iskip])', + example: '--8<-- "examples/delay.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'idlt', + description: 'requested delay time in seconds. This can be as large as available memory will permit. The space required for n seconds of delay is 4n * _sr_ bytes. It is allocated at the time the instrument is first initialized, and returned to the pool at the end of a score section.', + type: 'initialization' + }, + { + name: 'asig', + description: 'audio signal', + type: 'performance' + }, + ], + seeAlso: ['Delay'] +}, +{ + name: 'delay1', + type: 'opcode', + category: 'Signal Modifiers:Delay', + description: 'Delays an input signal by one sample.', + syntax: 'ares = delay1(asig [, iskip])', + example: '--8<-- "examples/delay1.csd"', + rates: ['a-rate'], + seeAlso: ['Delay'] +}, +{ + name: 'delayk', + type: 'opcode', + category: 'Signal Modifiers:Delay', + description: 'Delays an input signal by some time interval.', + syntax: 'kr = delayk(ksig, idel[, imode])\n kr = vdel_k(ksig, kdel, imdel[, imode])', + example: '--8<-- "examples/delayk.csd"', + parameters: [ + { + name: 'idel', + description: 'delay time (in seconds) for delayk. It is rounded to the nearest integer multiple of a k-cycle (i.e. 1/kr).', + type: 'initialization' + }, + { + name: 'imode', + description: 'sum of 1 for skipping initialization (e.g. in tied notes) and 2 for holding the first input value during the initial delay, instead of outputting zero. This is mainly of use when delaying envelopes that do not start at zero.', + type: 'initialization' + }, + { + name: 'imdel', + description: 'maximum delay time for vdel_k, in seconds.', + type: 'initialization' + }, + { + name: 'kr', + description: 'the output signal. Note: neither of the opcodes interpolate the output.', + type: 'performance' + }, + { + name: 'ksig', + description: 'the input signal.', + type: 'performance' + }, + { + name: 'kdel', + description: 'delay time (in seconds) for vdel_k. It is rounded to the nearest integer multiple of a k-cycle (i.e. 1/kr).', + type: 'performance' + }, + ], + seeAlso: ['Delay'] +}, +{ + name: 'delayr', + type: 'opcode', + category: 'Signal Modifiers:Delay', + description: 'Reads from an automatically established digital delay line.', + syntax: 'ares = delayr(idlt [, iskip])', + example: '--8<-- "examples/delayr.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'idlt', + description: 'requested delay time in seconds. This can be as large as available memory will permit. The space required for n seconds of delay is 4n * _sr_ bytes. It is allocated at the time the instrument is first initialized, and returned to the pool at the end of a score section.', + type: 'initialization' + }, + ], + seeAlso: ['Delay'] +}, +{ + name: 'delayw', + type: 'opcode', + category: 'Signal Modifiers:Delay', + description: 'Writes the audio signal to a digital delay line.', + syntax: 'delayw(asig)', + example: '--8<-- "examples/delayw.csd"', + rates: ['a-rate'], + seeAlso: ['Delay'] +}, +{ + name: 'deltap', + type: 'opcode', + category: 'Signal Modifiers:Delay', + description: 'Taps a delay line at variable offset times.', + syntax: 'ares = deltap(kdlt)', + example: 'asource buzz 1, 440, 20, 1\n atime linseg 1, p3/2,.01, p3/2,1 ; trace a distance in secs\n ampfac = 1/atime/atime ; and calc an amp factor\n adump delayr 1 ; set maximum distance\n amove deltapi atime ; move sound source past\n delayw asource ; the listener\n out amove * ampfac', + rates: ['a-rate'], + parameters: [ + { + name: 'kdlt', + description: 'specifies the tapped delay time in seconds. Each can range from 1 control period to the full delay time of the read/write pair; however, since there is no internal check for adherence to this range, the user is wholly responsible. Each argument can be a constant, a variable, or a time-varying signal.', + type: 'performance' + }, + ], + seeAlso: ['Delay'] +}, +{ + name: 'deltap3', + type: 'opcode', + category: 'Signal Modifiers:Delay', + description: 'Taps a delay line at variable offset times, uses cubic interpolation.', + syntax: 'ares = deltap3(xdlt)', + example: 'asource buzz 1, 440, 20, 1\natime linseg 1, p3/2,.01, p3/2,1 ; trace a distance in secs\nampfac = 1/atime/atime ; and calc an amp factor\nadump delayr 1 ; set maximum distance\namove deltapi atime ; move sound source past\n delayw asource ; the listener\n out amove * ampfac', + rates: ['a-rate'], + parameters: [ + { + name: 'xdlt', + description: 'specifies the tapped delay time in seconds. Each can range from 1 control period to the full delay time of the read/write pair; however, since there is no internal check for adherence to this range, the user is wholly responsible. Each argument can be a constant, a variable, or a time-varying signal; the _xdlt_ argument in _deltap3_ implies that an audio-varying delay is permitted there.', + type: 'performance' + }, + ], + seeAlso: ['Delay'] +}, +{ + name: 'deltapi', + type: 'opcode', + category: 'Signal Modifiers:Delay', + description: 'Taps a delay line at variable offset times, uses interpolation.', + syntax: 'ares = deltapi(xdlt)', + example: 'asource buzz 1, 440, 20, 1\natime linseg 1, p3/2,.01, p3/2,1 ; trace a distance in secs\nampfac = 1/atime/atime ; and calc an amp factor\nadump delayr 1 ; set maximum distance\namove deltapi atime ; move sound source past\n delayw asource ; the listener\n out amove * ampfac', + rates: ['a-rate'], + parameters: [ + { + name: 'xdlt', + description: 'specifies the tapped delay time in seconds. Each can range from 1 control period to the full delay time of the read/write pair; however, since there is no internal check for adherence to this range, the user is wholly responsible. Each argument can be a constant, a variable, or a time-varying signal; the _xdlt_ argument in _deltapi_ implies that an audio-varying delay is permitted there.', + type: 'performance' + }, + ], + seeAlso: ['Delay'] +}, +{ + name: 'deltapn', + type: 'opcode', + category: 'Signal Modifiers:Delay', + description: 'Taps a delay line at variable offset times.', + syntax: 'ares = deltapn(xnumsamps)', + example: '--8<-- "examples/deltapn.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'xnumsamps', + description: 'specifies the tapped delay time in number of samples. Each can range from 1 control period to the full delay time of the read/write pair; however, since there is no internal check for adherence to this range, the user is wholly responsible. Each argument can be a constant, a variable, or a time-varying signal.', + type: 'performance' + }, + ], + seeAlso: ['Delay'] +}, +{ + name: 'deltapx', + type: 'opcode', + category: 'Signal Modifiers:Delay', + description: 'Read from or write to a delay line with interpolation.', + syntax: 'aout = deltapx(adel, iwsize)', + example: '--8<-- "examples/deltapx.csd"', + parameters: [ + { + name: 'iwsize', + description: 'interpolation window size in samples. Allowed values are integer multiplies of 4 in the range 4 to 1024. _iwsize_ = 4 uses cubic interpolation. Increasing _iwsize_ improves sound quality at the expense of CPU usage, and minimum delay time.', + type: 'initialization' + }, + { + name: 'aout', + description: 'Output signal.', + type: 'performance' + }, + { + name: 'adel', + description: 'Delay time in seconds.', + type: 'performance' + }, + ], + seeAlso: ['Delay'] +}, +{ + name: 'deltapxw', + type: 'opcode', + category: 'Signal Modifiers:Delay', + description: 'Mixes the input signal to a delay line.', + syntax: 'deltapxw(ain, adel, iwsize)', + example: '--8<-- "examples/deltapxw.csd"', + parameters: [ + { + name: 'iwsize', + description: 'interpolation window size in samples. Allowed values are integer multiplies of 4 in the range 4 to 1024. _iwsize_ = 4 uses cubic interpolation. Increasing _iwsize_ improves sound quality at the expense of CPU usage, and minimum delay time.', + type: 'initialization' + }, + { + name: 'ain', + description: 'Input signal.', + type: 'performance' + }, + { + name: 'adel', + description: 'Delay time in seconds.', + type: 'performance' + }, + ], + seeAlso: ['Delay'] +}, +{ + name: 'multitap', + type: 'opcode', + category: 'Signal Modifiers:Delay', + description: 'Multitap delay line implementation.', + syntax: 'ares = multitap(asig [, itime1, igain1] [, itime2, igain2] [...])', + example: '--8<-- "examples/multitap.csd"', + rates: ['a-rate'], + seeAlso: ['Delay'] +}, +] diff --git a/src/lib/csound-reference/signal-modifiers-panning-and-spatialization.ts b/src/lib/csound-reference/signal-modifiers-panning-and-spatialization.ts new file mode 100644 index 0000000..e072515 --- /dev/null +++ b/src/lib/csound-reference/signal-modifiers-panning-and-spatialization.ts @@ -0,0 +1,865 @@ +import type { CsoundReference } from './types' + +// Signal Modifiers:Panning and Spatialization +export const signalModifiersPanningAndSpatialization: CsoundReference[] = [ +{ + name: 'bformdec1', + type: 'opcode', + category: 'Signal Modifiers:Panning and Spatialization', + description: 'Decodes an ambisonic B format signal into loudspeaker specific signals.', + syntax: 'ao1, ao2 = bformdec1(isetup, aw, ax, ay, az [, ar, as, at, au, av \\\n [, abk, al, am, an, ao, ap, aq]])\n ao1, ao2, ao3, ao4 = bformdec1(isetup, aw, ax, ay, az [, ar, as, at, au, av \\\n [, abk, al, am, an, ao, ap, aq]])\n ao1, ao2, ao3, ao4, ao5 = bformdec1(isetup, aw, ax, ay, az [, ar, as, at, au, av \\\n [, abk, al, am, an, ao, ap, aq]])\n ao1, ao2, ao3, ao4, ao5, ao6, ao7, ao8 = bformdec1(isetup, aw, ax, ay, az \\\n [, ar, as, at, au, av [, abk, al, am, an, ao, ap, aq]])\n aout[] = bformdec1(isetup, abform[])', + example: '--8<-- "examples/bformenc1-modern.csd"', + parameters: [ + { + name: 'isetup', + description: 'loudspeaker setup. There are five supported setups:', + type: 'initialization' + }, + ], + seeAlso: ['Panning and Spatialization: Ambisonics'] +}, +{ + name: 'bformdec2', + type: 'opcode', + category: 'Signal Modifiers:Panning and Spatialization', + description: 'Decodes an Ambisonics B format signal into loudspeaker specific signals, with dual--band decoding and near--field compensation.', + syntax: 'aout[] = bformdec2(isetup, abform[], [idecoder, idistance, ifreq, imix, \\\n ifilel, ifiler])', + parameters: [ + { + name: 'isetup', + description: 'loudspeaker setup. There are currently 8 supported setups, the first five are backwards compatible with [bformdec1](../opcodes/bformdec1.md):', + type: 'initialization' + }, + { + name: 'idecoder', + description: 'optional (default 0), select the type of decoder', + type: 'initialization' + }, + { + name: 'idistance', + description: 'optional (default 1 meter), select the distance (in meters) to the loudspeaker (radius if regular configuration)', + type: 'initialization' + }, + { + name: 'ifreq', + description: 'optional (default 400 Hz), frequency cut (Hz) of the band splitting filter (only has an effect if _idecoder_=0)*', + type: 'initialization' + }, + { + name: 'imix', + description: 'optional (default 0), type of mix of the velocity and energy decoders\' outputs', + type: 'initialization' + }, + { + name: 'ifilel', + description: 'left HRTF spectral data file', + type: 'initialization' + }, + { + name: 'ifiler', + description: 'right HRTF spectral data file', + type: 'initialization' + }, + { + name: 'abform', + description: 'input signal array in the B format', + type: 'performance' + }, + ], + seeAlso: ['Panning and Spatialization: Ambisonics'] +}, +{ + name: 'bformenc1', + type: 'opcode', + category: 'Signal Modifiers:Panning and Spatialization', + description: 'Codes a signal into the ambisonic B format.', + syntax: 'aw, ax, ay, az = bformenc1(asig, kalpha, kbeta)\n aw, ax, ay, az, ar, as, at, au, av = bformenc1(asig, kalpha, kbeta)\n aw, ax, ay, az, ar, as, at, au, av, ak, al, am, an, ao, ap, aq = bformenc1(\\\n asig, kalpha, kbeta)\n aarray[] = bformenc1(asig, kalpha, kbeta)', + example: '--8<-- "examples/bformenc1-modern.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'aarray', + description: 'output array to hold cells of the B format.', + type: 'performance' + }, + { + name: 'asig', + description: 'input signal.', + type: 'performance' + }, + { + name: 'kalpha', + description: 'azimuth angle in degrees (anticlockwise).', + type: 'performance' + }, + { + name: 'kbeta', + description: 'altitude angle in degrees.', + type: 'performance' + }, + ], + seeAlso: ['Panning and Spatialization: Ambisonics'] +}, +{ + name: 'hrtfearly', + type: 'opcode', + category: 'Signal Modifiers:Panning and Spatialization', + description: 'Generates 3D binaural audio with high-fidelity early reflections in a parametric room using a Phase Truncation algorithm.', + syntax: 'aleft, aright, irt60low, irt60high, imfp = hrtfearly(asrc, ksrcx, ksrcy, ksrcz, \\\n klstnrx, klstnry, klstnrz, ifilel, ifiler, idefroom [,ifade, isr, iorder, \\\n ithreed, kheadrot, iroomx, iroomy, iroomz, iwallhigh, iwalllow, \\\n iwallgain1, iwallgain2, iwallgain3, ifloorhigh, ifloorlow, ifloorgain1, \\\n ifloorgain2, ifloorgain3, iceilinghigh, iceilinglow, iceilinggain1, \\\n iceilinggain2, iceilinggain3])', + example: '--8<-- "examples/hrtfearly.csd"', + parameters: [ + { + name: 'ifilel', + description: 'left HRTF spectral data file.', + type: 'initialization' + }, + { + name: 'ifiler', + description: 'right HRTF spectral data file.', + type: 'initialization' + }, + { + name: 'idefroom', + description: 'default room, medium (1: 10*10*3), small (2: 3*4*3) or large (3: 20*25*7). Wall details (high coef, low coef, gain1, gain2, gain3): .3, .1, .75, .95, .9. Floor: .6, .1, .95, .6, .35. Ceiling: .2, .1, 1, 1, 1. If 0 is entered, optional room parameters will be read.', + type: 'initialization' + }, + { + name: 'ifade', + description: 'optional, number of processing buffers for phase change crossfade (default 8). Legal range is 1-24. See [hrtfmove](../opcodes/hrtfmove.md).', + type: 'initialization' + }, + { + name: 'isr', + description: 'optional, default 44.1kHz, legal values: 44100, 48000 and 96000.', + type: 'initialization' + }, + { + name: 'iorder', + description: 'optional, order of images processed: higher order: more reflections. Defaults to 1, legal range: 0-4.', + type: 'initialization' + }, + { + name: 'ithreed', + description: 'optional, process image sources in three dimensions (1) or two (0: default).', + type: 'initialization' + }, + { + name: 'iroomx', + description: 'optional, x room size in metres, will be read if no valid default room is entered (all below parameters behave similarly). Minimum room size is 2\\*2\\*2.', + type: 'initialization' + }, + { + name: 'iroomy', + description: 'optional, y room size.', + type: 'initialization' + }, + { + name: 'iroomz', + description: 'optional, z room size.', + type: 'initialization' + }, + { + name: 'iwallhigh', + description: 'optional, high frequency wall absorption coefficient (all 4 walls are assumed identical). Absorption coefficients will affect reverb time output.', + type: 'initialization' + }, + { + name: 'iwalllow', + description: 'optional, low frequency wall absorption coefficient.', + type: 'initialization' + }, + { + name: 'iwallgain1', + description: 'optional, gain on filter centred at 250 Hz (all filters have a Q implying 4 octaves).', + type: 'initialization' + }, + { + name: 'iwallgain2', + description: 'optional, as above, centred on 1000 Hz.', + type: 'initialization' + }, + { + name: 'iwallgain3', + description: 'optional, as above, centred on 4000 Hz.', + type: 'initialization' + }, + { + name: 'ifloorhigh', + description: 'as above for floor.', + type: 'initialization' + }, + { + name: 'ifloorlow', + description: 'as above for floor.', + type: 'initialization' + }, + { + name: 'ifloorgain1', + description: 'as above for floor.', + type: 'initialization' + }, + { + name: 'ifloorgain2', + description: 'as above for floor.', + type: 'initialization' + }, + { + name: 'ifloorgain3', + description: 'as above for floor.', + type: 'initialization' + }, + { + name: 'iceilinghigh', + description: 'as above for ceiling.', + type: 'initialization' + }, + { + name: 'iceilinglow', + description: 'as above for ceiling.', + type: 'initialization' + }, + { + name: 'iceilinggain1', + description: 'as above for ceiling.', + type: 'initialization' + }, + { + name: 'iceilinggain2', + description: 'as above for ceiling.', + type: 'initialization' + }, + { + name: 'iceilinggain3', + description: 'as above for ceiling.', + type: 'initialization' + }, + { + name: 'kheadrot', + description: 'optional, angular value for head rotation.', + type: 'performance' + }, + { + name: 'asrc', + description: 'Input/source signal.', + type: 'performance' + }, + ], + seeAlso: ['Panning and Spatialization: Binaural spatialization'] +}, +{ + name: 'hrtfer', + type: 'opcode', + category: 'Signal Modifiers:Panning and Spatialization', + description: 'Creates 3D audio for two speakers. Output is binaural (headphone) 3D audio.', + syntax: 'aleft, aright = hrtfer(asig, kaz, kelev, "HRTFcompact")', + example: '--8<-- "examples/hrtfer.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'kAz', + description: 'azimuth value in degrees. Positive values represent position on the right, negative values are positions on the left.', + type: 'initialization' + }, + { + name: 'kElev', + description: 'elevation value in degrees. Positive values represent position above horizontal, negative values are positions under horizontal.', + type: 'initialization' + }, + ], + seeAlso: ['Panning and Spatialization: Binaural spatialization'] +}, +{ + name: 'hrtfmove', + type: 'opcode', + category: 'Signal Modifiers:Panning and Spatialization', + description: 'Generates dynamic 3d binaural audio for headphones using magnitude interpolation and phase truncation.', + syntax: 'aleft, aright = hrtfmove(asrc, kAz, kElev, ifilel, ifiler [, imode, ifade, isr])', + example: '--8<-- "examples/hrtfmove.csd"', + parameters: [ + { + name: 'ifilel', + description: 'left HRTF spectral data file', + type: 'initialization' + }, + { + name: 'ifiler', + description: 'right HRTF spectral data file', + type: 'initialization' + }, + { + name: 'imode', + description: 'optional, default 0 for phase truncation, 1 for minimum phase', + type: 'initialization' + }, + { + name: 'ifade', + description: 'optional, number of processing buffers for phase change crossfade (default 8). Legal range is 1-24. A low value is recommended for complex sources (4 or less: a higher value may make the crossfade audible), a higher value (8 or more: a lower value may make the inconsistency when the filter changes phase values audible) for narrowband sources. Does not effect minimum phase processing.', + type: 'initialization' + }, + { + name: 'isr', + description: 'optional, default 44.1kHz, legal values: 44100, 48000 and 96000.', + type: 'initialization' + }, + { + name: 'kAz', + description: 'azimuth value in degrees. Positive values represent position on the right, negative values are positions on the left.', + type: 'performance' + }, + { + name: 'kElev', + description: 'elevation value in degrees. Positive values represent position above horizontal, negative values are positions below horizontal (min -40).', + type: 'performance' + }, + ], + seeAlso: ['Panning and Spatialization: Binaural spatialization', 'http://www.csoundjournal.com/issue9/newHRTFOpcodes.html'] +}, +{ + name: 'hrtfmove2', + type: 'opcode', + category: 'Signal Modifiers:Panning and Spatialization', + description: 'Generates dynamic 3d binaural audio for headphones using a Woodworth based spherical head model with improved low frequency phase accuracy.', + syntax: 'aleft, aright = hrtfmove2(asrc, kAz, kElev, ifilel, ifiler [,ioverlap, iradius, isr])', + example: '--8<-- "examples/hrtfmove2.csd"', + parameters: [ + { + name: 'ifilel', + description: 'left HRTF spectral data file', + type: 'initialization' + }, + { + name: 'ifiler', + description: 'right HRTF spectral data file', + type: 'initialization' + }, + { + name: 'ioverlap', + description: 'optional, number of overlaps for STFT processing (default 4). See STFT section of manual.', + type: 'initialization' + }, + { + name: 'iradius', + description: 'optional, head radius used for phase spectra calculation in centimeters (default 9.0)', + type: 'initialization' + }, + { + name: 'isr', + description: 'optional, default 44.1kHz, legal values: 44100, 48000 and 96000.', + type: 'initialization' + }, + { + name: 'asrc', + description: 'Input/source signal.', + type: 'performance' + }, + { + name: 'kAz', + description: 'azimuth value in degrees. Positive values represent position on the right, negative values are positions on the left.', + type: 'performance' + }, + { + name: 'kElev', + description: 'elevation value in degrees. Positive values represent position above horizontal, negative values are positions below horizontal (min -40).', + type: 'performance' + }, + ], + seeAlso: ['Panning and Spatialization: Binaural spatialization', 'http://www.csoundjournal.com/issue9/newHRTFOpcodes.html'] +}, +{ + name: 'hrtfreverb', + type: 'opcode', + category: 'Signal Modifiers:Panning and Spatialization', + description: 'A binaural, dynamic FDN based diffuse-field reverberator. The opcode works independently as an efficient, flexible reverberator.', + syntax: 'aleft, aright, idel = hrtfreverb(asrc, ilowrt60, ihighrt60, ifilel, ifiler \\\n [,isr, imfp, iorder])', + example: '--8<-- "examples/hrtfearly.csd"', + parameters: [ + { + name: 'ilowrt60', + description: 'low frequency reverb time.', + type: 'initialization' + }, + { + name: 'ihighrt60', + description: 'high frequency reverb time.', + type: 'initialization' + }, + { + name: 'ifilel', + description: 'left HRTF spectral data file.', + type: 'initialization' + }, + { + name: 'ifiler', + description: 'right HRTF spectral data file.', + type: 'initialization' + }, + { + name: 'isr', + description: 'optional, default 44.1kHz, legal values: 44100, 48000 and 96000.', + type: 'initialization' + }, + { + name: 'imfp', + description: 'optional, mean free path, defaults to that of a medium room. If used with [hrtfearly](../opcodes/hrtfearly.md), the mean free path of the room can be used to calculate the appropriate delay for the later reverb. Legal range: the mean free path of the smallest room allowed by hrtfearly (0.003876) 1.', + type: 'initialization' + }, + { + name: 'iorder', + description: 'optional, order of early reflection processing. If used with [hrtfearly](../opcodes/hrtfearly.md), the order of early reflections can be used to calculate the appropriate delay on the later reverb.', + type: 'initialization' + }, + { + name: 'asrc', + description: 'Input/source signal.', + type: 'performance' + }, + ], + seeAlso: ['Panning and Spatialization: Binaural spatialization'] +}, +{ + name: 'hrtfstat', + type: 'opcode', + category: 'Signal Modifiers:Panning and Spatialization', + description: 'Generates static 3d binaural audio for headphones using a Woodworth based spherical head model with improved low frequency phase accuracy.', + syntax: 'aleft, aright = hrtfstat(asrc, iAz, iElev, ifilel, ifiler [,iradius, isr])', + example: '--8<-- "examples/hrtfstat.csd"', + parameters: [ + { + name: 'iAz', + description: 'azimuth value in degrees. Positive values represent position on the right, negative values are positions on the left.', + type: 'initialization' + }, + { + name: 'iElev', + description: 'elevation value in degrees. Positive values represent position above horizontal, negative values are positions below horizontal (min -40).', + type: 'initialization' + }, + { + name: 'ifilel', + description: 'left HRTF spectral data file', + type: 'initialization' + }, + { + name: 'ifiler', + description: 'right HRTF spectral data file', + type: 'initialization' + }, + { + name: 'iradius', + description: 'optional, head radius used for phase spectra calculation in centimeters (default 9.0)', + type: 'initialization' + }, + { + name: 'isr', + description: 'optional (default 44.1kHz). Legal values are 44100, 48000 and 96000.', + type: 'initialization' + }, + ], + seeAlso: ['Panning and Spatialization: Binaural spatialization', 'http://www.csoundjournal.com/issue9/newHRTFOpcodes.html'] +}, +{ + name: 'locsend', + type: 'opcode', + category: 'Signal Modifiers:Panning and Spatialization', + description: 'Distributes the audio signals of a previous [locsig](../opcodes/locsig.md) opcode.', + syntax: 'a1, a2 = locsend()\n a1, a2, a3, a4 = locsend()', + example: 'asig some audio signal\n kdegree line 0, p3, 360\n kdistance line 1, p3, 10\n a1, a2, a3, a4 locsig asig, kdegree, kdistance, .1\n ar1, ar2, ar3, ar4 locsend\n ga1 = ga1+ar1\n ga2 = ga2+ar2\n ga3 = ga3+ar3\n ga4 = ga4+ar4\n outq a1, a2, a3, a4\nendin\n\ninstr 99 ; reverb instrument\n a1 reverb2 ga1, 2.5, .5\n a2 reverb2 ga2, 2.5, .5\n a3 reverb2 ga3, 2.5, .5\n a4 reverb2 ga4, 2.5, .5\n outq a1, a2, a3, a4\n ga1=0\n ga2=0\n ga3=0\n ga4=0', + seeAlso: ['Panning and Spatialization: Amplitude spatialization'] +}, +{ + name: 'locsig', + type: 'opcode', + category: 'Signal Modifiers:Panning and Spatialization', + description: 'Takes an input signal and distributes between 2 or 4 channels.', + syntax: 'a1, a2 = locsig(asig, kdegree, kdistance, kreverbsend)\n a1, a2, a3, a4 = locsig(asig, kdegree, kdistance, kreverbsend)', + example: '--8<-- "examples/locsig_quad.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'kdegree', + description: 'value between 0 and 360 for placement of the signal in a 2 or 4 channel space configured as: a1=0, a2=90, a3=180, a4=270 (kdegree=45 would balanced the signal equally between a1 and a2). _locsig_ maps _kdegree_ to sin and cos functions to derive the signal balances (e.g.: asig=1, kdegree=45, a1=a2=.707).', + type: 'performance' + }, + { + name: 'kdistance', + description: 'value >= 1 used to attenuate the signal and to calculate reverb level to simulate distance cues. As _kdistance_ gets larger the sound should get softer and somewhat more reverberant (assuming the use of _locsend_ in this case).', + type: 'performance' + }, + { + name: 'kreverbsend', + description: 'the percentage of the direct signal that will be factored along with the distance and degree values to derive signal amounts that can be sent to a reverb unit such as _reverb_, or _reverb2_.', + type: 'performance' + }, + ], + seeAlso: ['Panning and Spatialization: Amplitude spatialization'] +}, +{ + name: 'ms2st', + type: 'opcode', + category: 'Signal Modifiers:Panning and Spatialization', + description: 'Mid-Side to stereo Conversion with a width control.', + syntax: 'aleft,aright = ms2st(am, as, kwidth)', + example: '--8<-- "examples/ms2st.csd"', + parameters: [ + { + name: 'aleft', + description: 'left channel output.', + type: 'performance' + }, + { + name: 'aright', + description: 'right channel output.', + type: 'performance' + }, + { + name: 'am', + description: 'mid signal input.', + type: 'performance' + }, + { + name: 'as', + description: 'side signal input.', + type: 'performance' + }, + { + name: 'kwidth', + description: 'stereo width (0 to 1). At 0, no side signal is output, and at 1 no mid signal is present. A value of 0.5 restores a stereo to MS conversion (st2ms) exactly.', + type: 'performance' + }, + ], + seeAlso: ['Panning and Spatialization: Amplitude spatialization'] +}, +{ + name: 'pan', + type: 'opcode', + category: 'Signal Modifiers:Panning and Spatialization', + description: 'Distribute an audio signal amongst four channels with localization control.', + syntax: 'a1, a2, a3, a4 = pan(asig, kx, ky, ifn [, imode] [, ioffset])', + example: '--8<-- "examples/pan.csd"', + rates: ['a-rate', 'i-rate'], + parameters: [ + { + name: 'ifn', + description: 'function table number of a stored pattern describing the amplitude growth in a speaker channel as sound moves towards it from an adjacent speaker. Requires extended guard-point.', + type: 'initialization' + }, + ], + seeAlso: ['Panning and Spatialization: Amplitude spatialization'] +}, +{ + name: 'pan2', + type: 'opcode', + category: 'Signal Modifiers:Panning and Spatialization', + description: 'Distribute an audio signal across two channels with a choice of methods.', + syntax: 'a1, a2 = pan2(asig, xp [, imode])\n aouts[] = pan2(asig, xp [, imode])', + example: '--8<-- "examples/pan2.csd"', + rates: ['a-rate'], + seeAlso: ['Panning and Spatialization: Amplitude spatialization'] +}, +{ + name: 'space', + type: 'opcode', + category: 'Signal Modifiers:Panning and Spatialization', + description: 'Distributes an input signal among 4 channels using cartesian coordinates.', + syntax: 'a1, a2, a3, a4 = space(asig, ifn, ktime, kreverbsend, kx, ky)', + example: '--8<-- "examples/space_quad.csd"', + rates: ['a-rate', 'i-rate'], + parameters: [ + { + name: 'ifn', + description: 'number of the stored function created using [Gen28](../scoregens/gen28.md). This function generator reads a text file which contains sets of three values representing the xy coordinates and a time-tag for when the signal should be placed at that location. The file should look like:', + type: 'initialization' + }, + { + name: 'asig', + description: 'input audio signal.', + type: 'performance' + }, + { + name: 'ktime', + description: 'index into the table containing the xy coordinates. If used like:', + type: 'performance' + }, + { + name: 'kreverbsend', + description: 'the percentage of the direct signal that will be factored along with the distance as derived from the xy coordinates to calculate signal amounts that can be sent to reverb units such as _reverb_, or _reverb2_.', + type: 'performance' + }, + { + name: 'kx', + description: 'when _ifn_ is 0, _space_ and _spdist_ will use these values as the xy coordinates to localize the signal.', + type: 'performance' + }, + { + name: 'ky', + description: 'when _ifn_ is 0, _space_ and _spdist_ will use these values as the xy coordinates to localize the signal.', + type: 'performance' + }, + ], + seeAlso: ['Panning and Spatialization: Amplitude spatialization'] +}, +{ + name: 'spat3d', + type: 'opcode', + category: 'Signal Modifiers:Panning and Spatialization', + description: 'Positions the input sound in a 3D space and allows moving the sound at k-rate.', + syntax: 'aW, aX, aY, aZ = spat3d(ain, kX, kY, kZ, idist, ift, imode, imdel, iovr [, istor])', + example: '--8<-- "examples/spat3d_stereo.csd"', + parameters: [ + { + name: 'idist', + description: 'For modes 0 to 3, _idist_ is the unit circle distance in meters. For mode 4, _idist_ is the distance between microphones.', + type: 'initialization' + }, + { + name: 'ift', + description: 'Function table storing room parameters (for free field spatialization, set it to zero or negative). Table size is 54. The values in the table are:', + type: 'initialization' + }, + { + name: 'imode', + description: 'Output mode', + type: 'initialization' + }, + { + name: 'imdel', + description: 'Maximum delay time for spat3d in seconds. This has to be longer than the delay time of the latest reflection (depends on room dimensions, sound source distance, and recursion depth; using this formula gives a safe (although somewhat overestimated) value:', + type: 'initialization' + }, + { + name: 'iovr', + description: 'Oversample ratio for spat3d (1 to 8). Setting it higher improves quality at the expense of memory and CPU usage. The recommended value is 2.', + type: 'initialization' + }, + { + name: 'aW', + description: 'Output signals', + type: 'performance' + }, + { + name: 'aX', + description: 'Output signals', + type: 'performance' + }, + { + name: 'aY', + description: 'Output signals', + type: 'performance' + }, + { + name: 'aZ', + description: 'Output signals', + type: 'performance' + }, + { + name: 'ain', + description: 'Input signal', + type: 'performance' + }, + { + name: 'kX', + description: 'Sound source coordinates (in meters)', + type: 'performance' + }, + { + name: 'kY', + description: 'Sound source coordinates (in meters)', + type: 'performance' + }, + { + name: 'kZ', + description: 'Sound source coordinates (in meters)', + type: 'performance' + }, + ], + seeAlso: ['Panning and Spatialization: Simulation of room acoustics'] +}, +{ + name: 'spat3di', + type: 'opcode', + category: 'Signal Modifiers:Panning and Spatialization', + description: 'Positions the input sound in a 3D space with the sound source position set at i-time.', + syntax: 'aW, aX, aY, aZ = spat3di(ain, iX, iY, iZ, idist, ift, imode [, istor])', + parameters: [ + { + name: 'iX', + description: 'Sound source X coordinate in meters (positive: right, negative: left)', + type: 'initialization' + }, + { + name: 'iY', + description: 'Sound source Y coordinate in meters (positive: front, negative: back)', + type: 'initialization' + }, + { + name: 'iZ', + description: 'Sound source Z coordinate in meters (positive: up, negative: down)', + type: 'initialization' + }, + { + name: 'idist', + description: 'For modes 0 to 3, _idist_ is the unit circle distance in meters. For mode 4, _idist_ is the distance between microphones.', + type: 'initialization' + }, + { + name: 'ift', + description: 'Function table storing room parameters (for free field spatialization, set it to zero or negative). Table size is 54. The values in the table are:', + type: 'initialization' + }, + { + name: 'imode', + description: 'Output mode', + type: 'initialization' + }, + { + name: 'ain', + description: 'Input signal', + type: 'performance' + }, + { + name: 'aW', + description: 'Output signals', + type: 'performance' + }, + { + name: 'aX', + description: 'Output signals', + type: 'performance' + }, + { + name: 'aY', + description: 'Output signals', + type: 'performance' + }, + { + name: 'aZ', + description: 'Output signals', + type: 'performance' + }, + ], + seeAlso: ['Panning and Spatialization: Simulation of room acoustics'] +}, +{ + name: 'spat3dt', + type: 'opcode', + category: 'Signal Modifiers:Panning and Spatialization', + description: 'Can be used to render an impulse response for a 3D space at i-time.', + syntax: 'spat3dt(ioutft, iX, iY, iZ, idist, ift, imode, irlen [, iftnocl])', + example: '--8<-- "examples/spat3dt.csd"', + parameters: [ + { + name: 'ioutft', + description: 'Output ftable number for spat3dt. W, X, Y, and Z outputs are written interleaved to this table. If the table is too short, output will be truncated.', + type: 'initialization' + }, + { + name: 'iX', + description: 'Sound source X coordinate in meters (positive: right, negative: left)', + type: 'initialization' + }, + { + name: 'iY', + description: 'Sound source Y coordinate in meters (positive: front, negative: back)', + type: 'initialization' + }, + { + name: 'iZ', + description: 'Sound source Z coordinate in meters (positive: up, negative: down)', + type: 'initialization' + }, + { + name: 'idist', + description: 'For modes 0 to 3, _idist_ is the unit circle distance in meters. For mode 4, _idist_ is the distance between microphones.', + type: 'initialization' + }, + { + name: 'ift', + description: 'Function table storing room parameters (for free field spatialization, set it to zero or negative). Table size is 54. The values in the table are:', + type: 'initialization' + }, + { + name: 'imode', + description: 'Output mode', + type: 'initialization' + }, + { + name: 'irlen', + description: 'Impulse response length of echoes (in seconds). Depending on filter parameters, values around 0.005-0.01 are suitable for most uses (higher values result in more accurate output, but slower rendering)', + type: 'initialization' + }, + ], + seeAlso: ['Panning and Spatialization: Simulation of room acoustics'] +}, +{ + name: 'spdist', + type: 'opcode', + category: 'Signal Modifiers:Panning and Spatialization', + description: 'Calculates distance values from xy coordinates.', + syntax: 'k1 = spdist(ifn, ktime, kx, ky)', + example: '--8<-- "examples/spdist.csd"', + rates: ['i-rate'], + parameters: [ + { + name: 'ifn', + description: 'number of the stored function created using [Gen28](../scoregens/gen28.md). This function generator reads a text file which contains sets of three values representing the xy coordinates and a time-tag for when the signal should be placed at that location. The file should look like:', + type: 'initialization' + }, + { + name: 'ktime', + description: 'index into the table containing the xy coordinates. If used like:', + type: 'performance' + }, + { + name: 'kx', + description: 'when _ifn_ is 0, _space_ and _spdist_ will use these values as the XY coordinates to localize the signal.', + type: 'performance' + }, + { + name: 'ky', + description: 'when _ifn_ is 0, _space_ and _spdist_ will use these values as the XY coordinates to localize the signal.', + type: 'performance' + }, + ], + seeAlso: ['Panning and Spatialization: Amplitude spatialization'] +}, +{ + name: 'spsend', + type: 'opcode', + category: 'Signal Modifiers:Panning and Spatialization', + description: 'Generates output signals based on a previously defined [space](../opcodes/space.md) opcode.', + syntax: 'a1, a2, a3, a4 = spsend()', + example: '--8<-- "examples/spsend.csd"', + seeAlso: ['Panning and Spatialization: Amplitude spatialization'] +}, +{ + name: 'st2ms', + type: 'opcode', + category: 'Signal Modifiers:Panning and Spatialization', + description: 'Stereo to Mid-Side Conversion.', + syntax: 'am,as = st2ms(aleft,aright)', + example: '--8<-- "examples/st2ms.csd"', + parameters: [ + { + name: 'am', + description: 'mid signal output.', + type: 'performance' + }, + { + name: 'as', + description: 'side signal output.', + type: 'performance' + }, + { + name: 'aleft', + description: 'left channel input.', + type: 'performance' + }, + { + name: 'aright', + description: 'right channel input.', + type: 'performance' + }, + ], + seeAlso: ['Panning and Spatialization: Amplitude spatialization'] +}, +] diff --git a/src/lib/csound-reference/signal-modifiers-reverberation.ts b/src/lib/csound-reference/signal-modifiers-reverberation.ts new file mode 100644 index 0000000..dbb65d1 --- /dev/null +++ b/src/lib/csound-reference/signal-modifiers-reverberation.ts @@ -0,0 +1,360 @@ +import type { CsoundReference } from './types' + +// Signal Modifiers:Reverberation +export const signalModifiersReverberation: CsoundReference[] = [ +{ + name: 'alpass', + type: 'opcode', + category: 'Signal Modifiers:Reverberation', + description: 'Reverberates an input signal with a flat frequency response.', + syntax: 'ares = alpass(asig, xrvt, ilpt [, iskip] [, insmps])', + example: '--8<-- "examples/alpass-modern.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'ilpt', + description: 'loop time in seconds, which determines the “echo density” of the reverberation. This in turn characterizes the “color” of the filter whose frequency response curve will contain _ilpt_ * _sr_/2 peaks spaced evenly between 0 and _sr_/2 (the Nyquist frequency). Loop time can be as large as available memory will permit. The space required for an _n_ second loop is 4_n_*_sr_ bytes. The delay space is allocated and returned as in [delay](../opcodes/delay.md).', + type: 'initialization' + }, + { + name: 'xrvt', + description: 'the reverberation time (defined as the time in seconds for a signal to decay to 1/1000, or 60dB down from its original amplitude).', + type: 'performance' + }, + ], + seeAlso: ['Reverberation'] +}, +{ + name: 'babo', + type: 'opcode', + category: 'Signal Modifiers:Reverberation', + description: 'A physical model reverberator.', + syntax: 'a1, a2 = babo(asig, ksrcx, ksrcy, ksrcz, irx, iry, irz [, idiff] [, ifno])\n a1, a2 = babo2(asig, ksrcx, ksrcy, ksrcz, irx, iry, irz [, idiff] [, ifno])', + example: '--8<-- "examples/babo.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'irx', + description: 'the coordinates of the geometry of the resonator (length of the edges in meters)', + type: 'initialization' + }, + { + name: 'iry', + description: 'the coordinates of the geometry of the resonator (length of the edges in meters)', + type: 'initialization' + }, + { + name: 'irz', + description: 'the coordinates of the geometry of the resonator (length of the edges in meters)', + type: 'initialization' + }, + { + name: 'idiff', + description: 'is the coefficient of diffusion at the walls, which regulates the amount of diffusion (0-1, where 0 = no diffusion, 1 = maximum diffusion - default: 1)', + type: 'initialization' + }, + { + name: 'ifno', + description: 'expert values function: a function number that holds all the additional parameters of the resonator. This is typically a GEN2--type function used in non-rescaling mode. They are as follows:', + type: 'initialization' + }, + { + name: 'decay', + description: 'main decay of the resonator (default: 0.99) * _hydecay_ -- high frequency decay of the resonator (default: 0.1) * _rcvx, rcvy, rcvz_ -- the coordinates of the position of the receiver (the listener) (in meters; 0,0,0 is the resonator center) * _rdistance_ -- the distance in meters between the two pickups (your ears, for example - default: 0.3) * _direct_ -- the attenuation of the direct signal (0-1, default: 0.5). This is a non-op in babo, but has been introduced in babo2. * _early_diff_ -- the attenuation coefficient of the early reflections (0-1, default: 0.8)', + type: 'initialization' + }, + { + name: 'asig', + description: 'the input signal', + type: 'performance' + }, + { + name: 'ksrcx', + description: 'the virtual coordinates of the source of sound (the input signal). These are allowed to move at k-rate and provide all the necessary variations in terms of response of the resonator.', + type: 'performance' + }, + { + name: 'ksrcy', + description: 'the virtual coordinates of the source of sound (the input signal). These are allowed to move at k-rate and provide all the necessary variations in terms of response of the resonator.', + type: 'performance' + }, + { + name: 'ksrcz', + description: 'the virtual coordinates of the source of sound (the input signal). These are allowed to move at k-rate and provide all the necessary variations in terms of response of the resonator.', + type: 'performance' + }, + ], + seeAlso: ['Reverberation'] +}, +{ + name: 'comb', + type: 'opcode', + category: 'Signal Modifiers:Reverberation', + description: 'Reverberates an input signal with a “colored” frequency response.', + syntax: 'ares = comb(asig, krvt, ilpt [, iskip] [, insmps])', + example: '--8<-- "examples/comb-modern.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'ilpt', + description: 'loop time in seconds, which determines the “echo density” of the reverberation. This in turn characterizes the “color” of the _comb_ filter whose frequency response curve will contain _ilpt_ * _sr_/2 peaks spaced evenly between 0 and _sr_/2 (the Nyquist frequency). Loop time can be as large as available memory will permit. The space required for an _n_ second loop is _n_*_sr_ floating or double numbers (usually 4 or 8 bytes). Delay space is allocated and returned as in [delay](../opcodes/delay.md).', + type: 'initialization' + }, + { + name: 'krvt', + description: 'the reverberation time (defined as the time in seconds for a signal to decay to 1/1000, or 60dB down from its original amplitude).', + type: 'performance' + }, + ], + seeAlso: ['Reverberation'] +}, +{ + name: 'combinv', + type: 'opcode', + category: 'Signal Modifiers:Reverberation', + description: 'Reverberates an input signal with a “colored” frequency response. with a FIR filter.', + syntax: 'ares = combinv(asig, krvt, ilpt [, iskip] [, insmps])', + example: '--8<-- "examples/combinv-modern.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'ilpt', + description: 'loop time in seconds, which determines the “echo density” of the reverberation. This in turn characterizes the “color” of the _combinv_ filter whose frequency response curve will contain _ilpt_ * _sr_/2 peaks spaced evenly between 0 and _sr_/2 (the Nyquist frequency). Loop time can be as large as available memory will permit. The space required for an _n_ second loop is _n_*_sr_ floating or double numbers (usually 4 or 8 bytes). Delay space is allocated and returned as in [delay](../opcodes/delay.md).', + type: 'initialization' + }, + { + name: 'krvt', + description: 'the reverberation time (defined as the time in seconds for a signal to decay to 1/1000, or 60dB down from its original amplitude).', + type: 'performance' + }, + ], + seeAlso: ['Reverberation'] +}, +{ + name: 'freeverb', + type: 'opcode', + category: 'Signal Modifiers:Reverberation', + description: 'Opcode version of Jezar\'s Freeverb.', + syntax: 'aoutL, aoutR = freeverb(ainL, ainR, kRoomSize, kHFDamp[, iSRate[, iSkip]])', + example: '--8<-- "examples/freeverb.csd"', + parameters: [ + { + name: 'ainL', + description: 'input signals; usually both are the same, but different inputs can be used for special effect', + type: 'performance' + }, + { + name: 'ainR', + description: 'input signals; usually both are the same, but different inputs can be used for special effect', + type: 'performance' + }, + { + name: 'aoutL', + description: 'output signals for left and right channel', + type: 'performance' + }, + { + name: 'aoutR', + description: 'output signals for left and right channel', + type: 'performance' + }, + ], + seeAlso: ['Reverberation'] +}, +{ + name: 'nestedap', + type: 'opcode', + category: 'Signal Modifiers:Reverberation', + description: 'Three different nested all-pass filters, useful for implementing reverbs.', + syntax: 'ares = nestedap(asig, imode, imaxdel, idel1, igain1 [, idel2] [, igain2] \\\n [, idel3] [, igain3] [, istor])', + example: '--8<-- "examples/nestedap.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'imode', + description: 'operating mode of the filter:', + type: 'initialization' + }, + { + name: 'idel1', + description: 'delay times of the filter stages. Delay times are in seconds and must be greater than zero. _idel1_ must be greater than the sum of _idel2_ and _idel3_.', + type: 'initialization' + }, + { + name: 'idel2', + description: 'delay times of the filter stages. Delay times are in seconds and must be greater than zero. _idel1_ must be greater than the sum of _idel2_ and _idel3_.', + type: 'initialization' + }, + { + name: 'idel3', + description: 'delay times of the filter stages. Delay times are in seconds and must be greater than zero. _idel1_ must be greater than the sum of _idel2_ and _idel3_.', + type: 'initialization' + }, + { + name: 'igain1', + description: 'gain of the filter stages.', + type: 'initialization' + }, + { + name: 'igain2', + description: 'gain of the filter stages.', + type: 'initialization' + }, + { + name: 'igain3', + description: 'gain of the filter stages.', + type: 'initialization' + }, + { + name: 'imaxdel', + description: 'will be necessary if k-rate delays are implemented. Not currently used.', + type: 'initialization' + }, + { + name: 'istor', + description: 'Skip initialization if non-zero (default: 0).', + type: 'initialization' + }, + { + name: 'asig', + description: 'input signal', + type: 'performance' + }, + ], + seeAlso: ['Reverberation'] +}, +{ + name: 'nreverb', + type: 'opcode', + category: 'Signal Modifiers:Reverberation', + description: 'A reverberator consisting of 6 parallel comb-lowpass filters.', + syntax: 'ares = nreverb(asig, ktime, khdif [, iskip] [,inumCombs] [, ifnCombs] \\\n [, inumAlpas] [, ifnAlpas])', + example: '--8<-- "examples/nreverb.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'ifnCombs', + description: 'function table with _inumCombs_ comb filter time values, followed the same number of gain values. The ftable should not be rescaled (use negative fgen number). Positive time values are in seconds. The time values are converted internally into number of samples, then set to the next greater prime number. If the time is negative, it is interpreted directly as time in sample frames, and no processing is done (except negation). New in Csound version 4.09.', + type: 'initialization' + }, + ], + seeAlso: ['Reverberation'] +}, +{ + name: 'platerev', + type: 'opcode', + category: 'Signal Modifiers:Reverberation', + description: 'Models the reverberation of a rectangular metal plate with settable physical characteristics when excited by audio signal(s).', + syntax: 'a1[, a2, ...] = platerev(itabexcite. itabouts, kbndry, iaspect, istiff, idecay, \\\n iloss, aexcite1[, aexcite2, ...])', + example: '--8<-- "examples/plate.csd"', + parameters: [ + { + name: 'itabexcite', + description: 'number of a table that contains triplets for each excitation signal, (frequency, radius, initial phase in radians). The radius should be less than 1. These control where the excitation happens. The values in the table for frequency and radius may be changed in performance, with the proviso about clicking if the changes are too large.', + type: 'initialization' + }, + { + name: 'itabouts', + description: 'number of a table that contains triplets for each output signal, (frequency, radius, initial phase in radians). See itabexcite description.', + type: 'initialization' + }, + { + name: 'kbndry', + description: 'boundary condition of the plate; 0 = free, 1 = clamped, 2 = pivoting. Other values are undefined. Thus parameter may be changed at k-rate but that might give rise to clicks.', + type: 'initialization' + }, + { + name: 'iaspect', + description: 'plate aspect ratio which should be less than or equal to 1.', + type: 'initialization' + }, + { + name: 'istiff', + description: 'plate stiffness parameter (set around 1 or less for plate reverb).', + type: 'initialization' + }, + { + name: 'idecay', + description: 'time taken for 30 dB decay', + type: 'initialization' + }, + { + name: 'iloss', + description: 'loss parameter for high-frequency damping (value about 0.001 suggested).', + type: 'initialization' + }, + { + name: 'aexciten', + description: 'excitation signal to be inserted into the plate.', + type: 'performance' + }, + ], + seeAlso: ['Reverberation'] +}, +{ + name: 'reverb', + type: 'opcode', + category: 'Signal Modifiers:Reverberation', + description: 'Reverberates an input signal with a “natural room” frequency response.', + syntax: 'ares = reverb(asig, krvt [, iskip])', + example: '--8<-- "examples/reverb.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'krvt', + description: 'the reverberation time (defined as the time in seconds for a signal to decay to 1/1000, or 60dB down from its original amplitude).', + type: 'performance' + }, + ], + seeAlso: ['Reverberation'] +}, +{ + name: 'reverb2', + type: 'opcode', + category: 'Signal Modifiers:Reverberation', + description: 'Same as the [nreverb](../opcodes/nreverb.md) opcode.', + syntax: 'ares = reverb2(asig, ktime, khdif [, iskip] [,inumCombs] [, ifnCombs] \\\n [, inumAlpas] [, ifnAlpas])', + rates: ['a-rate'], +}, +{ + name: 'reverbsc', + type: 'opcode', + category: 'Signal Modifiers:Reverberation', + description: '8 delay line stereo FDN reverb.', + syntax: 'aoutL, aoutR = reverbsc(ainL, ainR, kfblvl, kfco[, israte[, ipitchm[, iskip]]])', + example: '--8<-- "examples/reverbsc.csd"', + parameters: [ + { + name: 'aoutL', + description: 'output signals for left and right channel', + type: 'performance' + }, + { + name: 'aoutR', + description: 'output signals for left and right channel', + type: 'performance' + }, + { + name: 'ainL', + description: 'left and right channel input. Note that having an input signal on either the left or right channel only will still result in having reverb output on both channels, making this unit more suitable for reverberating stereo input than the [freeverb](../opcodes/freeverb.md) opcode.', + type: 'performance' + }, + { + name: 'ainR', + description: 'left and right channel input. Note that having an input signal on either the left or right channel only will still result in having reverb output on both channels, making this unit more suitable for reverberating stereo input than the [freeverb](../opcodes/freeverb.md) opcode.', + type: 'performance' + }, + { + name: 'kfblvl', + description: 'feedback level, in the range 0 to 1. 0.6 gives a good small "live" room sound, 0.8 a small hall, and 0.9 a large hall. A setting of exactly 1 means infinite length, while higher values will make the opcode unstable.', + type: 'performance' + }, + { + name: 'kfco', + description: 'cutoff frequency of simple first order lowpass filters in the feedback loop of delay lines, in Hz. Should be in the range 0 to israte/2 (not sr/2). A lower value means faster decay in the high frequency range.', + type: 'performance' + }, + ], + seeAlso: ['Reverberation'] +}, +] diff --git a/src/lib/csound-reference/signal-modifiers-sample-level-operators.ts b/src/lib/csound-reference/signal-modifiers-sample-level-operators.ts new file mode 100644 index 0000000..1f48333 --- /dev/null +++ b/src/lib/csound-reference/signal-modifiers-sample-level-operators.ts @@ -0,0 +1,171 @@ +import type { CsoundReference } from './types' + +// Signal Modifiers:Sample Level Operators +export const signalModifiersSampleLevelOperators: CsoundReference[] = [ +{ + name: 'denorm', + type: 'opcode', + category: 'Signal Modifiers:Sample Level Operators', + description: 'Mixes low level (~1e-20 for floats, and ~1e-56 for doubles) noise to a list of a-rate signals.', + syntax: 'denorm(a1[, a2[, a3[, ... ]]])', + example: '--8<-- "examples/denorm.csd"', + seeAlso: ['Sample Level Operators'] +}, +{ + name: 'diff', + type: 'opcode', + category: 'Signal Modifiers:Sample Level Operators', + description: 'Modify a signal by differentiation.', + syntax: 'ares = diff(asig [, iskip])\n kres = diff(ksig [, iskip])', + example: '--8<-- "examples/diff.csd"', + rates: ['a-rate', 'k-rate'], + seeAlso: ['Sample Level Operators'] +}, +{ + name: 'downsamp', + type: 'opcode', + category: 'Signal Modifiers:Sample Level Operators', + description: 'Modify a signal by down-sampling.', + syntax: 'kres = downsamp(asig [, iwlen])', + example: '--8<-- "examples/downsamp.csd"', + rates: ['a-rate', 'k-rate'], + seeAlso: ['Sample Level Operators'] +}, +{ + name: 'fold', + type: 'opcode', + category: 'Signal Modifiers:Sample Level Operators', + description: 'Adds artificial foldover to an audio signal.', + syntax: 'ares = fold(asig, kincr)', + example: '--8<-- "examples/fold.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'asig', + description: 'input signal', + type: 'performance' + }, + { + name: 'kincr', + description: 'amount of foldover expressed in multiple of sampling rate. Must be >= 1', + type: 'performance' + }, + ], + seeAlso: ['Sample Level Operators'] +}, +{ + name: 'integ', + type: 'opcode', + category: 'Signal Modifiers:Sample Level Operators', + description: 'Modify a signal by integration.', + syntax: 'ares = integ(asig [, iskip])\n kres = integ(ksig [, iskip])', + example: '--8<-- "examples/integ.csd"', + rates: ['a-rate', 'k-rate'], + seeAlso: ['Sample Level Operators'] +}, +{ + name: 'interp', + type: 'opcode', + category: 'Signal Modifiers:Sample Level Operators', + description: 'Converts a control signal to an audio signal using linear interpolation.', + syntax: 'ares = interp(ksig [, iskip] [, imode] [, ivalue])', + example: '--8<-- "examples/interp.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'ksig', + description: 'input k-rate signal.', + type: 'performance' + }, + ], + seeAlso: ['Sample Level Operators', 'Csound Journal, issue10 - An Overview of Csound Variable Types'] +}, +{ + name: 'ntrpol', + type: 'opcode', + category: 'Signal Modifiers:Sample Level Operators', + description: 'Calculates the weighted mean value (i.e. linear interpolation) of two input signals.', + syntax: 'ares = ntrpol(asig1, asig2, kpoint [, imin] [, imax])\n ires = ntrpol(isig1, isig2, ipoint [, imin] [, imax])\n kres = ntrpol(ksig1, ksig2, kpoint [, imin] [, imax])', + example: '--8<-- "examples/ntrpol.csd"', + rates: ['a-rate', 'k-rate', 'i-rate'], + parameters: [ + { + name: 'imin', + description: 'minimum xpoint value (optional, default 0)', + type: 'initialization' + }, + { + name: 'imax', + description: 'maximum xpoint value (optional, default 1)', + type: 'initialization' + }, + { + name: 'xsig1', + description: 'input signals', + type: 'performance' + }, + { + name: 'xsig2', + description: 'input signals', + type: 'performance' + }, + { + name: 'xpoint', + description: 'interpolation point between the two values', + type: 'performance' + }, + ], + seeAlso: ['Sample Level Operators'] +}, +{ + name: 'opa', + type: 'opcode', + category: 'Signal Modifiers:Sample Level Operators', + description: 'Converts a k-sig or k-array parameter to an a-sig output.', + example: '--8<-- "examples/opa.csd"', + seeAlso: ['Sample Level Operators', 'Csound Journal, issue 10'] +}, +{ + name: 'opi', + type: 'opcode', + category: 'Signal Modifiers:Sample Level Operators', + description: 'Returns an init-type equivalent of a k-rate argument or array element or directly returns an i-rate argument.', + seeAlso: ['Sample Level Operators', 'Csound Journal, issue 10'] +}, +{ + name: 'opk', + type: 'opcode', + category: 'Signal Modifiers:Sample Level Operators', + description: 'Converts a i-rate parameter to an k-rate value or an a-rate value to a k-rate value by down-sampling.', + seeAlso: ['Sample Level Operators', 'Csound Journal, issue 10'] +}, +{ + name: 'ops', + type: 'opcode', + category: 'Signal Modifiers:Sample Level Operators', + description: 'Returns a string containg the numeric value of its argument.', + seeAlso: ['Sample Level Operators'] +}, +{ + name: 'samphold', + type: 'opcode', + category: 'Signal Modifiers:Sample Level Operators', + description: 'Performs a sample-and-hold operation on its input.', + syntax: 'ares = samphold(asig, agate [, ival] [, ivstor])\n kres = samphold(ksig, kgate [, ival] [, ivstor])', + example: 'asrc buzz 10000, 440, 20, 1 ; band-limited pulse train\nadif diff asrc ; emphasize the highs\nanew balance adif, asrc ; but retain the power\nagate reson asrc, 0, 440 ; use a lowpass of the original\nasamp samphold anew, agate ; to gate the new audiosig\naout tone asamp, 100 ; smooth out the rough edges', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'kgate', + description: 'controls whether to hold the signal.', + type: 'performance' + }, + { + name: 'xgate', + description: 'controls whether to hold the signal.', + type: 'performance' + }, + ], + seeAlso: ['Sample Level Operators'] +}, +] diff --git a/src/lib/csound-reference/signal-modifiers-signal-limiters.ts b/src/lib/csound-reference/signal-modifiers-signal-limiters.ts new file mode 100644 index 0000000..1903600 --- /dev/null +++ b/src/lib/csound-reference/signal-modifiers-signal-limiters.ts @@ -0,0 +1,89 @@ +import type { CsoundReference } from './types' + +// Signal Modifiers:Signal Limiters +export const signalModifiersSignalLimiters: CsoundReference[] = [ +{ + name: 'limit', + type: 'opcode', + category: 'Signal Modifiers:Signal Limiters', + description: 'Sets the lower and upper limits of the value it processes.', + syntax: 'ares = limit(asig, klow, khigh)\n ires = limit(isig, ilow, ihigh)\n kres = limit(ksig, klow, khigh)\n ires[] = limit(isig[], ilow, ihigh)\n kres[] = limit(ksig[], klow, khigh)\n )', + example: '--8<-- "examples/limit.csd"', + rates: ['a-rate', 'k-rate', 'i-rate'], + parameters: [ + { + name: 'isig', + description: 'input signal', + type: 'initialization' + }, + { + name: 'ilow', + description: 'low threshold', + type: 'initialization' + }, + { + name: 'ihigh', + description: 'high threshold', + type: 'initialization' + }, + { + name: 'xsig', + description: 'input signal', + type: 'performance' + }, + { + name: 'klow', + description: 'low threshold', + type: 'performance' + }, + { + name: 'khigh', + description: 'high threshold', + type: 'performance' + }, + ], + seeAlso: ['Signal Limiters', 'Array opcodes'] +}, +{ + name: 'mirror', + type: 'opcode', + category: 'Signal Modifiers:Signal Limiters', + description: 'Reflects the signal that exceeds the low and high thresholds.', + syntax: 'ares = mirror(asig, klow, khigh)\n ires = mirror(isig, ilow, ihigh)\n kres = mirror(ksig, klow, khigh)', + example: '--8<-- "examples/mirror.csd"', + rates: ['a-rate', 'k-rate', 'i-rate'], + parameters: [ + { + name: 'isig', + description: 'input signal', + type: 'initialization' + }, + { + name: 'ilow', + description: 'low threshold', + type: 'initialization' + }, + { + name: 'ihigh', + description: 'high threshold', + type: 'initialization' + }, + { + name: 'xsig', + description: 'input signal', + type: 'performance' + }, + { + name: 'klow', + description: 'low threshold', + type: 'performance' + }, + { + name: 'khigh', + description: 'high threshold', + type: 'performance' + }, + ], + seeAlso: ['Signal Limiters'] +}, +] diff --git a/src/lib/csound-reference/signal-modifiers-special-effects.ts b/src/lib/csound-reference/signal-modifiers-special-effects.ts new file mode 100644 index 0000000..d3ca960 --- /dev/null +++ b/src/lib/csound-reference/signal-modifiers-special-effects.ts @@ -0,0 +1,275 @@ +import type { CsoundReference } from './types' + +// Signal Modifiers:Special Effects +export const signalModifiersSpecialEffects: CsoundReference[] = [ +{ + name: 'distort', + type: 'opcode', + category: 'Signal Modifiers:Special Effects', + description: 'Distort an audio signal via waveshaping and optional clipping.', + syntax: 'ar = distort(asig, kdist, ifn[, ihp, istor])', + example: '--8<-- "examples/distort.csd"', + rates: ['a-rate', 'i-rate'], + parameters: [ + { + name: 'ifn', + description: 'table number of a waveshaping function with extended guard point. The function can be of any shape, but it should pass through 0 with positive slope at the table mid-point. The table size need not be large, since it is read with interpolation.', + type: 'initialization' + }, + { + name: 'ihp', + description: '(optional) half-power point (in cps) of an internal low-pass filter. The default value is 10.', + type: 'initialization' + }, + { + name: 'istor', + description: '(optional) initial disposition of internal data space (see reson). The default value is 0.', + type: 'initialization' + }, + { + name: 'asig', + description: 'Audio signal to be processed', + type: 'performance' + }, + { + name: 'kdist', + description: 'Amount of distortion (usually between 0 and 1)', + type: 'performance' + }, + ], + seeAlso: ['Special Effects', 'Waveshaping'] +}, +{ + name: 'distort1', + type: 'opcode', + category: 'Signal Modifiers:Special Effects', + description: 'Modified hyperbolic tangent distortion.', + syntax: 'ares = distort1(asig, kpregain, kpostgain, kshape1, kshape2[, imode])', + example: '--8<-- "examples/distort1.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'asig', + description: 'is the input signal.', + type: 'performance' + }, + { + name: 'kpregain', + description: 'determines the amount of gain applied to the signal before waveshaping. A value of 1 gives slight distortion.', + type: 'performance' + }, + { + name: 'kpostgain', + description: 'determines the amount of gain applied to the signal after waveshaping.', + type: 'performance' + }, + { + name: 'kshape1', + description: 'determines the shape of the positive part of the curve. A value of 0 gives a flat clip, small positive values give sloped shaping.', + type: 'performance' + }, + { + name: 'kshape2', + description: 'determines the shape of the negative part of the curve.', + type: 'performance' + }, + ], + seeAlso: ['Special Effects', 'Waveshaping'] +}, +{ + name: 'doppler', + type: 'opcode', + category: 'Signal Modifiers:Special Effects', + description: 'A fast and robust method for approximating sound propagation, achieving convincing Doppler shifts without having to solve equations.', + syntax: 'ashifted = doppler(asource, ksourceposition, kmicposition [, isoundspeed, \\\n ifiltercutoff])', + example: '--8<-- "examples/doppler.csd"', + parameters: [ + { + name: 'asource', + description: 'Input signal at the sound source.', + type: 'performance' + }, + { + name: 'ksourceposition', + description: 'Position of the source sound in meters. The distance between source and mic should not be changed faster than about 3/4 the speed of sound.', + type: 'performance' + }, + { + name: 'kmicposition', + description: 'Position of the recording microphone in meters. The distance between source and mic should not be changed faster than about 3/4 the speed of sound.', + type: 'performance' + }, + ], + seeAlso: ['Special Effects'] +}, +{ + name: 'flanger', + type: 'opcode', + category: 'Signal Modifiers:Special Effects', + description: 'A user controlled flanger.', + syntax: 'ares = flanger(asig, adel, kfeedback [, imaxd])', + example: '--8<-- "examples/flanger.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'asig', + description: 'input signal', + type: 'performance' + }, + { + name: 'adel', + description: 'delay in seconds', + type: 'performance' + }, + { + name: 'kfeedback', + description: 'feedback amount (in normal tasks this should not exceed 1, even if bigger values are allowed)', + type: 'performance' + }, + ], + seeAlso: ['Special Effects', 'http://en.wikipedia.org/wiki/Flanger'] +}, +{ + name: 'harmon', + type: 'opcode', + category: 'Signal Modifiers:Special Effects', + description: 'Analyze an audio input and generate harmonizing voices in synchrony.', + syntax: 'ares = harmon(asig, kestfrq, kmaxvar, kgenfreq1, kgenfreq2, imode, iminfrq, iprd)', + example: '--8<-- "examples/harmon.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'imode', + description: 'interpreting mode for the generating frequency inputs _kgenfreq1_, _kgenfreq2_. 0: input values are ratios with respect to the audio signal analyzed frequency. 1: input values are the actual requested frequencies in Hz.', + type: 'initialization' + }, + { + name: 'iminfrq', + description: 'the lowest expected frequency (in Hz) of the audio input. This parameter determines how much of the input is saved for the running analysis, and sets a lower bound on the internal pitch tracker.', + type: 'initialization' + }, + { + name: 'iprd', + description: 'period of analysis (in seconds). Since the internal pitch analysis can be time-consuming, the input is typically analyzed only each 20 to 50 milliseconds.', + type: 'initialization' + }, + { + name: 'kestfrq', + description: 'estimated frequency of the input.', + type: 'performance' + }, + { + name: 'kmaxvar', + description: 'the maximum variance (expects a value betwee 0 and 1).', + type: 'performance' + }, + { + name: 'kgenfreq1', + description: 'the first generated frequency.', + type: 'performance' + }, + { + name: 'kgenfreq2', + description: 'the second generated frequency.', + type: 'performance' + }, + ], + seeAlso: ['Special Effects'] +}, +{ + name: 'harmon2', + type: 'opcode', + category: 'Signal Modifiers:Special Effects', + description: 'Analyze an audio input and generate harmonizing voices in synchrony with formants preserved.', + syntax: 'ares = harmon2(asig, koct, kfrq1, kfrq2, icpsmode, ilowest[, ipolarity])\n ares = harmon3(asig, koct, kfrq1, kfrq2, kfrq3, icpsmode, ilowest[, ipolarity])\n ares = harmon4(asig, koct, kfrq1, kfrq2, kfrq3, kfrq4, icpsmode, ilowest \\\n [, ipolarity])', + example: 'a1,a2 ins ; get mic input\nw1 spectrum a1, .02, 7, 24, 12, 1, 3 ; and examine it\nkoct,kamp specptrk w1, 1, 6.5, 9.5, 7.5, 10, 7, .7, 0, 3, 1\na3 delay a1, .065 ; allow for ptrk delay\na4 harmon2 a3, koct, 1.25, 0.75, 0, 6.9 ; output a fixed 6-4 harmony\n outs a3, a4 ; as well as the original', + rates: ['a-rate'], + parameters: [ + { + name: 'icpsmode', + description: 'interpreting mode for the generating frequency inputs _kfrq1_, _kfrq2_, _kfrq3_ and _kfrq4_: 0: input values are ratios w.r.t. the cps equivalent of _koct_.1: input values are the actual requested frequencies in cps.', + type: 'initialization' + }, + { + name: 'ilowest', + description: 'lowest value of the _koct_ input for which harmonizing voices will be generated.', + type: 'initialization' + }, + { + name: 'ipolarity', + description: 'polarity of _asig_ input, 1 = positive glottal pulses, 0 = negative. Default is 1.', + type: 'initialization' + }, + ], + seeAlso: ['Special Effects'] +}, +{ + name: 'phaser1', + type: 'opcode', + category: 'Signal Modifiers:Special Effects', + description: 'First-order allpass filters arranged in a series.', + syntax: 'ares = phaser1(asig, kfreq, kord, kfeedback [, iskip])', + example: '--8<-- "examples/phaser1.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'kfreq', + description: 'frequency (in Hz) of the filter(s). This is the frequency at which each filter in the series shifts its input by 90 degrees.', + type: 'performance' + }, + { + name: 'kord', + description: 'the number of allpass stages in series. These are first-order filters and can range from 1 to 4999.', + type: 'performance' + }, + { + name: 'kfeedback', + description: 'amount of the output which is fed back into the input of the allpass chain. With larger amounts of feedback, more prominent notches appear in the spectrum of the output. _kfeedback_ must be between -1 and +1. for stability.', + type: 'performance' + }, + ], + seeAlso: ['Special Effects'] +}, +{ + name: 'phaser2', + type: 'opcode', + category: 'Signal Modifiers:Special Effects', + description: 'Second-order allpass filters arranged in a series.', + syntax: 'ares = phaser2(asig, kfreq, kq, kord, kmode, ksep, kfeedback)', + example: '--8<-- "examples/phaser2.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'kfreq', + description: 'frequency (in Hz) of the filter(s). This is the center frequency of the notch of the first allpass filter in the series. This frequency is used as the base frequency from which the frequencies of the other notches are derived.', + type: 'performance' + }, + { + name: 'kq', + description: 'Q of each notch. Higher Q values result in narrow notches. A Q between 0.5 and 1 results in the strongest "phasing" effect, but higher Q values can be used for special effects.', + type: 'performance' + }, + { + name: 'kord', + description: 'the number of allpass stages in series. These are second-order filters, and iord can range from 1 to 2499. With higher orders, the computation time increases.', + type: 'performance' + }, + { + name: 'kfeedback', + description: 'amount of the output which is fed back into the input of the allpass chain. With larger amounts of feedback, more prominent notches appear in the spectrum of the output. _kfeedback_ must be between -1 and +1. for stability.', + type: 'performance' + }, + { + name: 'kmode', + description: 'used in calculation of notch frequencies.', + type: 'performance' + }, + { + name: 'ksep', + description: 'scaling factor used, in conjunction with _imode_, to determine the frequencies of the additional notches in the output spectrum.', + type: 'performance' + }, + ], + seeAlso: ['Special Effects'] +}, +] diff --git a/src/lib/csound-reference/signal-modifiers-specialized-filters.ts b/src/lib/csound-reference/signal-modifiers-specialized-filters.ts new file mode 100644 index 0000000..fd2b019 --- /dev/null +++ b/src/lib/csound-reference/signal-modifiers-specialized-filters.ts @@ -0,0 +1,476 @@ +import type { CsoundReference } from './types' + +// Signal Modifiers:Specialized Filters +export const signalModifiersSpecializedFilters: CsoundReference[] = [ +{ + name: 'dcblock', + type: 'opcode', + category: 'Signal Modifiers:Specialized Filters', + description: 'Implements the DC blocking filter.', + syntax: 'ares = dcblock(ain [, igain])', + example: '--8<-- "examples/dcblock.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'igain', + description: 'the gain of the filter, which defaults to 0.99', + type: 'initialization' + }, + { + name: 'ain', + description: 'audio signal input', + type: 'performance' + }, + ], + seeAlso: ['Specialized Filters: High pass filters'] +}, +{ + name: 'dcblock2', + type: 'opcode', + category: 'Signal Modifiers:Specialized Filters', + description: 'Implements a DC blocking filter with improved DC attenuation.', + syntax: 'ares = dcblock2(ain [, iorder] [, iskip])', + example: '--8<-- "examples/dcblock2.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'iorder', + description: 'filter order, minimum 4th order, defaults to 128.', + type: 'initialization' + }, + { + name: 'iskip', + description: 'set to 1 to skip initialization (defaults to 0).', + type: 'initialization' + }, + { + name: 'ares', + description: 'filered audio signal', + type: 'performance' + }, + { + name: 'ain', + description: 'input audio signal', + type: 'performance' + }, + ], + seeAlso: ['Specialized Filters: High pass filters'] +}, +{ + name: 'eqfil', + type: 'opcode', + category: 'Signal Modifiers:Specialized Filters', + description: 'Equalizer filter.', + syntax: 'asig = eqfil(ain, kcf, kbw, kgain[, istor])', + example: '--8<-- "examples/eqfil.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'istor', + description: 'initial disposition of internal data space. Since filtering incorporates a feedback loop of previous output, the initial status of the storage space used is significant. A zero value will clear the space; a non-zero value will allow previous information to remain. The default value is 0.', + type: 'initialization' + }, + { + name: 'asig', + description: 'filtered output signal.', + type: 'performance' + }, + { + name: 'ain', + description: 'input signal.', + type: 'performance' + }, + { + name: 'kcf', + description: 'filter centre frequency.', + type: 'performance' + }, + { + name: 'kbw', + description: 'peak/notch bandwidth (Hz).', + type: 'performance' + }, + { + name: 'kgain', + description: 'peak/notch gain.', + type: 'performance' + }, + ], + seeAlso: ['Specialized Filters: Parametric EQ'] +}, +{ + name: 'exciter', + type: 'opcode', + category: 'Signal Modifiers:Specialized Filters', + description: 'A non-linear filter system to excite the signal.', + syntax: 'ares = exciter(asig, kfreq, kceil, kharmonics, kblend)', + example: '--8<-- "examples/exciter.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'asig', + description: 'input signal', + type: 'initialization' + }, + { + name: 'kfreq', + description: 'the lower end of the harmonics created.', + type: 'initialization' + }, + { + name: 'kceil', + description: 'the upper end of the harmonics created.', + type: 'initialization' + }, + { + name: 'kharmonics', + description: 'amount of harmonics in the range 0.1 - 10.', + type: 'initialization' + }, + { + name: 'kblend', + description: 'blend between 2nd and 3rd order harmonics in the range -10 - +10.', + type: 'initialization' + }, + { + name: 'asig', + description: 'input signal', + type: 'performance' + }, + { + name: 'kfreq', + description: 'the lower end of the harmonics created.', + type: 'performance' + }, + { + name: 'kceil', + description: 'the upper end of the harmonics created.', + type: 'performance' + }, + { + name: 'kharmonics', + description: 'amount of harmonics in the range 0.1 - 10.', + type: 'performance' + }, + { + name: 'kblend', + description: 'blend between 2nd and 3rd order harmonics in the range -10 - +10.', + type: 'performance' + }, + ], + seeAlso: ['Special Effects'] +}, +{ + name: 'filter2', + type: 'opcode', + category: 'Signal Modifiers:Specialized Filters', + description: 'General purpose custom filter.', + syntax: 'ares = filter2(asig, ibcoefs, iacoefs, ib0, ib1, ..., ibM, ia1, ia2, ..., iaN)\n kres = filter2(ksig, ibcoefs, iacoefs, ib0, ib1, ..., ibM, ia1, ia2, ..., iaN)', + example: 'k1 filter2 ksig, 2, 0, 0.5, 0.5 ;; k-rate FIR filter', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'ibcoefs', + description: 'number of feedforward coefficients including b0.', + type: 'initialization' + }, + { + name: 'iacoefs', + description: 'number of feedback coefficients', + type: 'initialization' + }, + ], + seeAlso: ['Specialized Filters: Other filters'] +}, +{ + name: 'fmanal', + type: 'opcode', + category: 'Signal Modifiers:Specialized Filters', + description: 'AM/FM analysis from quadrature signal.', + syntax: 'am, af = fmanal(are, aim)', + example: '--8<-- "examples/fmanal.csd"', + parameters: [ + { + name: 'are', + description: 'real (cosine-phase) input signal', + type: 'performance' + }, + { + name: 'aim', + description: 'imaginary (sine-phase) input signal', + type: 'performance' + }, + { + name: 'am', + description: 'amplitude modulation envelope', + type: 'performance' + }, + { + name: 'af', + description: 'frequency modulation envelope', + type: 'performance' + }, + ], + seeAlso: ['Specialized Filters: Other filters'] +}, +{ + name: 'fofilter', + type: 'opcode', + category: 'Signal Modifiers:Specialized Filters', + description: 'Formant filter.', + syntax: 'asig = fofilter(ain, xcf, xris, xdec[, istor])', + example: '--8<-- "examples/fofilter.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'istor', + description: 'initial disposition of internal data space. Since filtering incorporates a feedback loop of previous output, the initial status of the storage space used is significant. A zero value will clear the space; a non-zero value will allow previous information to remain. The default value is 0.', + type: 'initialization' + }, + { + name: 'asig', + description: 'input signal.', + type: 'performance' + }, + { + name: 'xcf', + description: 'filter centre frequency', + type: 'performance' + }, + { + name: 'xris', + description: 'impulse response attack time (secs).', + type: 'performance' + }, + { + name: 'xdec', + description: 'impulse response decay time (secs).', + type: 'performance' + }, + ], + seeAlso: ['Specialized Filters: Other filters'] +}, +{ + name: 'gtf', + type: 'opcode', + category: 'Signal Modifiers:Specialized Filters', + description: 'Apply a gammatone filter of various orders to an audio signal.', + syntax: 'aout = gtf(ain, kfreq, idecay[, iorder, iphase])', + example: '--8<-- "examples/gtf.csd"', + parameters: [ + { + name: 'idecay', + description: 'rate of decay', + type: 'initialization' + }, + { + name: 'iorder', + description: '(optional) Order of filter in rangs 1 to 10 defaulting to 4.', + type: 'initialization' + }, + { + name: 'iphase', + description: '(optional) Phase output, defaulting to zero.', + type: 'initialization' + }, + { + name: 'asig', + description: 'audio signal to be filtered.', + type: 'performance' + }, + { + name: 'kfreq', + description: 'central frequency of filter in Hertz.', + type: 'performance' + }, + ], + seeAlso: ['Specialized Filters: Other filters'] +}, +{ + name: 'hilbert', + type: 'opcode', + category: 'Signal Modifiers:Specialized Filters', + description: 'A Hilbert transformer.', + syntax: 'c:a, s:a = hilbert(sig:a)\n csig:Complex[] = hilbert(sig:a)', + example: '--8<-- "examples/hilbert.csd"', + parameters: [ + { + name: 'sig', + description: 'input signal', + type: 'performance' + }, + { + name: 'c', + description: 'cosine output of _sig_', + type: 'performance' + }, + { + name: 's', + description: 'sine output of _sig_', + type: 'performance' + }, + { + name: 'csig', + description: 'Complex array containing the analytic signal.', + type: 'performance' + }, + ], + seeAlso: ['Specialized Filters: Other filters'] +}, +{ + name: 'hilbert2', + type: 'opcode', + category: 'Signal Modifiers:Specialized Filters', + description: 'A DFT-based implementation of a Hilbert transformer.', + syntax: 'c:a, s:a = hilbert2(sig:a, fftsize:a, hopsize:i)\n csig:Complex[] = hilbert2(sig:a, fftsize:a, hopsize:i)', + example: '--8<-- "examples/hilbert2.csd"', + parameters: [ + { + name: 'sig', + description: 'input signal', + type: 'performance' + }, + { + name: 'c', + description: 'cosine output of _sig_', + type: 'performance' + }, + { + name: 's', + description: 'sine output of _sig_', + type: 'performance' + }, + { + name: 'csig', + description: 'Complex array containing the analytic signal.', + type: 'performance' + }, + ], + seeAlso: ['Specialized Filters: Other filters'] +}, +{ + name: 'mvmfilter', + type: 'opcode', + category: 'Signal Modifiers:Specialized Filters', + description: 'A filter with pronounced resonance and controllable decay time.', + syntax: 'aout = mvmfilter(ain, xfreq, xTau [, iskip])', + example: '--8<-- "examples/mvmfilter.csd"', + parameters: [ + { + name: 'aout', + description: 'filtered signal', + type: 'performance' + }, + { + name: 'ain', + description: 'signal to filter', + type: 'performance' + }, + { + name: 'xfreq', + description: 'resonant frequency of the filter', + type: 'performance' + }, + { + name: 'xTau', + description: 'Decay time of the filter in seconds', + type: 'performance' + }, + ], + seeAlso: ['Specialized Filters: Other filters', '"Very High Q Parametrically WellBehaved Two Pole Filters"'] +}, +{ + name: 'nlfilt', + type: 'opcode', + category: 'Signal Modifiers:Specialized Filters', + description: 'A filter with a non-linear effect.', + syntax: 'ares = nlfilt(ain, ka, kb, kd, kC, kL)', + example: '--8<-- "examples/nlfilt.csd"', + rates: ['a-rate'], + seeAlso: ['Specialized Filters: Other filters'] +}, +{ + name: 'nlfilt2', + type: 'opcode', + category: 'Signal Modifiers:Specialized Filters', + description: 'A filter with a non-linear effect and blowup protection.', + syntax: 'ares = nlfilt2(ain, ka, kb, kd, kC, kL)', + example: '--8<-- "examples/nlfilt2.csd"', + rates: ['a-rate'], + seeAlso: ['Specialized Filters: Other filters'] +}, +{ + name: 'pareq', + type: 'opcode', + category: 'Signal Modifiers:Specialized Filters', + description: 'Implementation of Zoelzer\'s parametric equalizer filters, with some modifications by the author.', + syntax: 'ares = pareq(asig, kc, kv, kq [, imode] [, iskip])', + example: '--8<-- "examples/pareq.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'kc', + description: 'center frequency in peaking mode, corner frequency in shelving mode.', + type: 'performance' + }, + { + name: 'kv', + description: 'amount of boost or cut. A value less than 1 is a cut. A value greater than 1 is a boost. A value of 1 is a flat response.', + type: 'performance' + }, + { + name: 'kq', + description: 'Q of the filter (sqrt(.5) is no resonance)', + type: 'performance' + }, + { + name: 'asig', + description: 'the incoming signal', + type: 'performance' + }, + ], + seeAlso: ['Specialized Filters: Parametric EQ'] +}, +{ + name: 'rbjeq', + type: 'opcode', + category: 'Signal Modifiers:Specialized Filters', + description: 'Parametric equalizer and filter opcode with 7 filter types, based on algorithm by Robert Bristow-Johnson.', + syntax: 'ar = rbjeq(asig, kfco, klvl, kQ, kS[, imode])', + example: '--8<-- "examples/rbjeq.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'ar', + description: 'the output signal.', + type: 'performance' + }, + { + name: 'asig', + description: 'the input signal', + type: 'performance' + }, + { + name: 'kfco', + description: 'cutoff, corner, or center frequency, depending on filter type, in Hz. It must be greater than zero, and less than sr / 2 (the range of about sr * 0.0002 to sr * 0.49 should be safe).', + type: 'performance' + }, + { + name: 'klvl', + description: 'level (amount of boost or cut), as amplitude gain (e.g. 1: flat response, 4: 12 dB boost, 0.1: 20 dB cut); zero or negative values are not allowed. It is recognized by the peaking and shelving EQ types (8, 10, 12) only, and is ignored by other filters.', + type: 'performance' + }, + { + name: 'kQ', + description: 'resonance (also kfco / bandwidth in many filter types). Not used by the shelving EQs (imode = 10 and 12). The exact meaning of this parameter depends on the filter type (see above), but it should be always greater than zero, and usually (kfco / kQ) less than sr / 2.', + type: 'performance' + }, + { + name: 'kS', + description: 'shelf slope parameter for shelving filters. Must be greater than zero; a higher value means a steeper slope, with resonance if kS > 1 (however, a too high kS value may make the filter unstable). If kS is set to exactly 1, the shelf slope is as steep as possible without a resonance. Note that the effect of kS - especially if it is greater than 1 - also depends on klvl, and it does not have any well defined unit.', + type: 'performance' + }, + ], + seeAlso: ['Specialized Filters: Parametric EQ'] +}, +] diff --git a/src/lib/csound-reference/signal-modifiers-standard-filters-control.ts b/src/lib/csound-reference/signal-modifiers-standard-filters-control.ts new file mode 100644 index 0000000..36810e2 --- /dev/null +++ b/src/lib/csound-reference/signal-modifiers-standard-filters-control.ts @@ -0,0 +1,268 @@ +import type { CsoundReference } from './types' + +// Signal Modifiers:Standard Filters:Control +export const signalModifiersStandardFiltersControl: CsoundReference[] = [ +{ + name: 'aresonk', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters:Control', + description: 'A notch filter whose transfer functions are the complements of the reson opcode.', + syntax: 'kres = aresonk(ksig, kcf, kbw [, iscl] [, iskip])', + example: '--8<-- "examples/aresonk-modern.csd"', + rates: ['k-rate'], + parameters: [ + { + name: 'kres', + description: 'the output signal at control-rate.', + type: 'performance' + }, + { + name: 'ksig', + description: 'the input signal at control-rate.', + type: 'performance' + }, + { + name: 'kcf', + description: 'the center frequency of the filter, or frequency position of the peak response.', + type: 'performance' + }, + { + name: 'kbw', + description: 'bandwidth of the filter (the Hz difference between the upper and lower half-power points).', + type: 'performance' + }, + ], + seeAlso: ['Standard Filters: Control signal filters'] +}, +{ + name: 'atonek', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters:Control', + description: 'A hi-pass filter whose transfer functions are the complements of the [tonek](../opcodes/tonek.md) opcode.', + syntax: 'kres = atonek(ksig, khp [, iskip])', + example: '--8<-- "examples/atonek-modern.csd"', + rates: ['k-rate'], + parameters: [ + { + name: 'kres', + description: 'the output signal at control-rate.', + type: 'performance' + }, + { + name: 'ksig', + description: 'the input signal at control-rate.', + type: 'performance' + }, + { + name: 'khp', + description: 'the response curve\'s half-power point, in Hertz. Half power is defined as peak power / root 2.', + type: 'performance' + }, + ], + seeAlso: ['Standard Filters: Control signal filters'] +}, +{ + name: 'lag', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters:Control', + description: 'Exponential Lag.', + syntax: 'aout = lag(ain, klagtime [, initialvalue])\n kout = lag(kin, klagtime [, initialvalue])', + example: '--8<-- "examples/lag.csd"', + rates: ['k-rate'], + parameters: [ + { + name: 'ain', + description: 'input signal', + type: 'performance' + }, + { + name: 'klagtime', + description: '60 dB lag time in seconds.', + type: 'performance' + }, + { + name: 'kladown', + description: '60 dB lag time in seconds for the downgoing signal.', + type: 'performance' + }, + ], + seeAlso: ['Standard Filters: Control signal filters'] +}, +{ + name: 'lagud', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters:Control', + description: 'Exponential Lag.', + syntax: 'aout = lagud(ain, klagup, klagdown [, initialvalue])\n kout = lagud(kin, klagup, klagdown [, initialvalue])', + example: '--8<-- "examples/lagud.csd"', + rates: ['k-rate'], + parameters: [ + { + name: 'ain', + description: 'input signal', + type: 'performance' + }, + { + name: 'klagup', + description: '60 dB lag time in seconds for the upgoing signal.', + type: 'performance' + }, + { + name: 'klagdown', + description: '60 dB lag time in seconds for the downgoing signal.', + type: 'performance' + }, + ], + seeAlso: ['Standard Filters: Control signal filters'] +}, +{ + name: 'lineto', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters:Control', + description: 'Generate glissandos starting from a control signal.', + syntax: 'kres = lineto(ksig, ktime)', + example: '--8<-- "examples/lineto.csd"', + rates: ['k-rate'], + parameters: [ + { + name: 'kres', + description: 'Output signal.', + type: 'performance' + }, + { + name: 'ksig', + description: 'Input signal.', + type: 'performance' + }, + { + name: 'ktime', + description: 'Time length of glissando in seconds.', + type: 'performance' + }, + ], + seeAlso: ['Standard Filters: Control signal filters'] +}, +{ + name: 'port', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters:Control', + description: 'Applies portamento to a step-valued control signal.', + syntax: 'kres = port(ksig, ihtim [, isig])', + example: '--8<-- "examples/port.csd"', + rates: ['k-rate'], + parameters: [ + { + name: 'ihtim', + description: 'half-time of the function, in seconds.', + type: 'initialization' + }, + { + name: 'kres', + description: 'the output signal at control-rate.', + type: 'performance' + }, + { + name: 'ksig', + description: 'the input signal at control-rate.', + type: 'performance' + }, + ], + seeAlso: ['Standard Filters: Control signal filters'] +}, +{ + name: 'portk', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters:Control', + description: 'Applies portamento to a step-valued control signal.', + syntax: 'kres = portk(ksig, khtim [, isig])', + example: '--8<-- "examples/portk.csd"', + rates: ['k-rate'], + parameters: [ + { + name: 'kres', + description: 'the output signal at control-rate.', + type: 'performance' + }, + { + name: 'ksig', + description: 'the input signal at control-rate.', + type: 'performance' + }, + { + name: 'khtim', + description: 'half-time of the function in seconds.', + type: 'performance' + }, + ], + seeAlso: ['Standard Filters: Control signal filters'] +}, +{ + name: 'resonk', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters:Control', + description: 'A second-order resonant filter.', + syntax: 'kres = resonk(ksig, kcf, kbw [, iscl] [, iskip])', + example: '--8<-- "examples/resonk.csd"', + rates: ['k-rate'], + parameters: [ + { + name: 'kres', + description: 'the output signal at control-rate.', + type: 'performance' + }, + { + name: 'ksig', + description: 'the input signal at control-rate.', + type: 'performance' + }, + { + name: 'kcf', + description: 'the center frequency of the filter, or frequency position of the peak response.', + type: 'performance' + }, + { + name: 'kbw', + description: 'bandwidth of the filter (the Hz difference between the upper and lower half-power points).', + type: 'performance' + }, + ], + seeAlso: ['Standard Filters: Control signal filters'] +}, +{ + name: 'resonxk', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters:Control', + description: 'Control signal resonant filter stack.', + syntax: 'kres = resonxk(ksig, kcf, kbw[, inumlayer, iscl, istor])', + example: '--8<-- "examples/resonxk.csd"', + rates: ['k-rate'], + parameters: [ + { + name: 'inumlayer', + description: 'number of elements of filter stack. Default value is 4. Maximum value is 10', + type: 'initialization' + }, + { + name: 'kres', + description: 'output signal', + type: 'performance' + }, + { + name: 'ksig', + description: 'input signal', + type: 'performance' + }, + { + name: 'kcf', + description: 'the center frequency of the filter, or frequency position of the peak response.', + type: 'performance' + }, + { + name: 'kbw', + description: 'bandwidth of the filter (the Hz difference between the upper and lower half-power points)', + type: 'performance' + }, + ], + seeAlso: ['Standard Filters: Control signal filters'] +}, +] diff --git a/src/lib/csound-reference/signal-modifiers-standard-filters-resonant.ts b/src/lib/csound-reference/signal-modifiers-standard-filters-resonant.ts new file mode 100644 index 0000000..83e5f83 --- /dev/null +++ b/src/lib/csound-reference/signal-modifiers-standard-filters-resonant.ts @@ -0,0 +1,929 @@ +import type { CsoundReference } from './types' + +// Signal Modifiers:Standard Filters:Resonant +export const signalModifiersStandardFiltersResonant: CsoundReference[] = [ +{ + name: 'areson', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters:Resonant', + description: 'A notch filter whose transfer functions are the complements of the reson opcode.', + syntax: 'ares = areson(asig, kcf, kbw [, iscl] [, iskip])\n ares = areson(asig, acf, kbw [, iscl] [, iskip])\n ares = areson(asig, kcf, abw [, iscl] [, iskip])\n ares = areson(asig, acf, abw [, iscl] [, iskip])', + example: '--8<-- "examples/areson-modern.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'ares', + description: 'the output signal at audio rate.', + type: 'performance' + }, + { + name: 'asig', + description: 'the input signal at audio rate.', + type: 'performance' + }, + { + name: 'kcf', + description: 'the center frequency of the filter, or frequency position of the peak response.', + type: 'performance' + }, + { + name: 'acf', + description: 'the center frequency of the filter, or frequency position of the peak response.', + type: 'performance' + }, + { + name: 'kbw', + description: 'bandwidth of the filter (the Hz difference between the upper and lower half-power points).', + type: 'performance' + }, + { + name: 'abw', + description: 'bandwidth of the filter (the Hz difference between the upper and lower half-power points).', + type: 'performance' + }, + ], + seeAlso: ['Standard Filters: Resonant Low-pass filters'] +}, +{ + name: 'bob', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters:Resonant', + description: 'Runge-Kutte numerical simulation of the Moog analog resonant filter.', + syntax: 'asig = bob(ain, xcf, xres, xsat [, iosamps, istor])', + example: '--8<-- "examples/bob-modern.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'iosamps', + description: 'number of times of oversampling used in the filtering process. This will determine the maximum sharpness of the filter resonance (Q). More oversampling allows higher Qs, less oversampling will limit the resonance. The default is 2 times (iosamps=0).', + type: 'initialization' + }, + { + name: 'istor', + description: 'initial disposition of internal data space. Since filtering incorporates a feedback loop of previous output, the initial status of the storage space used is significant. A zero value will clear the space; a non-zero value will allow previous information to remain. The default value is 0.', + type: 'initialization' + }, + { + name: 'asig', + description: 'input signal', + type: 'performance' + }, + { + name: 'xcf', + description: 'filter cutoff frequency', + type: 'performance' + }, + { + name: 'xres', + description: 'filter resonance. Nominally, a value of 4 should be the limit of stability -- above that, the filter oscillates.', + type: 'performance' + }, + { + name: 'xsat', + description: 'saturation. This parameter determines at what signal level the "transistors" in the model saturate. The maximum output amplitude is about 2/3 of that value.', + type: 'performance' + }, + ], + seeAlso: ['Standard Filters: Resonant Low-pass filters'] +}, +{ + name: 'bqrez', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters:Resonant', + description: 'A second-order multi-mode filter.', + syntax: 'ares = bqrez(asig, xfco, xres [, imode] [, iskip])', + example: '--8<-- "examples/bqrez-modern.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'ares', + description: 'output audio signal.', + type: 'performance' + }, + { + name: 'asig', + description: 'input audio signal.', + type: 'performance' + }, + { + name: 'xfco', + description: 'filter cut-off frequency in Hz. May be i-time, k-rate, a-rate.', + type: 'performance' + }, + { + name: 'xres', + description: 'amount of resonance. Values of 1 to 100 are typical. Resonance should be one or greater. A value of 100 gives a 20dB gain at the cutoff frequency. May be i-time, k-rate, a-rate.', + type: 'performance' + }, + ], + seeAlso: ['Standard Filters: Resonant Low-pass filters'] +}, +{ + name: 'lowpass2', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters:Resonant', + description: 'A resonant second-order lowpass filter.', + syntax: 'ares = lowpass2(asig, kcf, kq [, iskip])', + example: '--8<-- "examples/lowpass2.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'iskip', + description: 'initial disposition of internal data space. A zero value will clear the space; a non-zero value will allow previous information to remain. The default value is 0.', + type: 'initialization' + }, + { + name: 'asig', + description: 'input signal to be filtered', + type: 'performance' + }, + { + name: 'kcf', + description: 'cutoff or resonant frequency of the filter, measured in Hz', + type: 'performance' + }, + { + name: 'kq', + description: 'Q of the filter, defined, for bandpass filters, as bandwidth/cutoff. _kq_ should be between 1 and 500', + type: 'performance' + }, + ], + seeAlso: ['Standard Filters: Resonant Low-pass filters'] +}, +{ + name: 'lowres', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters:Resonant', + description: 'Another resonant lowpass filter.', + syntax: 'ares = lowres(asig, xcutoff, xresonance [, iskip])', + example: '--8<-- "examples/lowres.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'iskip', + description: 'initial disposition of internal data space. A zero value will clear the space; a non-zero value will allow previous information to remain. The default value is 0.', + type: 'initialization' + }, + { + name: 'asig', + description: 'input signal', + type: 'performance' + }, + { + name: 'xcutoff', + description: 'filter cutoff frequency point', + type: 'performance' + }, + { + name: 'xresonance', + description: 'resonance amount', + type: 'performance' + }, + ], + seeAlso: ['Standard Filters: Resonant Low-pass filters'] +}, +{ + name: 'lowresx', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters:Resonant', + description: 'Simulates layers of serially connected resonant lowpass filters.', + syntax: 'ares = lowresx(asig, xcutoff, xresonance [, inumlayer] [, iskip])', + example: '--8<-- "examples/lowresx.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'inumlayer', + description: 'number of elements in a _lowresx_ stack. Default value is 4. There is no maximum.', + type: 'initialization' + }, + { + name: 'iskip', + description: 'initial disposition of internal data space. A zero value will clear the space; a non-zero value will allow previous information to remain. The default value is 0.', + type: 'initialization' + }, + { + name: 'asig', + description: 'input signal', + type: 'performance' + }, + { + name: 'xcutoff', + description: 'filter cutoff frequency point', + type: 'performance' + }, + { + name: 'xresonance', + description: 'resonance amount', + type: 'performance' + }, + ], + seeAlso: ['Standard Filters: Resonant Low-pass filters'] +}, +{ + name: 'lpf18', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters:Resonant', + description: 'A 3-pole sweepable resonant lowpass filter.', + syntax: 'ares = lpf18(asig, xfco, xres, xdist [, iskip])', + example: '--8<-- "examples/lpf18.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'xfco', + description: 'the filter cutoff frequency in Hz. Should be in the range 0 to _sr_/2.', + type: 'performance' + }, + { + name: 'xres', + description: 'the amount of resonance. Self-oscillation occurs when _xres_ is approximately 1. Should usually be in the range 0 to 1, however, values slightly greater than 1 are possible for more sustained oscillation and an “overdrive” effect.', + type: 'performance' + }, + { + name: 'xdist', + description: 'amount of distortion. _kdist_ = 0 gives a clean output. _xdist_ > 0 adds _tanh_() distortion controlled by the filter parameters, in such a way that both low cutoff and high resonance increase the distortion amount. Some experimentation is encouraged.', + type: 'performance' + }, + ], + seeAlso: ['Standard Filters: Resonant Low-pass filters'] +}, +{ + name: 'moogladder', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters:Resonant', + description: 'Moog ladder lowpass filter.', + syntax: 'asig = moogladder(ain, kcf, kres[, istor])\n asig = moogladder(ain, acf, kres[, istor])\n asig = moogladder(ain, kcf, ares[, istor])\n asig = moogladder(ain, acf, ares[, istor])', + example: '--8<-- "examples/moogladder.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'istor', + description: 'initial disposition of internal data space. Since filtering incorporates a feedback loop of previous output, the initial status of the storage space used is significant. A zero value will clear the space; a non-zero value will allow previous information to remain. The default value is 0.', + type: 'initialization' + }, + { + name: 'asig', + description: 'input signal.', + type: 'performance' + }, + { + name: 'kcf', + description: 'filter cutoff frequency', + type: 'performance' + }, + { + name: 'acf', + description: 'filter cutoff frequency', + type: 'performance' + }, + { + name: 'kres', + description: 'resonance, generally < 1, but not limited to it. Higher than 1 resonance values might cause aliasing, analogue synths generally allow resonances to be above 1.', + type: 'performance' + }, + { + name: 'ares', + description: 'resonance, generally < 1, but not limited to it. Higher than 1 resonance values might cause aliasing, analogue synths generally allow resonances to be above 1.', + type: 'performance' + }, + ], + seeAlso: ['Standard Filters: Resonant Low-pass filters'] +}, +{ + name: 'moogladder2', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters:Resonant', + description: 'Moog ladder lowpass filter.', + syntax: 'asig = moogladder2(ain, kcf, kres[, istor])\n asig = moogladder2(ain, acf, kres[, istor])\n asig = moogladder2(ain, kcf, ares[, istor])\n asig = moogladder2(ain, acf, ares[, istor])', + example: '--8<-- "examples/moogladder2.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'istor', + description: 'initial disposition of internal data space. Since filtering incorporates a feedback loop of previous output, the initial status of the storage space used is significant. A zero value will clear the space; a non-zero value will allow previous information to remain. The default value is 0.', + type: 'initialization' + }, + { + name: 'asig', + description: 'input signal.', + type: 'performance' + }, + { + name: 'kcf', + description: 'filter cutoff frequency', + type: 'performance' + }, + { + name: 'acf', + description: 'filter cutoff frequency', + type: 'performance' + }, + { + name: 'kres', + description: 'resonance, generally < 1, but not limited to it. Higher than 1 resonance values might cause aliasing, analogue synths generally allow resonances to be above 1.', + type: 'performance' + }, + { + name: 'ares', + description: 'resonance, generally < 1, but not limited to it. Higher than 1 resonance values might cause aliasing, analogue synths generally allow resonances to be above 1.', + type: 'performance' + }, + ], + seeAlso: ['Standard Filters: Resonant Low-pass filters'] +}, +{ + name: 'moogvcf', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters:Resonant', + description: 'A digital emulation of the Moog diode ladder filter configuration.', + syntax: 'ares = moogvcf(asig, xfco, xres [,iscale, iskip])', + example: '--8<-- "examples/moogvcf.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'asig', + description: 'input signal', + type: 'performance' + }, + { + name: 'xfco', + description: 'filter cut-off frequency in Hz. As of version 3.50, may i-,k-, or a-rate.', + type: 'performance' + }, + { + name: 'xres', + description: 'amount of resonance. Self-oscillation occurs when _xres_ is approximately one. As of version 3.50, may a-rate, i-rate, or k-rate.', + type: 'performance' + }, + ], + seeAlso: ['Standard Filters: Resonant Low-pass filters'] +}, +{ + name: 'moogvcf2', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters:Resonant', + description: 'A digital emulation of the Moog diode ladder filter configuration.', + syntax: 'ares = moogvcf2(asig, xfco, xres [,iscale, iskip])', + example: '--8<-- "examples/moogvcf2.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'asig', + description: 'input signal', + type: 'performance' + }, + { + name: 'xfco', + description: 'filter cut-off frequency in Hz. which may be i-,k-, or a-rate.', + type: 'performance' + }, + { + name: 'xres', + description: 'amount of resonance. Self-oscillation occurs when _xres_ is approximately one. May be a-rate, i-rate, or k-rate.', + type: 'performance' + }, + ], + seeAlso: ['Standard Filters: Resonant Low-pass filters'] +}, +{ + name: 'mvchpf', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters:Resonant', + description: 'Moog voltage-controlled highpass filter emulation.', + syntax: 'asig = mvchpf(ain, xcf[, istor])', + example: '--8<-- "examples/mvchpf.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'istor', + description: 'initial disposition of internal data space. Since filtering incorporates a feedback loop of previous output, the initial status of the storage space used is significant. A zero value will clear the space; a non-zero value will allow previous information to remain. The default value is 0.', + type: 'initialization' + }, + { + name: 'ain', + description: 'input signal.', + type: 'performance' + }, + { + name: 'xcf', + description: 'filter cutoff frequency. The useful range is around six octaves below and above middle C (pch 8.00).', + type: 'performance' + }, + ], + seeAlso: ['Standard Filters: Hi-pass filters'] +}, +{ + name: 'mvclpf1', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters:Resonant', + description: 'Moog voltage-controlled lowpass filter emulation.', + syntax: 'asig = mvclpf1(ain, xcf, xres[,istor])', + example: '--8<-- "examples/mvclpf1.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'istor', + description: 'initial disposition of internal data space. Since filtering incorporates a feedback loop of previous output, the initial status of the storage space used is significant. A zero value will clear the space; a non-zero value will allow previous information to remain. The default value is 0.', + type: 'initialization' + }, + { + name: 'ain', + description: 'input signal.', + type: 'performance' + }, + { + name: 'xcf', + description: 'filter cutoff frequency. The useful range is around six octaves below and above middle C (pch 8.00).', + type: 'performance' + }, + { + name: 'xres', + description: 'resonance, limited to the interval [0,1].', + type: 'performance' + }, + ], + seeAlso: ['Standard Filters: Resonant Low-pass filters'] +}, +{ + name: 'mvclpf2', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters:Resonant', + description: 'Moog voltage-controlled lowpass filter emulation.', + syntax: 'asig = mvclpf2(ain, xcf, xres[, istor])', + example: '--8<-- "examples/mvclpf2.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'istor', + description: 'initial disposition of internal data space. Since filtering incorporates a feedback loop of previous output, the initial status of the storage space used is significant. A zero value will clear the space; a non-zero value will allow previous information to remain. The default value is 0.', + type: 'initialization' + }, + { + name: 'ain', + description: 'input signal.', + type: 'performance' + }, + { + name: 'xcf', + description: 'filter cutoff frequency. The useful range is around six octaves below and above middle C (pch 8.00).', + type: 'performance' + }, + { + name: 'xres', + description: 'resonance, limited to the interval [0,1].', + type: 'performance' + }, + ], + seeAlso: ['Standard Filters: Resonant Low-pass filters'] +}, +{ + name: 'mvclpf3', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters:Resonant', + description: 'Moog voltage-controlled lowpass filter emulation.', + syntax: 'asig = mvclpf3(ain, xcf, xres[, istor])', + example: '--8<-- "examples/mvclpf3.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'istor', + description: 'initial disposition of internal data space. Since filtering incorporates a feedback loop of previous output, the initial status of the storage space used is significant. A zero value will clear the space; a non-zero value will allow previous information to remain. The default value is 0.', + type: 'initialization' + }, + { + name: 'ain', + description: 'input signal.', + type: 'performance' + }, + { + name: 'xcf', + description: 'filter cutoff frequency. The useful range is around six octaves below and above middle C (pch 8.00).', + type: 'performance' + }, + { + name: 'xres', + description: 'resonance, limited to the interval [0,1].', + type: 'performance' + }, + ], + seeAlso: ['Standard Filters: Resonant Low-pass filters'] +}, +{ + name: 'mvclpf4', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters:Resonant', + description: 'Moog voltage-controlled lowpass filter emulation.', + syntax: 'asig1, asig2, asig3, asig4 = mvclpf4(ain, xcf, xres[, istor])', + example: '--8<-- "examples/mvclpf4.csd"', + parameters: [ + { + name: 'istor', + description: 'initial disposition of internal data space. Since filtering incorporates a feedback loop of previous output, the initial status of the storage space used is significant. A zero value will clear the space; a non-zero value will allow previous information to remain. The default value is 0.', + type: 'initialization' + }, + { + name: 'asig1', + description: '6dB/oct low-pass response output.', + type: 'performance' + }, + { + name: 'asig2', + description: '12dB/oct low-pass response output.', + type: 'performance' + }, + { + name: 'asig3', + description: '18dB/oct low-pass response output..', + type: 'performance' + }, + { + name: 'asig4', + description: '24dB/oct low-pass response output.', + type: 'performance' + }, + { + name: 'ain', + description: 'input signal.', + type: 'performance' + }, + { + name: 'xcf', + description: 'filter cutoff frequency. The useful range is around six octaves below and above middle C (pch 8.00).', + type: 'performance' + }, + { + name: 'xres', + description: 'resonance, limited to the interval [0,1].', + type: 'performance' + }, + ], + seeAlso: ['Standard Filters: Resonant Low-pass filters'] +}, +{ + name: 'otafilter', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters:Resonant', + description: 'Resonant 4pole non-linear lowpass filter.', + syntax: 'sig4:a, sig2:a = otafilter(in:a, cf:{a,k}, res:{a,k}, drive:k[, stor:i])', + example: '--8<-- "examples/otafilter.csd"', + parameters: [ + { + name: 'stor', + description: 'initial disposition of internal data space. Since filtering incorporates a feedback loop of previous output, the initial status of the storage space used is significant. A zero value will clear the space; a non-zero value will allow previous information to remain. The default value is 0.', + type: 'initialization' + }, + { + name: 'sig4', + description: '4-pole output', + type: 'performance' + }, + { + name: 'sig2', + description: '2-pole output', + type: 'performance' + }, + { + name: 'in', + description: 'input signal.', + type: 'performance' + }, + { + name: 'cf', + description: 'filter cutoff frequency (a- or k-rate)', + type: 'performance' + }, + { + name: 'res', + description: 'resonance, between 0 and 1. Higher values will make the filter self-oscillate (a- or k-rate).', + type: 'performance' + }, + { + name: 'drive', + description: 'filter drive gain (0 - no drive, > 0 - increased drive)', + type: 'performance' + }, + ], + seeAlso: ['Standard Filters: Resonant Low-pass filters'] +}, +{ + name: 'reson', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters:Resonant', + description: 'A second-order resonant filter.', + syntax: 'ares = reson(asig, xcf, xbw [, iscl] [, iskip])', + example: '--8<-- "examples/reson.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'ares', + description: 'the output signal at audio rate.', + type: 'performance' + }, + { + name: 'asig', + description: 'the input signal at audio rate.', + type: 'performance' + }, + { + name: 'xcf', + description: 'the center frequency of the filter, or frequency position of the peak response.', + type: 'performance' + }, + { + name: 'xbw', + description: 'bandwidth of the filter (the Hz difference between the upper and lower half-power points).', + type: 'performance' + }, + ], + seeAlso: ['Standard Filters: Resonant Low-pass filters'] +}, +{ + name: 'resonr', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters:Resonant', + description: 'A second-order, two-pole two-zero bandpass filter with variable frequency response.', + syntax: 'ares = resonr(asig, xcf, xbw [, iscl] [, iskip])', + example: '--8<-- "examples/resonr.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'asig', + description: 'input signal to be filtered', + type: 'performance' + }, + { + name: 'xcf', + description: 'cutoff or resonant frequency of the filter, measured in Hz', + type: 'performance' + }, + { + name: 'xbw', + description: 'bandwidth of the filter (the Hz difference between the upper and lower half-power points)', + type: 'performance' + }, + ], + seeAlso: ['Standard Filters: Resonant Low-pass filters'] +}, +{ + name: 'resonx', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters:Resonant', + description: 'Emulates a stack of filters using the reson opcode.', + syntax: 'ares = resonx(asig, xcf, xbw [, inumlayer] [, iscl] [, iskip])', + example: '--8<-- "examples/resonx.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'asig', + description: 'input signal', + type: 'performance' + }, + { + name: 'xcf', + description: 'the center frequency of the filter, or frequency position of the peak response.', + type: 'performance' + }, + { + name: 'xbw', + description: 'bandwidth of the filter (the Hz difference between the upper and lower half-power points)', + type: 'performance' + }, + ], + seeAlso: ['Standard Filters: Resonant Low-pass filters'] +}, +{ + name: 'resony', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters:Resonant', + description: 'A bank of second-order bandpass filters, connected in parallel.', + syntax: 'ares = resony(asig, kbf, kbw, inum, ksep [, isepmode] [, iscl] [, iskip])', + example: '--8<-- "examples/resony.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'inum', + description: 'number of filters', + type: 'initialization' + }, + { + name: 'asig', + description: 'audio input signal', + type: 'performance' + }, + { + name: 'kbf', + description: 'base frequency, i.e. center frequency of lowest filter in Hz', + type: 'performance' + }, + { + name: 'kbw', + description: 'bandwidth in Hz', + type: 'performance' + }, + { + name: 'ksep', + description: 'separation of the center frequency of filters in octaves', + type: 'performance' + }, + ], + seeAlso: ['Standard Filters: Resonant Low-pass filters'] +}, +{ + name: 'resonz', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters:Resonant', + description: 'A second-order, two-pole two-zero bandpass filter with variable frequency response.', + syntax: 'ares = resonz(asig, xcf, xbw [, iscl] [, iskip])', + example: '--8<-- "examples/resonr.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'iskip', + description: 'initial disposition of internal data space. Since filtering incorporates a feedback loop of previous output, the initial status of the storage space used is significant. A zero value will clear the space; a non-zero value will allow previous information to remain. The default value is 0.', + type: 'initialization' + }, + { + name: 'iscl', + description: 'coded scaling factor for resonators. A value of 1 signifies a peak response factor of 1, i.e. all frequencies other than _kcf_ are attenuated in accordance with the (normalized) response curve. A value of 2 raises the response factor so that its overall RMS value equals 1. This intended equalization of input and output power assumes all frequencies are physically present; hence it is most applicable to white noise. A zero value signifies no scaling of the signal, leaving that to some later adjustment (see [balance](../opcodes/balance.md)). The default value is 0.', + type: 'initialization' + }, + { + name: 'asig', + description: 'input signal to be filtered', + type: 'performance' + }, + { + name: 'xcf', + description: 'cutoff or resonant frequency of the filter, measured in Hz', + type: 'performance' + }, + { + name: 'xbw', + description: 'bandwidth of the filter (the Hz difference between the upper and lower half-power points)', + type: 'performance' + }, + ], + seeAlso: ['Standard Filters: Resonant Low-pass filters'] +}, +{ + name: 'rezzy', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters:Resonant', + description: 'A resonant low-pass filter.', + syntax: 'ares = rezzy(asig, xfco, xres [, imode, iskip])', + example: '--8<-- "examples/rezzy.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'asig', + description: 'input signal', + type: 'performance' + }, + { + name: 'xfco', + description: 'filter cut-off frequency in Hz. As of version 3.50, may i-,k-, or a-rate.', + type: 'performance' + }, + { + name: 'xres', + description: 'amount of resonance. Values of 1 to 100 are typical. Resonance should be one or greater. As of version 3.50, may a-rate, i-rate, or k-rate.', + type: 'performance' + }, + ], + seeAlso: ['Standard Filters: Resonant Low-pass filters'] +}, +{ + name: 'skf', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters:Resonant', + description: 'Sallen-Key filter.', + syntax: 'asig = skf(asig, xcf, xK[, ihp, istor])', + example: '--8<-- "examples/skf.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'ihp', + description: 'if non-zero, select highpass response. Defaults to 0 (lowpass).', + type: 'initialization' + }, + { + name: 'istor', + description: 'initial disposition of internal data space. Since filtering incorporates a feedback loop of previous output, the initial status of the storage space used is significant. A zero value will clear the space; a non-zero value will allow previous information to remain. The default value is 0.', + type: 'initialization' + }, + { + name: 'asig', + description: 'input', + type: 'performance' + }, + { + name: 'xcf', + description: 'filter cutoff frequency (a- or k-rate)', + type: 'performance' + }, + { + name: 'xK', + description: 'Sallen-Key opamp gain, in the range 1 to 3. At 3 the filter self-oscillates. K=1. 586 gives a Butterworth response, higher values are equivalent to Chebyshev responses (with peaking). At K=1 the filter is critically damped and the poles are real-valued.', + type: 'performance' + }, + ], + seeAlso: ['Standard Filters: Resonant Low-pass filters'] +}, +{ + name: 'spf', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters:Resonant', + description: 'Steiner-Parker filter.', + syntax: 'asig = spf(alp,ahp,abp, xcf, xR[, istor])', + example: '--8<-- "examples/spf.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'istor', + description: 'initial disposition of internal data space. Since filtering incorporates a feedback loop of previous output, the initial status of the storage space used is significant. A zero value will clear the space; a non-zero value will allow previous information to remain. The default value is 0.', + type: 'initialization' + }, + { + name: 'alp', + description: 'lowpass, highpass and bandpass input signals. Different signals can be used as inputs; if the same signal is placed at the lowpass and highpass inputs, the result is a band-reject output for that signal. If the same signal is used for all inputs, an allpass filter results.', + type: 'performance' + }, + { + name: 'ahp', + description: 'lowpass, highpass and bandpass input signals. Different signals can be used as inputs; if the same signal is placed at the lowpass and highpass inputs, the result is a band-reject output for that signal. If the same signal is used for all inputs, an allpass filter results.', + type: 'performance' + }, + { + name: 'abp', + description: 'lowpass, highpass and bandpass input signals. Different signals can be used as inputs; if the same signal is placed at the lowpass and highpass inputs, the result is a band-reject output for that signal. If the same signal is used for all inputs, an allpass filter results.', + type: 'performance' + }, + { + name: 'xcf', + description: 'filter cutoff frequency (a- or k-rate)', + type: 'performance' + }, + { + name: 'xR', + description: 'filter damping factor, which controls peaking (for bandpass, R = 1/Q, where Q is the ratio of centre frequency and bandwidth). A value of sqrt(2) (approx 1.414) gives no peaking (Butterworth response), and lower values will make the filter peak and ring. A value of 0 turns the filter into a sinusoidal oscillator. Valid values in the range of 0 - 2. At 2, the filter has real poles and so it is equivalent to two first-order filters in series.', + type: 'performance' + }, + ], + seeAlso: ['Standard Filters: Resonant Low-pass filters'] +}, +{ + name: 'statevar', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters:Resonant', + description: 'Statevar is a new digital implementation of the analogue state-variable filter.', + syntax: 'ahp, alp, abp, abr = statevar(ain, xcf, xq [, iosamps, istor])', + example: '--8<-- "examples/statevar.csd"', + parameters: [ + { + name: 'iosamps', + description: 'number of times of oversampling used in the filtering process. This will determine the maximum sharpness of the filter resonance (Q). More oversampling allows higher Qs, less oversampling will limit the resonance. The default is 3 times (iosamps=0).', + type: 'initialization' + }, + { + name: 'istor', + description: 'initial disposition of internal data space. Since filtering incorporates a feedback loop of previous output, the initial status of the storage space used is significant. A zero value will clear the space; a non-zero value will allow previous information to remain. The default value is 0.', + type: 'initialization' + }, + { + name: 'ahp', + description: 'high-pass output signal.', + type: 'performance' + }, + { + name: 'alp', + description: 'low-pass output signal.', + type: 'performance' + }, + { + name: 'abp', + description: 'band-pass signal.', + type: 'performance' + }, + { + name: 'abr', + description: 'band-reject signal.', + type: 'performance' + }, + { + name: 'asig', + description: 'input signal.', + type: 'performance' + }, + { + name: 'xcf', + description: 'filter cutoff frequency (k-rate or a-rate).', + type: 'performance' + }, + { + name: 'xq', + description: 'filter Q (k-rate or a-rate). This value is limited internally depending on the frequency and the number of times of oversampling used in the process (3-times oversampling by default).', + type: 'performance' + }, + ], + seeAlso: ['Standard Filters: Resonant Low-pass filters'] +}, +] diff --git a/src/lib/csound-reference/signal-modifiers-standard-filters.ts b/src/lib/csound-reference/signal-modifiers-standard-filters.ts new file mode 100644 index 0000000..00e6b0b --- /dev/null +++ b/src/lib/csound-reference/signal-modifiers-standard-filters.ts @@ -0,0 +1,471 @@ +import type { CsoundReference } from './types' + +// Signal Modifiers:Standard Filters +export const signalModifiersStandardFilters: CsoundReference[] = [ +{ + name: 'atone', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters', + description: 'A hi-pass filter whose transfer functions are the complements of the [tone](../opcodes/tone.md) opcode.', + syntax: 'ares = atone(asig, khp [, iskip])', + example: '--8<-- "examples/atone-modern.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'ares', + description: 'the output signal at audio rate.', + type: 'performance' + }, + { + name: 'asig', + description: 'the input signal at audio rate.', + type: 'performance' + }, + { + name: 'khp', + description: 'the response curve\'s half-power point, in Hertz. Half power is defined as peak power / root 2.', + type: 'performance' + }, + ], + seeAlso: ['Standard filters: Hi-pass filters'] +}, +{ + name: 'atonex', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters', + description: 'Emulates a stack of filters using the atone opcode.', + syntax: 'ares = atonex(asig, khp [, inumlayer] [, iskip])\n ares = atonex(asig, ahp [, inumlayer] [, iskip])', + example: '--8<-- "examples/atonex-modern.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'asig', + description: 'input signal', + type: 'performance' + }, + { + name: 'khp', + description: 'the response curve\'s half-power point. Half power is defined as peak power / root 2.', + type: 'performance' + }, + { + name: 'ahp', + description: 'the response curve\'s half-power point. Half power is defined as peak power / root 2.', + type: 'performance' + }, + ], + seeAlso: ['Standard filters: Hi-pass filters'] +}, +{ + name: 'biquad', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters', + description: 'A sweepable general purpose biquadratic digital filter.', + syntax: 'ares = biquad(asig, kb0, kb1, kb2, ka0, ka1, ka2 [, iskip])', + example: '--8<-- "examples/biquad-modern.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'asig', + description: 'input signal', + type: 'performance' + }, + ], + seeAlso: ['Standard filters: Biquad filters'] +}, +{ + name: 'biquada', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters', + description: 'A sweepable general purpose biquadratic digital filter with a-rate parameters.', + syntax: 'ares = biquada(asig, ab0, ab1, ab2, aa0, aa1, aa2 [, iskip])', + example: '--8<-- "examples/biquada-modern.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'asig', + description: 'input signal', + type: 'performance' + }, + ], + seeAlso: ['Standard filters: Biquad filters'] +}, +{ + name: 'butbp', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters', + description: 'Same as the [butterbp](../opcodes/butterbp.md) opcode.', + syntax: 'ares = butbp(asig, kfreq, kband [, iskip])', + rates: ['a-rate'], +}, +{ + name: 'butbr', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters', + description: 'Same as the [butterbr](../opcodes/butterbr.md) opcode.', + syntax: 'ares = butbr(asig, kfreq, kband [, iskip])', + rates: ['a-rate'], +}, +{ + name: 'buthp', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters', + description: 'Same as the [butterhp](../opcodes/butterhp.md) opcode.', + syntax: 'ares = buthp(asig, kfreq [, iskip])\n ares = buthp(asig, afreq [, iskip])', + rates: ['a-rate'], +}, +{ + name: 'butlp', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters', + description: 'Same as the [butterlp](../opcodes/butterlp.md) opcode.', + syntax: 'ares = butlp(asig, kfreq [, iskip])\n ares = butlp(asig, afreq [, iskip])', + rates: ['a-rate'], +}, +{ + name: 'butterbp', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters', + description: 'A band-pass Butterworth filter.', + syntax: 'ares = butterbp(asig, xfreq, xband [, iskip])', + example: '--8<-- "examples/butterbp-modern.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'asig', + description: 'Input signal to be filtered.', + type: 'performance' + }, + { + name: 'xfreq', + description: 'Cutoff or center frequency for each of the filters.', + type: 'performance' + }, + { + name: 'xband', + description: 'Bandwidth of the bandpass and bandreject filters.', + type: 'performance' + }, + ], + seeAlso: ['Standard filters: Butterworth filters'] +}, +{ + name: 'butterbr', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters', + description: 'A band-reject Butterworth filter.', + syntax: 'ares = butterbr(asig, xfreq, xband [, iskip])', + example: '--8<-- "examples/butterbr-modern.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'asig', + description: 'Input signal to be filtered.', + type: 'performance' + }, + { + name: 'xfreq', + description: 'Cutoff or center frequency for each of the filters.', + type: 'performance' + }, + { + name: 'xband', + description: 'Bandwidth of the bandpass and bandreject filters.', + type: 'performance' + }, + ], + seeAlso: ['Standard filters: Butterworth filters'] +}, +{ + name: 'butterhp', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters', + description: 'A high-pass Butterworth filter.', + syntax: 'ares = butterhp(asig, kfreq [, iskip])\n ares = butterhp(asig, afreq [, iskip])', + example: '--8<-- "examples/butterhp-modern.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'asig', + description: 'Input signal to be filtered.', + type: 'performance' + }, + { + name: 'kfreq', + description: 'Cutoff or center frequency for each of the filters.', + type: 'performance' + }, + { + name: 'afreq', + description: 'Cutoff or center frequency for each of the filters.', + type: 'performance' + }, + ], + seeAlso: ['Standard filters: Butterworth filters'] +}, +{ + name: 'butterlp', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters', + description: 'A low-pass Butterworth filter.', + syntax: 'ares = butterlp(asig, kfreq [, iskip])\n ares = butterlp(asig, afreq [, iskip])', + example: '--8<-- "examples/butterlp-modern.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'asig', + description: 'Input signal to be filtered.', + type: 'performance' + }, + { + name: 'kfreq', + description: 'Cutoff or center frequency for each of the filters.', + type: 'performance' + }, + { + name: 'afreq', + description: 'Cutoff or center frequency for each of the filters.', + type: 'performance' + }, + ], + seeAlso: ['Standard filters: Butterworth filters'] +}, +{ + name: 'clfilt', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters', + description: 'Implements the classical standard analog filter types: low-pass and high-pass.', + syntax: 'ares = clfilt(asig, kfreq, itype, inpol [, ikind] [, ipbr] [, isba] [, iskip])', + example: '--8<-- "examples/clfilt_lowpass-modern.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'itype', + description: '0 for low-pass, 1 for high-pass.', + type: 'initialization' + }, + { + name: 'inpol', + description: 'The number of poles in the filter. It must be an even number from 2 to 80.', + type: 'initialization' + }, + { + name: 'asig', + description: 'The input audio signal.', + type: 'performance' + }, + { + name: 'kfreq', + description: 'The corner frequency for low-pass or high-pass.', + type: 'performance' + }, + ], + seeAlso: ['Standard filters: General filters'] +}, +{ + name: 'diode_ladder', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters', + description: 'Zero-delay feedback implementation of a 4 pole (24 dB/oct) diode low-pass filter.', + syntax: 'asig = diode_ladder(ain, xcf, xk [, inlp, isaturation, istor])', + example: '--8<-- "examples/diode_ladder.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'istor', + description: 'initial disposition of internal data space. Since filtering incorporates a feedback loop of previous output, the initial status of the storage space used is significant. A zero value will clear the space; a non-zero value will allow previous information to remain. The default value is 0.', + type: 'initialization' + }, + { + name: 'asig', + description: 'low-pass output signal.', + type: 'performance' + }, + { + name: 'ain', + description: 'input signal.', + type: 'performance' + }, + { + name: 'xcf', + description: 'filter cutoff frequency (i-, k-, or a-rate).', + type: 'performance' + }, + { + name: 'xk', + description: 'filter feedback value k (i-, k-, or a-rate) that controls resonance. Range 0.0-17.0 . Self-oscillation occurs at 17.0.', + type: 'performance' + }, + ], + seeAlso: ['Standard filters: Zero-delay Feedback Filters (Virtual Analog)'] +}, +{ + name: 'k35_hpf', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters', + description: 'Zero-delay feedback implementation of Korg35 resonant high-pass filter.', + syntax: 'asig = K35_hpf(ain, xcf, xQ [, inlp, isaturation, istor])', + example: '--8<-- "examples/k35.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'istor', + description: 'initial disposition of internal data space. Since filtering incorporates a feedback loop of previous output, the initial status of the storage space used is significant. A zero value will clear the space; a non-zero value will allow previous information to remain. The default value is 0.', + type: 'initialization' + }, + { + name: 'asig', + description: 'output signal.', + type: 'performance' + }, + { + name: 'ain', + description: 'input signal.', + type: 'performance' + }, + { + name: 'xcf', + description: 'filter cutoff frequency (i-, k-, or a-rate).', + type: 'performance' + }, + { + name: 'xQ', + description: 'filter Q value (i-, k-, or a-rate). Range 1.0-10.0 (clamped by opcode). Self-oscillation occurs at 10.0.', + type: 'performance' + }, + ], + seeAlso: ['Standard filters: Zero-delay Feedback Filters (Virtual Analog)'] +}, +{ + name: 'k35_lpf', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters', + description: 'Zero-delay feedback implementation of Korg35 resonant low-pass filter.', + syntax: 'asig = K35_lpf(ain, xcf, xQ [, inlp, isaturation, istor])', + example: '--8<-- "examples/k35.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'istor', + description: 'initial disposition of internal data space. Since filtering incorporates a feedback loop of previous output, the initial status of the storage space used is significant. A zero value will clear the space; a non-zero value will allow previous information to remain. The default value is 0.', + type: 'initialization' + }, + { + name: 'asig', + description: 'output signal.', + type: 'performance' + }, + { + name: 'ain', + description: 'input signal.', + type: 'performance' + }, + { + name: 'xcf', + description: 'filter cutoff frequency (i-, k-, or a-rate).', + type: 'performance' + }, + { + name: 'xQ', + description: 'filter Q value (i-, k-, or a-rate). Range 1.0-10.0 (clamped by opcode). Self-oscillation occurs at 10.0.', + type: 'performance' + }, + ], + seeAlso: ['Standard filters: Zero-delay Feedback Filters (Virtual Analog)'] +}, +{ + name: 'median', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters', + description: 'A median filter, a variant FIR lowpass filter.', + syntax: 'ares = median(asig, ksize, imaxsize [, iskip])', + example: '--8<-- "examples/median.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'imaxsize', + description: 'the maximun size of the window used to select the data.', + type: 'initialization' + }, + { + name: 'iskip', + description: 'initial disposition of internal data space. A zero value will clear the space; a non-zero value will allow previous information to remain. The default value is 0.', + type: 'initialization' + }, + { + name: 'asig', + description: 'input signal to be filtered', + type: 'performance' + }, + { + name: 'ksize', + description: 'size of the window over which the input is to be filtered. It must not exceed the maximum window size; if it does it is truncated.', + type: 'performance' + }, + ], + seeAlso: ['Standard filters: Variant FIR lowpass filter'] +}, +{ + name: 'mediank', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters', + description: 'A median filter, a variant FIR lowpass filter.', + syntax: 'kres = mediank(kin, ksize, imaxsize [, iskip])', + example: '--8<-- "examples/mediank.csd"', + rates: ['k-rate'], + parameters: [ + { + name: 'imaxsize', + description: 'the maximun size of the window used to select the data.', + type: 'initialization' + }, + { + name: 'iskip', + description: 'initial disposition of internal data space. A zero value will clear the space; a non-zero value will allow previous information to remain. The default value is 0.', + type: 'initialization' + }, + { + name: 'kin', + description: 'krate value to be filtered', + type: 'performance' + }, + { + name: 'ksize', + description: 'size of the window over which the input is to be filtered. It must not exceed the maximum window size; if it does it is truncated.', + type: 'performance' + }, + ], + seeAlso: ['Standard filters: Variant FIR lowpass filter'] +}, +{ + name: 'mode', + type: 'opcode', + category: 'Signal Modifiers:Standard Filters', + description: 'A filter that simulates a mass-spring-damper system.', + syntax: 'aout = mode(ain, xfreq, xQ [, iskip])', + example: '--8<-- "examples/mode.csd"', + parameters: [ + { + name: 'aout', + description: 'filtered signal', + type: 'performance' + }, + { + name: 'ain', + description: 'signal to filter', + type: 'performance' + }, + { + name: 'xfreq', + description: 'resonant frequency of the filter', + type: 'performance' + }, + { + name: 'xQ', + description: 'quality factor of the filter', + type: 'performance' + }, + ], + seeAlso: ['Specialized Filters: Other filters'] +}, +] diff --git a/src/lib/csound-reference/signal-modifiers-waveshaping.ts b/src/lib/csound-reference/signal-modifiers-waveshaping.ts new file mode 100644 index 0000000..cb2f9d3 --- /dev/null +++ b/src/lib/csound-reference/signal-modifiers-waveshaping.ts @@ -0,0 +1,170 @@ +import type { CsoundReference } from './types' + +// Signal Modifiers:Waveshaping +export const signalModifiersWaveshaping: CsoundReference[] = [ +{ + name: 'chebyshevpoly', + type: 'opcode', + category: 'Signal Modifiers:Waveshaping', + description: 'Efficiently evaluates the sum of Chebyshev polynomials of arbitrary order.', + syntax: 'aout = chebyshevpoly(ain, k0 [, k1 [, k2 [...]]])', + example: '--8<-- "examples/chebyshevpoly-modern.csd"', + parameters: [ + { + name: 'ain', + description: 'the input signal used as the independent variable of the Chebyshev polynomials ("x").', + type: 'performance' + }, + { + name: 'aout', + description: 'the output signal ("y").', + type: 'performance' + }, + ], + seeAlso: ['Waveshaping', 'Opcode Equivalents of Functions'] +}, +{ + name: 'pdclip', + type: 'opcode', + category: 'Signal Modifiers:Waveshaping', + description: 'Performs linear clipping on an audio signal or a phasor.', + syntax: 'aout = pdclip(ain, kWidth, kCenter [, ibipolar [, ifullscale]])', + example: '--8<-- "examples/pdclip.csd"', + parameters: [ + { + name: 'ibipolar', + description: 'an optional parameter specifying either unipolar (0) or bipolar (1) mode. Defaults to unipolar mode.', + type: 'initialization' + }, + { + name: 'ifullscale', + description: 'an optional parameter specifying the range of input and output values. The maximum will be _ifullscale_. The minimum depends on the mode of operation: zero for unipolar or -_ifullscale_ for bipolar. Defaults to 1.0 -- you should set this parameter to the maximum expected input value.', + type: 'initialization' + }, + { + name: 'ain', + description: 'the input signal to be clipped.', + type: 'performance' + }, + { + name: 'aout', + description: 'the output signal.', + type: 'performance' + }, + { + name: 'kWidth', + description: 'the percentage of the signal range that is clipped (must be between 0 and 1).', + type: 'performance' + }, + { + name: 'kCenter', + description: 'an offset for shifting the unclipped window of the signal higher or lower in the range (essentially a DC offset). Values should be in the range [-1, 1] with a value of zero representing no shift (regardless of whether bipolar or unipolar mode is used).', + type: 'performance' + }, + ], + seeAlso: ['Phase Distortion'] +}, +{ + name: 'pdhalf', + type: 'opcode', + category: 'Signal Modifiers:Waveshaping', + description: 'Distorts a phasor for reading the two halves of a table at different rates.', + syntax: 'aout = pdhalf(ain, kShapeAmount [, ibipolar [, ifullscale]])', + example: 'aphase phasor ifreq\napd pdhalf aphase, kamount\naout tablei apd, 1, 1', + parameters: [ + { + name: 'ibipolar', + description: 'an optional parameter specifying either unipolar (0) or bipolar (1) mode. Defaults to unipolar mode.', + type: 'initialization' + }, + { + name: 'ifullscale', + description: 'an optional parameter specifying the range of input and output values. The maximum will be _ifullscale_. The minimum depends on the mode of operation: zero for unipolar or -_ifullscale_ for bipolar. Defaults to 1.0 -- you should set this parameter to the maximum expected input value.', + type: 'initialization' + }, + { + name: 'ain', + description: 'the input signal to be distorted.', + type: 'performance' + }, + { + name: 'aout', + description: 'the output signal.', + type: 'performance' + }, + { + name: 'kShapeAmount', + description: 'the amount of distortion applied to the input. Must be between negative one and one (-1 to 1). An amount of zero means no distortion.', + type: 'performance' + }, + ], + seeAlso: ['Phase Distortion', 'http://en.wikipedia.org/wiki/Phase_distortion_synthesis'] +}, +{ + name: 'pdhalfy', + type: 'opcode', + category: 'Signal Modifiers:Waveshaping', + description: 'Distorts a phasor for reading two unequal portions of a table in equal periods.', + syntax: 'aout = pdhalfy(ain, kShapeAmount [, ibipolar [, ifullscale]])', + example: 'aphase phasor ifreq\napd pdhalfy aphase, kamount\naout tablei apd, 1, 1', + parameters: [ + { + name: 'ibipolar', + description: 'an optional parameter specifying either unipolar (0) or bipolar (1) mode. Defaults to unipolar mode.', + type: 'initialization' + }, + { + name: 'ifullscale', + description: 'an optional parameter specifying the range of input and output values. The maximum will be _ifullscale_. The minimum depends on the mode of operation: zero for unipolar or -_ifullscale_ for bipolar. Defaults to 1.0 -- you should set this parameter to the maximum expected input value.', + type: 'initialization' + }, + { + name: 'ain', + description: 'the input signal to be distorted.', + type: 'performance' + }, + { + name: 'aout', + description: 'the output signal.', + type: 'performance' + }, + { + name: 'kShapeAmount', + description: 'the amount of distortion applied to the input. Must be between negative one and one (-1 to 1). An amount of zero means no distortion.', + type: 'performance' + }, + ], + seeAlso: ['Phase Distortion', 'http://en.wikipedia.org/wiki/Phase_distortion_synthesis'] +}, +{ + name: 'powershape', + type: 'opcode', + category: 'Signal Modifiers:Waveshaping', + description: 'Waveshapes a signal by raising it to a variable exponent.', + syntax: 'aout = powershape(ain, kShapeAmount [, ifullscale])', + example: '--8<-- "examples/powershape.csd"', + parameters: [ + { + name: 'ifullscale', + description: 'optional parameter specifying the range of input values from -_ifullscale_ to _ifullscale_. Defaults to 1.0 -- you should set this parameter to the maximum expected input value.', + type: 'initialization' + }, + { + name: 'ain', + description: 'the input signal to be shaped.', + type: 'performance' + }, + { + name: 'aout', + description: 'the output signal.', + type: 'performance' + }, + { + name: 'kShapeAmount', + description: 'the amount of the shaping effect applied to the input; equal to the power that the input signal is raised.', + type: 'performance' + }, + ], + seeAlso: ['pow', 'powoftwo', 'Waveshaping', 'Mathematical Functions'] +}, +] diff --git a/src/lib/csound-reference/spectral-processing-ats.ts b/src/lib/csound-reference/spectral-processing-ats.ts new file mode 100644 index 0000000..12b76cf --- /dev/null +++ b/src/lib/csound-reference/spectral-processing-ats.ts @@ -0,0 +1,315 @@ +import type { CsoundReference } from './types' + +// Spectral Processing:ATS +export const spectralProcessingAts: CsoundReference[] = [ +{ + name: 'ATSadd', + type: 'opcode', + category: 'Spectral Processing:ATS', + description: 'Uses the data from an ATS analysis file to perform additive synthesis using an internal array of interpolating oscillators.', + syntax: 'ar = ATSadd(ktimepnt, kfmod, iatsfile, ifn, ipartials [, ipartialoffset, \\\n ipartialincr, igatefn])', + example: 'ktime line 0, p3, 2.5\n asig ATSadd ktime, 1, "clarinet.ats", 1, 20, 2', + rates: ['i-rate'], + parameters: [ + { + name: 'iatsfile', + description: 'the ATS number (n in ats.n) or the name in quotes of the analysis file made using [ATSA](../utility/atsa.md).', + type: 'initialization' + }, + { + name: 'ifn', + description: 'table number of a stored function containing a sine wave for _ATSadd_ and a cosine for [ATSaddnz](../opcodes/ATSaddnz.md) (see examples below for more info)', + type: 'initialization' + }, + { + name: 'ipartials', + description: 'number of partials that will be used in the resynthesis (the noise has a maximum of 25 bands)', + type: 'initialization' + }, + { + name: 'ktimepnt', + description: 'The time pointer in seconds used to index the ATS file. Used for _ATSadd_ exactly the same as for [pvoc](../opcodes/pvoc.md).', + type: 'performance' + }, + { + name: 'kfmod', + description: 'A control-rate transposition factor: a value of 1 incurs no transposition, 1.5 transposes up a perfect fifth, and .5 down an octave. Used for _ATSadd_ exactly the same as for [pvoc](../opcodes/pvoc.md).', + type: 'performance' + }, + ], + seeAlso: ['ATS Spectral Processing'] +}, +{ + name: 'ATSaddnz', + type: 'opcode', + category: 'Spectral Processing:ATS', + description: 'Uses the data from an ATS analysis file to perform noise resynthesis using a modified randi function.', + syntax: 'ar = ATSaddnz(ktimepnt, iatsfile, ibands [, ibandoffset, ibandincr])', + example: 'ktime line 0, p3, 2.5\n asig ATSaddnz ktime, "clarinet.ats", 25', + parameters: [ + { + name: 'iatsfile', + description: 'the ATS number (n in ats.n) or the name in quotes of the analysis file made using [ATSA](../utility/atsa.md).', + type: 'initialization' + }, + { + name: 'ibands', + description: 'number of noise bands that will be used in the resynthesis (the noise has a maximum of 25 bands)', + type: 'initialization' + }, + { + name: 'ktimepnt', + description: 'The time pointer in seconds used to index the ATS file. Used for _ATSaddnz_ exactly the same as for [pvoc](../opcodes/pvoc.md) and [ATSadd](../opcodes/ATSadd.md).', + type: 'performance' + }, + ], + seeAlso: ['ATS Spectral Processing'] +}, +{ + name: 'ATSbufread', + type: 'opcode', + category: 'Spectral Processing:ATS', + description: 'Reads data from and ATS data file and stores it in an internal data table of frequency, amplitude pairs.', + syntax: 'ATSbufread(ktimepnt, kfmod, iatsfile, ipartials [, ipartialoffset, \\\n ipartialincr])', + example: '--8<-- "examples/ATSbufread-modern.csd"', + parameters: [ + { + name: 'iatsfile', + description: 'the ATS number (n in ats.n) or the name in quotes of the analysis file made using [ATSA](../utility/atsa.md).', + type: 'initialization' + }, + { + name: 'ipartials', + description: 'number of partials that will be used in the resynthesis (the noise has a maximum of 25 bands)', + type: 'initialization' + }, + { + name: 'ktimepnt', + description: 'The time pointer in seconds used to index the ATS file. Used for _ATSbufread_ exactly the same as for [pvoc](../opcodes/pvoc.md).', + type: 'performance' + }, + { + name: 'kfmod', + description: 'an input for performing pitch transposition or frequency modulation on all of the synthesized partials, if no fm or pitch change is desired then use a 1 for this value.', + type: 'performance' + }, + ], + seeAlso: ['ATS Spectral Processing'] +}, +{ + name: 'ATScross', + type: 'opcode', + category: 'Spectral Processing:ATS', + description: '_ATScross_ uses data from an ATS analysis file and data from an [ATSbufread](../opcodes/ATSbufread.md) to perform cross synthesis.', + syntax: 'ar = ATScross(ktimepnt, kfmod, iatsfile, ifn, kmylev, kbuflev, ipartials \\\n [, ipartialoffset, ipartialincr])', + example: '--8<-- "examples/ATScross-modern.csd"', + rates: ['i-rate'], + parameters: [ + { + name: 'iatsfile', + description: 'integer or character-string denoting a control-file derived from ATS analysis of an audio signal. An integer denotes the suffix of a file ATS.m; a character-string (in double quotes) gives a filename, optionally a full pathname. If not full-path, the file is sought first in the current directory, then in the one given by the environment variable SADIR (if defined).', + type: 'initialization' + }, + { + name: 'ifn', + description: 'table number of a stored function containing a sine wave.', + type: 'initialization' + }, + { + name: 'ipartials', + description: 'number of partials that will be used in the resynthesis', + type: 'initialization' + }, + { + name: 'ktimepnt', + description: 'The time pointer in seconds used to index the ATS file. Used for _ATScross_ exactly the same as for [pvoc](../opcodes/pvoc.md).', + type: 'performance' + }, + { + name: 'kfmod', + description: 'an input for performing pitch transposition or frequency modulation on all of the synthesized partials, if no fm or pitch change is desired then use a 1 for this value.', + type: 'performance' + }, + { + name: 'kmylev', + description: 'scales the _ATScross_ component of the frequency spectrum applied to the partials from the ATS file indicated by the _ATScross_ opcode. The frequency spectrum information comes from the _ATScross_ ATS file. A value of 1 (and 0 for _kbuflev_) gives the same results as [ATSadd](../opcodes/ATSadd.md).', + type: 'performance' + }, + { + name: 'kbuflev', + description: 'scales the [ATSbufread](../opcodes/ATSbufread.md) component of the frequency spectrum applied to the partials from the ATS file indicated by the _ATScross_ opcode. The frequency spectrum information comes from the [ATSbufread](../opcodes/ATSbufread.md) ATS file. A value of 1 (and 0 for _kmylev_) results in partials that have frequency information from the ATS file given by the _ATScross_, but amplitudes imposed by data from the ATS file given by [ATSbufread](../opcodes/ATSbufread.md).', + type: 'performance' + }, + ], + seeAlso: ['ATS Spectral Processing'] +}, +{ + name: 'ATSinfo', + type: 'opcode', + category: 'Spectral Processing:ATS', + description: 'Reads data out of the header of an ATS file.', + syntax: 'idata = ATSinfo(iatsfile, ilocation)', + example: '--8<-- "examples/ATSinfo-modern.csd"', + parameters: [ + { + name: 'iatsfile', + description: 'the ATS number (n in ats.n) or the name in quotes of the analysis file made using [ATSA](../utility/atsa.md).', + type: 'initialization' + }, + { + name: 'ilocation', + description: 'indicates which location in the header file to return. The data in the header gives information about the data contained in the rest of the ATS file. The possible values for _ilocation_ are given in the following list:', + type: 'initialization' + }, + ], + seeAlso: ['ATS Spectral Processing'] +}, +{ + name: 'ATSinterpread', + type: 'opcode', + category: 'Spectral Processing:ATS', + description: 'Allows a user to determine the frequency envelope of any [ATSbufread](../opcodes/ATSbufread.md).', + syntax: 'kamp = ATSinterpread(kfreq)', + example: '--8<-- "examples/ATSinterpread-modern.csd"', + rates: ['k-rate'], + parameters: [ + { + name: 'kfreq', + description: 'a frequency value (given in Hertz) used by _ATSinterpread_ as in index into the table produced by an [ATSbufread](../opcodes/ATSbufread.md).', + type: 'performance' + }, + ], + seeAlso: ['ATS Spectral Processing'] +}, +{ + name: 'ATSpartialtap', + type: 'opcode', + category: 'Spectral Processing:ATS', + description: 'Returns a frequency, amplitude pair from an [ATSbufread](../opcodes/ATSbufread.md) opcode.', + syntax: 'kfrq, kamp = ATSpartialtap(ipartialnum)', + example: '--8<-- "examples/ATSpartialtap-modern.csd"', + rates: ['k-rate'], + parameters: [ + { + name: 'ipartialnum', + description: 'indicates the partial that the _ATSpartialtap_ opcode should read from an [ATSbufread](../opcodes/ATSbufread.md).', + type: 'initialization' + }, + { + name: 'kfrq', + description: 'returns the frequency value for the requested partial.', + type: 'performance' + }, + { + name: 'kamp', + description: 'returns the amplitude value for the requested partial.', + type: 'performance' + }, + ], + seeAlso: ['ATS Spectral Processing'] +}, +{ + name: 'ATSread', + type: 'opcode', + category: 'Spectral Processing:ATS', + description: 'Reads data from an ATS file.', + syntax: 'kfreq, kamp = ATSread(ktimepnt, iatsfile, ipartial)', + example: '--8<-- "examples/ATSread-modern.csd"', + rates: ['k-rate'], + parameters: [ + { + name: 'iatsfile', + description: 'the ATS number (n in ats.n) or the name in quotes of the analysis file made using [ATSA](../utility/atsa.md).', + type: 'initialization' + }, + { + name: 'ipartial', + description: 'the number of the analysis partial to return the frequency in Hz and amplitude.', + type: 'initialization' + }, + { + name: 'kfreq', + description: 'outputs of the _ATSread_ unit. These values represent the frequency and amplitude of a specific partial selected by the user using _ipartial_. The partials\' informations are derived from an ATS analysis. _ATSread_ linearly interpolates the frequency and amplitude between frames in the ATS analysis file at k-rate. The output is dependent on the data in the analysis file and the pointer _ktimepnt_.', + type: 'performance' + }, + { + name: 'kamp', + description: 'outputs of the _ATSread_ unit. These values represent the frequency and amplitude of a specific partial selected by the user using _ipartial_. The partials\' informations are derived from an ATS analysis. _ATSread_ linearly interpolates the frequency and amplitude between frames in the ATS analysis file at k-rate. The output is dependent on the data in the analysis file and the pointer _ktimepnt_.', + type: 'performance' + }, + { + name: 'ktimepnt', + description: 'The time pointer in seconds used to index the ATS file. Used for _ATSread_ exactly the same as for [pvoc](../opcodes/pvoc.md) and [ATSadd](../opcodes/ATSadd.md).', + type: 'performance' + }, + ], + seeAlso: ['ATS Spectral Processing'] +}, +{ + name: 'ATSreadnz', + type: 'opcode', + category: 'Spectral Processing:ATS', + description: 'reads data from an ATS file.', + syntax: 'kenergy = ATSreadnz(ktimepnt, iatsfile, iband)', + example: 'ktime line 2.5, p3, 0\n kenergy\tATSreadnz ktime, "clarinet.ats", 5', + parameters: [ + { + name: 'iatsfile', + description: 'the ATS number (n in ats.n) or the name in quotes of the analysis file made using [ATSA](../utility/atsa.md).', + type: 'initialization' + }, + { + name: 'iband', + description: 'the number of the noise band to return the energy data.', + type: 'initialization' + }, + { + name: 'ktimepnt', + description: 'The time pointer in seconds used to index the ATS file. Used for _ATSreadnz_ exactly the same as for [pvoc](../opcodes/pvoc.md) and [ATSadd](../opcodes/ATSadd.md).', + type: 'performance' + }, + ], + seeAlso: ['ATS Spectral Processing'] +}, +{ + name: 'ATSsinnoi', + type: 'opcode', + category: 'Spectral Processing:ATS', + description: '_ATSsinnoi_ reads data from an ATS data file and uses the information to synthesize sines and noise together.', + syntax: 'ar = ATSsinnoi(ktimepnt, ksinlev, knzlev, kfmod, iatsfile, ipartials \\\n [, ipartialoffset, ipartialincr])', + example: 'ktime line 0, p3, 2.5\n asig ATSsinnoi ktime, 1, 1, 1, "beats.ats", 42', + parameters: [ + { + name: 'iatsfile', + description: 'the ATS number (n in ats.n) or the name in quotes of the analysis file made using [ATSA](../utility/atsa.md).', + type: 'initialization' + }, + { + name: 'ipartials', + description: 'number of partials that will be used in the resynthesis (the noise has a maximum of 25 bands)', + type: 'initialization' + }, + { + name: 'ktimepnt', + description: 'The time pointer in seconds used to index the ATS file. Used for _ATSsinnoi_ exactly the same as for [pvoc](../opcodes/pvoc.md).', + type: 'performance' + }, + { + name: 'ksinlev', + description: 'controls the level of the sines in the _ATSsinnoi_ ugen. A value of 1 gives full volume sinewaves.', + type: 'performance' + }, + { + name: 'knzlev', + description: 'controls the level of the noise components in the _ATSsinnoi_ ugen. A value of 1 gives full volume noise.', + type: 'performance' + }, + { + name: 'kfmod', + description: 'an input for performing pitch transposition or frequency modulation on all of the synthesized partials, if no fm or pitch change is desired then use a 1 for this value.', + type: 'performance' + }, + ], + seeAlso: ['ATS Spectral Processing'] +}, +] diff --git a/src/lib/csound-reference/spectral-processing-lpc.ts b/src/lib/csound-reference/spectral-processing-lpc.ts new file mode 100644 index 0000000..3a93f11 --- /dev/null +++ b/src/lib/csound-reference/spectral-processing-lpc.ts @@ -0,0 +1,416 @@ +import type { CsoundReference } from './types' + +// Spectral Processing:LPC +export const spectralProcessingLpc: CsoundReference[] = [ +{ + name: 'allpole', + type: 'opcode', + category: 'Spectral Processing:LPC', + description: 'Allpole filter implementation using direct convolution.', + syntax: 'ares = allpole(asig, kCoef[])', + example: '--8<-- "examples/allpole-modern.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'asig', + description: 'audio input', + type: 'performance' + }, + { + name: 'ares', + description: 'audio output', + type: 'performance' + }, + ], + seeAlso: ['Streaming Linear Predictive Coding (SLPC) Resynthesis'] +}, +{ + name: 'apoleparams', + type: 'opcode', + category: 'Spectral Processing:LPC', + description: 'Extracts allpole filter parameters from coefficients.', + syntax: 'kPar[] = apoleparams(kCoef[])', + example: '--8<-- "examples/apoleparams-modern.csd"', + seeAlso: ['Streaming Linear Predictive Coding (SLPC) Resynthesis'] +}, +{ + name: 'lpcanal', + type: 'opcode', + category: 'Spectral Processing:LPC', + description: 'Streaming linear prediction analysis.', + syntax: 'kCoef[], krms, kerr, kcps = lpcanal(asrc, kflg, kprd, isiz, iord [, iwin])\n kCoef[], krms, kerr, kcps = lpcanal(koff, kflg, ifn, isiz, iord [, iwin])\n iCoef[], irms, ierr, icps = lpcanal(ioff, iflg, ifn, isiz, iord [, iwin])', + example: '--8<-- "examples/lpcanal.csd"', + rates: ['k-rate', 'i-rate'], + parameters: [ + { + name: 'isiz', + description: 'size of lpc input frame in samples.', + type: 'initialization' + }, + { + name: 'iord', + description: 'linear predictor order.', + type: 'initialization' + }, + { + name: 'ifn', + description: 'streaming LPC analysis source function table', + type: 'initialization' + }, + { + name: 'iwin', + description: 'window function table number (optional)', + type: 'initialization' + }, + { + name: 'krms', + description: 'RMS estimate of source signal.', + type: 'performance' + }, + { + name: 'kerr', + description: 'linear prediction error (or residual).', + type: 'performance' + }, + { + name: 'kcps', + description: 'fundamental frequency estimate, from the autocorrelation function.', + type: 'performance' + }, + { + name: 'asrc', + description: 'streaming LPC analysis source signal', + type: 'performance' + }, + { + name: 'kflg', + description: 'compute flag, non-zero values switch on linear prediction analysis replacing filter coefficients, zero switch it off, keeping current filter coefficients.', + type: 'performance' + }, + { + name: 'kprd', + description: 'analysis period in samples, determining how often new coefficients are computed.', + type: 'performance' + }, + { + name: 'koff', + description: 'function table position offset, in samples, determining the start position of analysis frame.', + type: 'performance' + }, + ], + seeAlso: ['Streaming Linear Predictive Coding (SLPC) Resynthesis'] +}, +{ + name: 'lpcfilter', + type: 'opcode', + category: 'Spectral Processing:LPC', + description: 'Streaming linear prediction all-pole filter whose coefficients are obtained from streaming linear prediction analysis.', + syntax: 'ares = lpcfilter(asig, asrc, kflg, kprd, isiz, iord [, iwin])\n ares = lpcfilter(asig, koff, kflg, ifn, isiz, iord [, iwin])', + example: '--8<-- "examples/lpcfilter.csd"', + rates: ['a-rate', 'i-rate'], + parameters: [ + { + name: 'isiz', + description: 'size of lpc input frame in samples.', + type: 'initialization' + }, + { + name: 'iord', + description: 'linear predictor order.', + type: 'initialization' + }, + { + name: 'ifn', + description: 'streaming LPC analysis source function table', + type: 'initialization' + }, + { + name: 'iwin', + description: 'window function table number (optional)', + type: 'initialization' + }, + { + name: 'ares', + description: 'output', + type: 'performance' + }, + { + name: 'asig', + description: 'audio input', + type: 'performance' + }, + { + name: 'asrc', + description: 'streaming LPC analysis source signal', + type: 'performance' + }, + { + name: 'kflg', + description: 'compute flag, non-zero values switch on linear prediction analysis replacing filter coefficients, zero switch it off, keeping current filter coefficients.', + type: 'performance' + }, + { + name: 'kprd', + description: 'analysis period in samples, determining how often new coefficients are computed.', + type: 'performance' + }, + { + name: 'koff', + description: 'function table position offset, in samples, determining the start position of analysis frame.', + type: 'performance' + }, + ], + seeAlso: ['Streaming Linear Predictive Coding (SLPC) Resynthesis'] +}, +{ + name: 'lpfreson', + type: 'opcode', + category: 'Spectral Processing:LPC', + description: 'Resynthesises a signal from the data passed internally by a previous _lpread_, applying formant shifting.', + syntax: 'ares = lpfreson(asig, kfrqratio)', + example: '--8<-- "examples/lpfreson.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'asig', + description: 'an audio driving function for resynthesis.', + type: 'performance' + }, + { + name: 'kfrqratio', + description: 'frequency ratio. Must be greater than 0.', + type: 'performance' + }, + ], + seeAlso: ['Linear Predictive Coding (LPC) Resynthesis'] +}, +{ + name: 'lpinterp', + type: 'opcode', + category: 'Spectral Processing:LPC', + description: 'Computes a new set of poles from the interpolation between two analysis.', + syntax: 'lpinterp(islot1, islot2, kmix)', + parameters: [ + { + name: 'islot1', + description: 'slot where the first analysis was stored', + type: 'initialization' + }, + { + name: 'islot2', + description: 'slot where the second analysis was stored', + type: 'initialization' + }, + { + name: 'kmix', + description: 'mix value between the two analysis. Should be between 0 and 1. 0 means analysis 1 only. 1 means analysis 2 only. Any value in between will produce interpolation between the filters.', + type: 'initialization' + }, + ], + seeAlso: ['Linear Predictive Coding (LPC) Resynthesis'] +}, +{ + name: 'lpread', + type: 'opcode', + category: 'Spectral Processing:LPC', + description: 'Reads a control file of time-ordered information frames.', + syntax: 'krmsr, krmso, kerr, kcps = lpread(ktimpnt, ifilcod [, inpoles] [, ifrmrate])', + example: '--8<-- "examples/lpread.csd"', + rates: ['k-rate'], + parameters: [ + { + name: 'ifilcod', + description: 'integer or character-string denoting a control-file (reflection coefficients and four parameter values) derived from n-pole linear predictive spectral analysis of a source audio signal. An integer denotes the suffix of a file _lp.m_; a character-string (in double quotes) gives a filename, optionally a full pathname. If not fullpath, the file is sought first in the current directory, then in that of the environment variable SADIR (if defined). Memory usage depends on the size of the file, which is held entirely in memory during computation but shared by multiple calls (see also _adsyn_, [pvoc](../opcodes/pvoc.md)).', + type: 'initialization' + }, + { + name: 'krmsr', + description: 'root-mean-square (rms) of the residual of analysis', + type: 'performance' + }, + { + name: 'krmso', + description: 'rms of the original signal', + type: 'performance' + }, + { + name: 'kerr', + description: 'the normalized error signal', + type: 'performance' + }, + { + name: 'kcps', + description: 'pitch in Hz', + type: 'performance' + }, + { + name: 'ktimpnt', + description: 'The passage of time, in seconds, through the analysis file. _ktimpnt_ must always be positive, but can move forwards or backwards in time, be stationary or discontinuous, as a pointer into the analysis file.', + type: 'performance' + }, + ], + seeAlso: ['Linear Predictive Coding (LPC) Resynthesis'] +}, +{ + name: 'lpreson', + type: 'opcode', + category: 'Spectral Processing:LPC', + description: 'RResynthesises a signal from the data passed internally by a previous _lpread_.', + syntax: 'ares = lpreson(asig)', + example: '--8<-- "examples/lpreson.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'asig', + description: 'an audio driving function for resynthesis.', + type: 'performance' + }, + ], + seeAlso: ['Linear Predictive Coding (LPC) Resynthesis'] +}, +{ + name: 'lpslot', + type: 'opcode', + category: 'Spectral Processing:LPC', + description: 'Selects the slot to be use by further lp opcodes.', + syntax: 'lpslot(islot)', + example: '--8<-- "examples/lpslot.csd"', + parameters: [ + { + name: 'islot', + description: 'number of slot to be selected.', + type: 'initialization' + }, + ], + seeAlso: ['Linear Predictive Coding (LPC) Resynthesis'] +}, +{ + name: 'pvscfs', + type: 'opcode', + category: 'Spectral Processing:LPC', + description: 'Cepstrum all-pole coefficient analysis.', + syntax: 'kCoef[], krms, kerr = pvscfs(fsig, iord [, imod])', + example: '--8<-- "examples/pvscfs.csd"', + parameters: [ + { + name: 'iord', + description: 'all-pole filter order.', + type: 'initialization' + }, + { + name: 'imod', + description: 'filter stabilisation mode (0=no stabilisation; 1= pole reflection; 2 = pole limiting; defaults to 1).', + type: 'initialization' + }, + { + name: 'krms', + description: 'RMS estimate of source signal.', + type: 'performance' + }, + { + name: 'kerr', + description: 'error (or residual).', + type: 'performance' + }, + { + name: 'fsig', + description: 'pvs signal input in PV_AMP_* format.', + type: 'performance' + }, + ], + seeAlso: ['Streaming Linear Predictive Coding (SLPC) Resynthesis'] +}, +{ + name: 'pvslpc', + type: 'opcode', + category: 'Spectral Processing:LPC', + description: 'Streaming linear prediction analysis.', + syntax: 'fsig = pvslpc(asrc, idftsiz, ihop, iord [, iwin])', + example: '--8<-- "examples/pvslpc.csd"', + parameters: [ + { + name: 'idftsiz', + description: 'size of lpc input frame in samples and fsig analysis frame. It needs to be a power-of-two.', + type: 'initialization' + }, + { + name: 'iord', + description: 'linear predictor order.', + type: 'initialization' + }, + { + name: 'ihop', + description: 'analysis hop size.', + type: 'initialization' + }, + { + name: 'iwin', + description: 'window function table number (optional).', + type: 'initialization' + }, + { + name: 'fsig', + description: 'fsig output', + type: 'performance' + }, + { + name: 'asrc', + description: 'source signal for lpc analysis', + type: 'performance' + }, + ], + seeAlso: ['Streaming Linear Predictive Coding (SLPC) Resynthesis'] +}, +{ + name: 'resonbnk', + type: 'opcode', + category: 'Spectral Processing:LPC', + description: 'A resonator filter bank.', + syntax: 'asig = resonbnk(ain, kPar[], kmin, kmax, iper [, imode, iscal, iskip])', + example: '--8<-- "examples/resonbnk.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'iper', + description: 'filter parameter interpolation period (in samples).', + type: 'initialization' + }, + { + name: 'imode', + description: 'filter connection mode (0 = serial, 1 = parallel, defaults to 1).', + type: 'initialization' + }, + { + name: 'iscal', + description: 'filter scaling mode (0 = no scaling, 1 and 2 modes as in reson, defaults to 0).', + type: 'initialization' + }, + { + name: 'iskip', + description: 'skip initialisation if non-zero (defaults to 0).', + type: 'initialization' + }, + { + name: 'asig', + description: 'output signal', + type: 'performance' + }, + { + name: 'ain', + description: 'input signal', + type: 'performance' + }, + { + name: 'kmin', + description: 'minimum filter frequency.', + type: 'performance' + }, + { + name: 'kmax', + description: 'maximum filter frequency.', + type: 'performance' + }, + ], + seeAlso: ['Streaming Linear Predictive Coding (SLPC) Resynthesis'] +}, +] diff --git a/src/lib/csound-reference/spectral-processing-non-standard.ts b/src/lib/csound-reference/spectral-processing-non-standard.ts new file mode 100644 index 0000000..f1db785 --- /dev/null +++ b/src/lib/csound-reference/spectral-processing-non-standard.ts @@ -0,0 +1,210 @@ +import type { CsoundReference } from './types' + +// Spectral Processing:Non-Standard +export const spectralProcessingNonStandard: CsoundReference[] = [ +{ + name: 'specaddm', + type: 'opcode', + category: 'Spectral Processing:Non-Standard', + description: 'Perform a weighted add of two input spectra.', + syntax: 'wsig = specaddm(wsig1, wsig2 [, imul2])', + parameters: [ + { + name: 'wsig1', + description: 'the first input spectra.', + type: 'performance' + }, + { + name: 'wsig2', + description: 'the second input spectra.', + type: 'performance' + }, + ], + seeAlso: ['specdiff', 'specfilt', 'spechist', 'specscal'] +}, +{ + name: 'specdiff', + type: 'opcode', + category: 'Spectral Processing:Non-Standard', + description: 'Finds the positive difference values between consecutive spectral frames.', + syntax: 'wsig = specdiff(wsigin)', + example: 'wsig2 specdiff wsig1 ; sense onsets \n wsig3 specfilt wsig2, 2 ; absorb slowly\n specdisp wsig2, 0.1 ; & display both spectra\n specdisp wsig3, 0.1', + parameters: [ + { + name: 'wsig', + description: 'the output spectrum.', + type: 'performance' + }, + { + name: 'wsigin', + description: 'the input spectra.', + type: 'performance' + }, + ], + seeAlso: ['specaddm', 'specfilt', 'spechist', 'specscal'] +}, +{ + name: 'specdisp', + type: 'opcode', + category: 'Spectral Processing:Non-Standard', + description: 'Displays the magnitude values of the spectrum.', + syntax: 'specdisp(wsig, iprd [, iwtflg])', + example: 'ksum specsum wsig, 1 ; sum the spec bins, and ksmooth\n if ksum < 2000 kgoto zero ; if sufficient amplitude\n koct specptrk wsig ; pitch-track the signal\n kgoto contin\nzero: \n koct = 0 ; else output zero\ncontin:', + parameters: [ + { + name: 'iprd', + description: 'the period, in seconds, of each new display.', + type: 'initialization' + }, + { + name: 'wsig', + description: 'the input spectrum.', + type: 'performance' + }, + ], + seeAlso: ['specsum'] +}, +{ + name: 'specfilt', + type: 'opcode', + category: 'Spectral Processing:Non-Standard', + description: 'Filters each channel of an input spectrum.', + syntax: 'wsig = specfilt(wsigin, ifhtim)', + example: 'wsig2 specdiff wsig1 ; sense onsets\n wsig3 specfilt wsig2, 2 ; absorb slowly\n specdisp wsig2, 0.1 ; & display both spectra\n specdisp wsig3, 0.1', + parameters: [ + { + name: 'ifhtim', + description: 'half-time constant.', + type: 'initialization' + }, + { + name: 'wsigin', + description: 'the input spectrum.', + type: 'performance' + }, + ], + seeAlso: ['specaddm', 'specdiff', 'spechist', 'specscal'] +}, +{ + name: 'spechist', + type: 'opcode', + category: 'Spectral Processing:Non-Standard', + description: 'Accumulates the values of successive spectral frames.', + syntax: 'wsig = spechist(wsigin)', + example: 'wsig2 specdiff wsig1 ; sense onsets\n wsig3 specfilt wsig2, 2 ; absorb slowly\n specdisp wsig2, 0.1 ; & display both spectra\n specdisp wsig3, 0.1', + parameters: [ + { + name: 'wsigin', + description: 'the input spectra.', + type: 'performance' + }, + ], + seeAlso: ['specaddm', 'specdiff', 'specfilt', 'specscal'] +}, +{ + name: 'specptrk', + type: 'opcode', + category: 'Spectral Processing:Non-Standard', + description: 'Estimates the pitch of the most prominent complex tone in the spectrum.', + syntax: 'koct, kamp = specptrk(wsig, kvar, ilo, ihi, istr, idbthresh, inptls, irolloff \\\n [, iodd] [, iconfs] [, interp] [, ifprd] [, iwtflg])', + example: 'a1, a2 ins ; read a stereo clarinet input\n krms rms a1, 20 ; find a monaural rms value\n kvar = 0.6 + krms/8000 ; & use to gate the pitch variance\n wsig spectrum a1, 0.01, 7, 24, 15, 0, 3 ; get a 7-oct spectrum, 24 bibs/oct\n specdisp wsig, 0.2 ; display this and now estimate\n ; the pch and amp\n koct, ka spectrk wsig, kvar, 7.0, 10, 9, 20, 4, 0.7, 1, 5, 1, 0.2\n aosc oscil ka * ka * 10, cpsoct(koct), 2 ; & generate \\ new tone with these\n koct = (koct < 7.0 ? 7.0 : koct) ; replace non pitch with low C\n display koct - 7.0, 0.25, 20 ; & display the pitch track\n display ka, 0.25, 20 ; plus the summed root mag\n outs a1, aosc ; output 1 original and 1 new track', + rates: ['k-rate'], + parameters: [ + { + name: 'ilo', + description: 'pitch range conditioners (low, high, and starting) expressed in decimal octave form.', + type: 'initialization' + }, + { + name: 'ihi', + description: 'pitch range conditioners (low, high, and starting) expressed in decimal octave form.', + type: 'initialization' + }, + { + name: 'istr', + description: 'pitch range conditioners (low, high, and starting) expressed in decimal octave form.', + type: 'initialization' + }, + { + name: 'idbthresh', + description: 'energy threshold (in decibels) for pitch tracking to occur. Once begun, tracking will be continuous until the energy falls below one half the threshold (6 dB down), whence the _koct_ and _kamp_ outputs will be zero until the full threshold is again surpassed. _idbthresh_ is a guiding value. At initialization it is first converted to the _idbout_ mode of the source spectrum (and the 6 dB down point becomes .5, .25, or 1/root 2 for modes 0, 2 and 3). The values are also further scaled to allow for the weighted partial summation used during correlation.The actual thresholding is done using the internal weighted and summed _kamp_ value that is visible as the second output parameter.', + type: 'initialization' + }, + { + name: 'inptls', + description: 'number of harmonic partials used as a matching template in the spectrally-based pitch detection, and an amplitude rolloff for the set expressed as some fraction per octave (linear, so don\'t roll off to negative). Since the partials and rolloff fraction can affect the pitch following, some experimentation will be useful: try 4 or 5 partials with .6 rolloff as an initial setting; raise to 10 or 12 partials with rolloff .75 for complex timbres like the bassoon (weak fundamental). Computation time is dependent on the number of partials sought. The maximum number is 16.', + type: 'initialization' + }, + { + name: 'irolloff', + description: 'number of harmonic partials used as a matching template in the spectrally-based pitch detection, and an amplitude rolloff for the set expressed as some fraction per octave (linear, so don\'t roll off to negative). Since the partials and rolloff fraction can affect the pitch following, some experimentation will be useful: try 4 or 5 partials with .6 rolloff as an initial setting; raise to 10 or 12 partials with rolloff .75 for complex timbres like the bassoon (weak fundamental). Computation time is dependent on the number of partials sought. The maximum number is 16.', + type: 'initialization' + }, + { + name: 'ilo', + description: '_ihi_ (decimal octave low and high pitch). _kvar_ can be dynamic, e.g. onset amp dependent. Pitch resolution uses the originating _spectrum_ _ifrqs_ bins/octave, with further parabolic interpolation between adjacent bins. Settings of root magnitude, _ifrqs_ = 24, _iq_ = 15 should capture all the inflections of interest. Between frames, the output is either repeated or interpolated at the k-rate. (See [spectrum](../opcodes/spectrum.md).)', + type: 'performance' + }, + ], +}, +{ + name: 'specscal', + type: 'opcode', + category: 'Spectral Processing:Non-Standard', + description: 'Scales an input spectral datablock with spectral envelopes.', + syntax: 'wsig = specscal(wsigin, ifscale, ifthresh)', + example: 'wsig2 specdiff wsig1 ; sense onsets\n wsig3 specfilt wsig2, 2 ; absorb slowly\n specdisp wsig2, 0.1 ; & display both spectra\n specdisp wsig3, 0.1', + parameters: [ + { + name: 'ifscale', + description: 'scale function table. A function table containing values by which a value\'s magnitude is rescaled.', + type: 'initialization' + }, + { + name: 'ifthresh', + description: 'threshold function table. If _ifthresh_ is non-zero, each magnitude is reduced by its corresponding table-value (to not less than zero)', + type: 'initialization' + }, + { + name: 'wsig', + description: 'the output spectrum', + type: 'performance' + }, + { + name: 'wsigin', + description: 'the input spectra', + type: 'performance' + }, + ], + seeAlso: ['specaddm', 'specdiff', 'specfilt', 'spechist'] +}, +{ + name: 'specsum', + type: 'opcode', + category: 'Spectral Processing:Non-Standard', + description: 'Sums the magnitudes across all channels of the spectrum.', + syntax: 'ksum = specsum(wsig [, interp])', + example: 'ksum specsum wsig, 1 ; sum the spec bins, and ksmooth\n if ksum < 2000 kgoto zero ; if sufficient amplitude\n koct specptrk wsig ; pitch-track the signal\n kgoto contin\nzero: \n koct = 0 ; else output zero\ncontin:', + parameters: [ + { + name: 'ksum', + description: 'the output signal.', + type: 'performance' + }, + { + name: 'wsig', + description: 'the input spectrum.', + type: 'performance' + }, + ], + seeAlso: ['specdisp'] +}, +{ + name: 'spectrum', + type: 'opcode', + category: 'Spectral Processing:Non-Standard', + description: 'Generate a constant-Q, exponentially-spaced DFT across all octaves of a multiply-downsampled control or audio input signal.', + syntax: 'wsig = spectrum(xsig, iprd, iocts, ifrqa [, iq] [, ihann] [, idbout] \\\n [, idsprd] [, idsinrs])', + example: 'asig in ; get external audio\nwsig spectrum asig, 0.02, 6, 12, 33, 0, 1, 1 ; downsample in 6 octs & calc a 72 pt dft\n ; (Q 33, dB out) every 20 msecs', +}, +] diff --git a/src/lib/csound-reference/spectral-processing-other.ts b/src/lib/csound-reference/spectral-processing-other.ts new file mode 100644 index 0000000..7e0809b --- /dev/null +++ b/src/lib/csound-reference/spectral-processing-other.ts @@ -0,0 +1,230 @@ +import type { CsoundReference } from './types' + +// Spectral Processing:Other +export const spectralProcessingOther: CsoundReference[] = [ +{ + name: 'centroid', + type: 'opcode', + category: 'Spectral Processing:Other', + description: 'Calculate the spectral centroid of an audio signal on a given trigger.', + syntax: 'kcent = centroid(asig, ktrig, ifftsize)', + example: '--8<-- "examples/centroid-modern.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'ifftsize', + description: 'fftsize. Non pow-of-two values are converted to the next pow-of-two not smaller than ifftsize.', + type: 'initialization' + }, + { + name: 'kcent', + description: 'the spectral centroid in Hz', + type: 'performance' + }, + { + name: 'asig', + description: 'an input audio signal', + type: 'performance' + }, + { + name: 'ktrig', + description: '1 to calculate a new centroid, 0 to skip the process (and output previous value).', + type: 'performance' + }, + ], + seeAlso: ['Sensing and Control: Tempo and Pitch estimation'] +}, +{ + name: 'filescal', + type: 'opcode', + category: 'Spectral Processing:Other', + description: 'Phase-locked vocoder processing with onset detection/processing, \'tempo-scaling\'.', + syntax: 'asig [,asig2] = filescal(ktimescal, kamp, kpitch, Sfile, klock \\\n [,ifftsize, idecim, ithresh])', + example: '--8<-- "examples/filescal.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'Sfile', + description: 'source soundfile, mono or stereo files are allowed, but need to match the number of outputs.', + type: 'initialization' + }, + { + name: 'ifftsize', + description: 'FFT size (power-of-two), defaults to 2048.', + type: 'initialization' + }, + { + name: 'idecim', + description: 'decimation, defaults to 4 (meaning hopsize = fftsize/4)', + type: 'initialization' + }, + { + name: 'idbthresh', + description: 'threshold based on dB power spectrum ratio between two successive windows. A detected ratio above it will cancel timescaling momentarily, to avoid smearing (defaults to 1)', + type: 'initialization' + }, + { + name: 'ktimescal', + description: 'timescaling ratio, < 1 stretch, > 1 contract. Non-negative numbers only.', + type: 'performance' + }, + { + name: 'kamp', + description: 'amplitude scaling', + type: 'performance' + }, + { + name: 'kpitch', + description: 'grain pitch scaling (1=normal pitch, < 1 lower, > 1 higher; negative, backwards)', + type: 'performance' + }, + { + name: 'klock', + description: 'switchec phase-locking on (non-zero) or off (zero).', + type: 'performance' + }, + ], + seeAlso: ['Short-time Fourier Transform (STFT) Resynthesis'] +}, +{ + name: 'mincer', + type: 'opcode', + category: 'Spectral Processing:Other', + description: 'Phase-locked vocoder processing.', + syntax: 'asig = mincer(atimpt, kamp, kpitch, ktab, klock [ ,ifftsize, idecim])', + example: '--8<-- "examples/mincer.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'ifftsize', + description: 'FFT size (power-of-two), defaults to 2048.', + type: 'initialization' + }, + { + name: 'idecim', + description: 'decimation, defaults to 4 (meaning hopsize = fftsize/4)', + type: 'initialization' + }, + { + name: 'atimpt', + description: 'time position of current audio sample in secs. Table reading wraps around the ends of the function table.', + type: 'performance' + }, + { + name: 'kamp', + description: 'amplitude scaling', + type: 'performance' + }, + { + name: 'kpitch', + description: 'grain pitch scaling (1=normal pitch, < 1 lower, > 1 higher; negative, backwards)', + type: 'performance' + }, + { + name: 'klock', + description: '0 or 1, to switch phase-locking on/off', + type: 'performance' + }, + { + name: 'ktab', + description: 'source signal function table. Deferred-allocation tables (see [GEN01](../scoregens/gen01.md)) are accepted, but the opcode expects a mono source. Tables can be switched at k-rate.', + type: 'performance' + }, + ], + seeAlso: ['Short-time Fourier Transform (STFT) Resynthesis'] +}, +{ + name: 'mp3scal', + type: 'opcode', + category: 'Spectral Processing:Other', + description: 'Phase-locked vocoder processing with onset detection/processing, \'tempo-scaling\'.', + syntax: 'asig, asig2, ktime = mp3scal(Sfile, ktimescal, kpitch, kamp \\\n [, iskip, ifftsize, idecim, ilock])\n )', + example: '--8<-- "examples/mp3scal.csd"', + rates: ['a-rate', 'k-rate'], + parameters: [ + { + name: 'Sfile', + description: 'source soundfile stereo mp3 files.', + type: 'initialization' + }, + { + name: 'ifftsize', + description: 'FFT size (power-of-two), defaults to 2048.', + type: 'initialization' + }, + { + name: 'idecim', + description: 'decimation, defaults to 4 (meaning hopsize = fftsize/4)', + type: 'initialization' + }, + { + name: 'iskip', + description: 'skiptime in seconds, defaults to 1.', + type: 'initialization' + }, + { + name: 'ilock', + description: '0 or 1, to switch phase-locking on/off, defaults to 1.', + type: 'initialization' + }, + { + name: 'ktimescal', + description: 'timescaling ratio, < 1 stretch, > 1 contract. Non-negative numbers only.', + type: 'performance' + }, + { + name: 'kamp', + description: 'amplitude scaling', + type: 'performance' + }, + { + name: 'kpitch', + description: 'grain pitch scaling (1=normal pitch, < 1 lower, > 1 higher)', + type: 'performance' + }, + { + name: 'ktime', + description: 'time stamp', + type: 'performance' + }, + { + name: 'asig', + description: 'stereo output signals', + type: 'performance' + }, + { + name: 'asig2', + description: 'stereo output signals', + type: 'performance' + }, + ], + seeAlso: ['Short-time Fourier Transform (STFT) Resynthesis'] +}, +{ + name: 'paulstretch', + type: 'opcode', + category: 'Spectral Processing:Other', + description: 'Extreme time-stretching algorithm by Nasca Octavian Paul.', + syntax: 'asig = paulstretch(istretch, iwindowsize, ift)', + example: '--8<-- "examples/paulstretch.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'istretch', + description: 'Stretch factor.', + type: 'initialization' + }, + { + name: 'iwindowsize', + description: 'Window size, in seconds.', + type: 'initialization' + }, + { + name: 'ift', + description: 'source signal function table. Deferred-allocation tables (see [GEN01](../scoregens/gen01.md)) are accepted, but the opcode expects a mono source.', + type: 'initialization' + }, + ], + seeAlso: ['Special Effects'] +}, +] diff --git a/src/lib/csound-reference/spectral-processing-stft.ts b/src/lib/csound-reference/spectral-processing-stft.ts new file mode 100644 index 0000000..b6c9750 --- /dev/null +++ b/src/lib/csound-reference/spectral-processing-stft.ts @@ -0,0 +1,211 @@ +import type { CsoundReference } from './types' + +// Spectral Processing:STFT +export const spectralProcessingStft: CsoundReference[] = [ +{ + name: 'pvadd', + type: 'opcode', + category: 'Spectral Processing:STFT', + description: 'Reads from a _pvoc_ file and uses the data to perform additive synthesis.', + syntax: 'ares = pvadd(ktimpnt, kfmod, ifilcod, ifn, ibins [, ibinoffset] \\\n [, ibinincr] [, iextractmode] [, ifreqlim] [, igatefn])', + example: 'ktime line 0, p3, p3\nasig pvadd ktime, 1, “oboe.pvoc”, 1, 100, 2', + rates: ['a-rate', 'i-rate'], + parameters: [ + { + name: 'ifilcod', + description: 'integer or character-string denoting a control-file derived from [pvanal](../utility/pvanal.md) analysis of an audio signal. An integer denotes the suffix of a file _pvoc.m_; a character-string (in double quotes) gives a filename, optionally a full pathname. If not fullpath, the file is sought first in the current directory, then in the one given by the environment variable [SADIR](../invoke/environment-variables.md) (if defined). _pvoc_ control files contain data organized for fft resynthesis. Memory usage depends on the size of the files involved, which are read and held entirely in memory during computation but are shared by multiple calls (see also [lpread](../opcodes/lpread.md)).', + type: 'initialization' + }, + { + name: 'ifn', + description: 'table number of a stored function containing a sine wave.', + type: 'initialization' + }, + { + name: 'ibins', + description: 'number of bins that will be used in the resynthesis (each bin counts as one oscillator in the re-synthesis)', + type: 'initialization' + }, + ], + seeAlso: ['Short-time Fourier Transform (STFT) Resynthesis'] +}, +{ + name: 'pvbufread', + type: 'opcode', + category: 'Spectral Processing:STFT', + description: 'Reads from a phase vocoder analysis file and makes the retrieved data available.', + syntax: 'pvbufread(ktimpnt, ifile)', + example: 'ktime1 line 0, p3, 3.5 ; used as index in the "oboe.pvoc" file\nktime2 line 0, p3, 4.5 ; used as index in the "clar.pvoc" file\nkinterp linseg 1, p3*0.15, 1, p3*0.35, 0, p3*0.25, 0, p3*0.15, 1, p3*0.1, 1\n pvbufread ktime1, "oboe.pvoc"\napv pvinterp ktime2,1,"clar.pvoc", 1, 1.065, 1, 0.75, 1-kinterp, 1-kinterp', + parameters: [ + { + name: 'ifile', + description: 'the _pvoc_ number (n in pvoc.n) or the name in quotes of the analysis file made using _pvanal_. (See [pvoc](../opcodes/pvoc.md).)', + type: 'initialization' + }, + { + name: 'ktimpnt', + description: 'the passage of time, in seconds, through this file. _ktimpnt_ must always be positive, but can move forwards or backwards in time, be stationary or discontinuous, as a pointer into the analysis file.', + type: 'performance' + }, + ], + seeAlso: ['Short-time Fourier Transform (STFT) Resynthesis'] +}, +{ + name: 'pvcross', + type: 'opcode', + category: 'Spectral Processing:STFT', + description: 'Applies the amplitudes from one phase vocoder analysis file to the data from a second file and then performs the resynthesis.', + syntax: 'ares = pvcross(ktimpnt, kfmod, ifile, kampscale1, kampscale2 [, ispecwp])', + example: 'ktime1 line 0, p3, 3.5 ; used as index in the "oboe.pvoc" file\nktime2 line 0, p3, 4.5 ; used as index in the "clar.pvoc" file\nkcross expon 0.001, p3, 1\n pvbufread ktime1, "oboe.pvoc"\napv pvcross ktime2, 1, "clar.pvoc", 1-kcross, kcross', + rates: ['a-rate'], + parameters: [ + { + name: 'ifile', + description: 'the _pvoc_ number (n in pvoc.n) or the name in quotes of the analysis file made using _pvanal_. (See [pvoc](../opcodes/pvoc.md).)', + type: 'initialization' + }, + { + name: 'ktimpnt', + description: 'the passage of time, in seconds, through this file. _ktimpnt_ must always be positive, but can move forwards or backwards in time, be stationary or discontinuous, as a pointer into the analysis file.', + type: 'performance' + }, + { + name: 'kfmod', + description: 'a control-rate transposition factor: a value of 1 incurs no transposition, 1.5 transposes up a perfect fifth, and 0.5 down an octave.', + type: 'performance' + }, + { + name: 'kampscale1', + description: 'used to scale the amplitudes stored in each frame of the phase vocoder analysis file. _kampscale1_ scale the amplitudes of the data from the file read by the previously called _pvbufread_. _kampscale2_ scale the amplitudes of the file named by _ifile_.', + type: 'performance' + }, + { + name: 'kampscale2', + description: 'used to scale the amplitudes stored in each frame of the phase vocoder analysis file. _kampscale1_ scale the amplitudes of the data from the file read by the previously called _pvbufread_. _kampscale2_ scale the amplitudes of the file named by _ifile_.', + type: 'performance' + }, + ], + seeAlso: ['Short-time Fourier Transform (STFT) Resynthesis'] +}, +{ + name: 'pvinterp', + type: 'opcode', + category: 'Spectral Processing:STFT', + description: 'Interpolates between the amplitudes and frequencies of two phase vocoder analysis files.', + syntax: 'ares = pvinterp(ktimpnt, kfmod, ifile, kfreqscale1, kfreqscale2, \\\n kampscale1, kampscale2, kfreqinterp, kampinterp)', + example: 'ktime1 line 0, p3, 3.5 ; used as index in the "oboe.pvoc" file\nktime2 line 0, p3, 4.5 ; used as index in the "clar.pvoc" file\nkinterp linseg 1, p3*0.15, 1, p3*0.35, 0, p3*0.25, 0, p3*0.15, 1, p3*0.1, 1\n pvbufread ktime1, "oboe.pvoc"\napv pvinterp ktime2,1,"clar.pvoc", 1, 1.065, 1, 0.75, 1-kinterp, 1-kinterp', + rates: ['a-rate'], + parameters: [ + { + name: 'ifile', + description: 'the _pvoc_ number (n in pvoc.n) or the name in quotes of the analysis file made using pvanal. (See [pvoc](../opcodes/pvoc.md).)', + type: 'initialization' + }, + { + name: 'ktimpnt', + description: 'the passage of time, in seconds, through this file. _ktimpnt_ must always be positive, but can move forwards or backwards in time, be stationary or discontinuous, as a pointer into the analysis file.', + type: 'performance' + }, + { + name: 'kfmod', + description: 'a control-rate transposition factor: a value of 1 incurs no transposition, 1.5 transposes up a perfect fifth, and .5 down an octave.', + type: 'performance' + }, + { + name: 'kfreqscale1', + description: 'used in _pvinterp_ to scale the frequencies and amplitudes stored in each frame of the phase vocoder analysis file. _kfreqscale1_ and _kampscale1_ scale the frequencies and amplitudes of the data from the file read by the previously called [pvbufread](../opcodes/pvbufread.md) (this data is passed internally to the _pvinterp_ unit). _kfreqscale2_ and _kampscale2_ scale the frequencies and amplitudes of the file named by _ifile_ in the _pvinterp_ argument list and read within the _pvinterp_ unit.', + type: 'performance' + }, + { + name: 'kfreqscale2', + description: 'used in _pvinterp_ to scale the frequencies and amplitudes stored in each frame of the phase vocoder analysis file. _kfreqscale1_ and _kampscale1_ scale the frequencies and amplitudes of the data from the file read by the previously called [pvbufread](../opcodes/pvbufread.md) (this data is passed internally to the _pvinterp_ unit). _kfreqscale2_ and _kampscale2_ scale the frequencies and amplitudes of the file named by _ifile_ in the _pvinterp_ argument list and read within the _pvinterp_ unit.', + type: 'performance' + }, + { + name: 'kampscale1', + description: 'used in _pvinterp_ to scale the frequencies and amplitudes stored in each frame of the phase vocoder analysis file. _kfreqscale1_ and _kampscale1_ scale the frequencies and amplitudes of the data from the file read by the previously called [pvbufread](../opcodes/pvbufread.md) (this data is passed internally to the _pvinterp_ unit). _kfreqscale2_ and _kampscale2_ scale the frequencies and amplitudes of the file named by _ifile_ in the _pvinterp_ argument list and read within the _pvinterp_ unit.', + type: 'performance' + }, + { + name: 'kampscale2', + description: 'used in _pvinterp_ to scale the frequencies and amplitudes stored in each frame of the phase vocoder analysis file. _kfreqscale1_ and _kampscale1_ scale the frequencies and amplitudes of the data from the file read by the previously called [pvbufread](../opcodes/pvbufread.md) (this data is passed internally to the _pvinterp_ unit). _kfreqscale2_ and _kampscale2_ scale the frequencies and amplitudes of the file named by _ifile_ in the _pvinterp_ argument list and read within the _pvinterp_ unit.', + type: 'performance' + }, + { + name: 'kfreqinterp', + description: 'used in _pvinterp_, determine the interpolation distance between the values of one phase vocoder file and the values of a second file. When the value of _kfreqinterp_ is 1, the frequency values will be entirely those from the first file (read by the _pvbufread_), post scaling by the _kfreqscale1_ argument. When the value of _kfreqinterp_ is 0 the frequency values will be those of the second file (read by the _pvinterp_ unit itself), post scaling by _kfreqscale2_. When _kfreqinterp_ is between 0 and 1 the frequency values will be calculated, on a bin, by bin basis, as the percentage between each pair of frequencies (in other words, _kfreqinterp_=0.5 will cause the frequencies values to be half way between the values in the set of data from the first file and the set of data from the second file).', + type: 'performance' + }, + { + name: 'kampinterp', + description: 'used in _pvinterp_, determine the interpolation distance between the values of one phase vocoder file and the values of a second file. When the value of _kfreqinterp_ is 1, the frequency values will be entirely those from the first file (read by the _pvbufread_), post scaling by the _kfreqscale1_ argument. When the value of _kfreqinterp_ is 0 the frequency values will be those of the second file (read by the _pvinterp_ unit itself), post scaling by _kfreqscale2_. When _kfreqinterp_ is between 0 and 1 the frequency values will be calculated, on a bin, by bin basis, as the percentage between each pair of frequencies (in other words, _kfreqinterp_=0.5 will cause the frequencies values to be half way between the values in the set of data from the first file and the set of data from the second file).', + type: 'performance' + }, + ], + seeAlso: ['Short-time Fourier Transform (STFT) Resynthesis'] +}, +{ + name: 'pvoc', + type: 'opcode', + category: 'Spectral Processing:STFT', + description: 'Implements signal reconstruction using an fft-based phase vocoder.', + syntax: 'ares = pvoc(ktimpnt, kfmod, ifilcod [, ispecwp] [, iextractmode] \\\n [, ifreqlim] [, igatefn])', + example: '--8<-- "examples/pvoc.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'ifilcod', + description: 'integer or character-string denoting a control-file derived from analysis of an audio signal. An integer denotes the suffix of a file _pvoc.m_; a character-string (in double quotes) gives a filename, optionally a full pathname. If not fullpath, the file is sought first in the current directory, then in the one given by the environment variable [SADIR](../invoke/environment-variables.md) (if defined). _pvoc_ control contains breakpoint amplitude and frequency envelope values organized for fft resynthesis. Memory usage depends on the size of the files involved, which are read and held entirely in memory during computation but are shared by multiple calls (see also [lpread](../opcodes/lpread.md)).', + type: 'initialization' + }, + { + name: 'ktimpnt', + description: 'The passage of time, in seconds, through the analysis file. _ktimpnt_ must always be positive, but can move forwards or backwards in time, be stationary or discontinuous, as a pointer into the analysis file.', + type: 'performance' + }, + { + name: 'kfmod', + description: 'a control-rate transposition factor: a value of 1 incurs no transposition, 1.5 transposes up a perfect fifth, and .5 down an octave.', + type: 'performance' + }, + ], + seeAlso: ['Short-time Fourier Transform (STFT) Resynthesis'] +}, +{ + name: 'pvread', + type: 'opcode', + category: 'Spectral Processing:STFT', + description: 'Reads from a [pvoc](../opcodes/pvoc.md) file and returns the frequency and amplitude from a single analysis channel or bin.', + syntax: 'kfreq, kamp = pvread(ktimpnt, ifile, ibin)', + example: '--8<-- "examples/pvread.csd"', + rates: ['k-rate'], + parameters: [ + { + name: 'ifile', + description: 'the _pvoc_ number (n in pvoc.n) or the name in quotes of the analysis file made using _pvanal_. (See [pvoc](../opcodes/pvoc.md).)', + type: 'initialization' + }, + { + name: 'ibin', + description: 'the number of the analysis channel from which to return frequency in Hz and magnitude.', + type: 'initialization' + }, + { + name: 'kfreq', + description: 'outputs of the _pvread_ unit. These values, retrieved from a phase vocoder analysis file, represent the values of frequency and amplitude from a single analysis channel specified in the _ibin_ argument. Interpolation between analysis frames is performed at k-rate resolution and dependent of course upon the rate and direction of _ktimpnt_.', + type: 'performance' + }, + { + name: 'kamp', + description: 'outputs of the _pvread_ unit. These values, retrieved from a phase vocoder analysis file, represent the values of frequency and amplitude from a single analysis channel specified in the _ibin_ argument. Interpolation between analysis frames is performed at k-rate resolution and dependent of course upon the rate and direction of _ktimpnt_.', + type: 'performance' + }, + { + name: 'ktimpnt', + description: 'the passage of time, in seconds, through this file. _ktimpnt_ must always be positive, but can move forwards or backwards in time, be stationary or discontinuous, as a pointer into the analysis file.', + type: 'performance' + }, + ], + seeAlso: ['Short-time Fourier Transform (STFT) Resynthesis'] +}, +] diff --git a/src/lib/csound-reference/spectral-processing-streaming.ts b/src/lib/csound-reference/spectral-processing-streaming.ts new file mode 100644 index 0000000..e5bf8cb --- /dev/null +++ b/src/lib/csound-reference/spectral-processing-streaming.ts @@ -0,0 +1,1569 @@ +import type { CsoundReference } from './types' + +// Spectral Processing:Streaming +export const spectralProcessingStreaming: CsoundReference[] = [ +{ + name: 'binit', + type: 'opcode', + category: 'Spectral Processing:Streaming', + description: 'PVS tracks to amplitude+frequency conversion.', + syntax: 'fsig = binit(fin, isize)', + example: '--8<-- "examples/binit-modern.csd"', + parameters: [ + { + name: 'fsig', + description: 'output pv stream in PVS_AMP_FREQ format', + type: 'performance' + }, + { + name: 'fin', + description: 'input pv stream in TRACKS format', + type: 'performance' + }, + { + name: 'isize', + description: 'FFT size of output (N).', + type: 'performance' + }, + ], + seeAlso: ['Tools for Real-time Spectral Processing (pvs opcodes)'] +}, +{ + name: 'part2txt', + type: 'opcode', + category: 'Spectral Processing:Streaming', + description: 'Write a text file containing partial tracks data.', + syntax: 'part2txt(SFile, ftrks)', + example: '--8<-- "examples/part2txt.csd"', + parameters: [ + { + name: 'SFile', + description: 'output filename', + type: 'initialization' + }, + { + name: 'ftrks', + description: 'output pv stream in TRACKS format', + type: 'performance' + }, + ], + seeAlso: ['Tools for Real-time Spectral Processing (pvs opcodes)'] +}, +{ + name: 'partials', + type: 'opcode', + category: 'Spectral Processing:Streaming', + description: 'Partial track spectral analysis.', + syntax: 'ftrks = partials(ffr, fphs, kthresh, kminpts, kmaxgap, imaxtracks)', + example: '--8<-- "examples/partials.csd"', + parameters: [ + { + name: 'ftrks', + description: 'output pv stream in TRACKS format', + type: 'performance' + }, + { + name: 'ffr', + description: 'input pv stream in AMP_FREQ format', + type: 'performance' + }, + { + name: 'fphs', + description: 'input pv stream in AMP_PHASE format', + type: 'performance' + }, + { + name: 'kthresh', + description: 'analysis threshold factor, defined between -1 and 1. If non-negative, the analysis threshold is taken to be relative to the maximum magnitude in each analysis frame (kthresh * max_magnitude). If negative, the absolute threshold value is relative to 0dbfs (kthresh * 0dbfs). Tracks below this threshold will be discarded.', + type: 'performance' + }, + { + name: 'kminpoints', + description: 'minimum number of time points for a detected peak to make a track (1 is the minimum). Since this opcode works with streaming signals, larger numbers will increase the delay between input and output, as we have to wait for the required minimum number of points.', + type: 'performance' + }, + { + name: 'kmaxgap', + description: 'maximum gap between time-points for track continuation (> 0). Tracks that have no continuation after kmaxgap will be discarded.', + type: 'performance' + }, + { + name: 'imaxtracks', + description: 'maximum number of analysis tracks (number of bins >= imaxtracks)', + type: 'performance' + }, + ], + seeAlso: ['Tools for Real-time Spectral Processing (pvs opcodes)'] +}, +{ + name: 'pvs2array', + type: 'opcode', + category: 'Spectral Processing:Streaming', + description: 'Same as the [pvs2tab](../opcodes/pvs2tab.md) opcode.', + syntax: 'kframe = pvs2array(kvar[], fsig)\n kframe = pvs2array(kmags[], kfreqs[], fsig)', +}, +{ + name: 'pvs2tab', + type: 'opcode', + category: 'Spectral Processing:Streaming', + description: 'Copies spectral data to k-rate arrays (or t-variables). Also known as [pvs2array](pvs2array.md).', + syntax: 'kframe = pvs2tab(tvar|kvar[], fsig)\n kframe = pvs2tab(kmags[], kfreqs[], fsig)', + example: 'karr[] init 1026\na1 inch 1\nfsig1 pvsanal a1, 1024,256,1024, 1\nkframe pvs2tab karr, fsig1', + parameters: [ + { + name: 'kframe', + description: 'current copied frame number. It can be used to detect when a new frame has been copied.', + type: 'performance' + }, + { + name: 'fsig', + description: 'input fsig to be copied.', + type: 'performance' + }, + ], + seeAlso: ['Tools for Real-time Spectral Processing (pvs opcodes)', 'Array-based spectral opcodes'] +}, +{ + name: 'pvsadsyn', + type: 'opcode', + category: 'Spectral Processing:Streaming', + description: 'Resynthesize using a fast oscillator-bank.', + syntax: 'ares = pvsadsyn(fsrc, inoscs, kfmod [, ibinoffset] [, ibinincr] [, iinit])', + example: '--8<-- "examples/pvsadsyn.csd"', + rates: ['a-rate'], + parameters: [ + { + name: 'inoscs', + description: 'The number of analysis bins to synthesise. Cannot be larger than the size of fsrc (see [pvsinfo](../opcodes/pvsinfo.md)), e.g. as created by [pvsanal](../opcodes/pvsanal.md). Processing time is directly proportional to inoscs.', + type: 'initialization' + }, + { + name: 'kfmod', + description: 'Scale all frequencies by factor kfmod. 1.0 = no change, 2 = up one octave.', + type: 'performance' + }, + ], + seeAlso: ['Tools for Real-time Spectral Processing (pvs opcodes)'] +}, +{ + name: 'pvsanal', + type: 'opcode', + category: 'Spectral Processing:Streaming', + description: 'Generate an fsig from a mono audio source ain, using phase vocoder overlap-add analysis.', + syntax: 'fsig = pvsanal(ain, ifftsize, ioverlap, iwinsize, iwintype [, iformat] [, iinit])', + example: '--8<-- "examples/pvsanal.csd"', + parameters: [ + { + name: 'ifftsize', + description: 'The FFT size in samples. Need not be a power of two (though these are especially efficient), but must be even. Odd numbers are rounded up internally. _ifftsize_ determines the number of analysis bins in _fsig_, as _ifftsize/2 + 1_. For example, where _ifftsize_ = 1024, _fsig_ will contain 513 analysis bins, ordered linearly from the fundamental to Nyquist. The fundamental of analysis (which in principle gives the lowest resolvable frequency) is determined as _sr/ifftsize_. Thus, for the example just given and assuming _sr_ = 44100, the fundamental of analysis is 43.07Hz. In practice, due to the phase-preserving nature of the phase vocoder, the frequency of any bin can deviate bilaterally, so that DC components are recorded. Given a strongly pitched signal, frequencies in adjacent bins can bunch very closely together, around partials in the source, and the lowest bins may even have negative frequencies.', + type: 'initialization' + }, + { + name: 'ioverlap', + description: 'The distance in samples (“hop size”) between overlapping analysis frames. As a rule, this needs to be at least _ifftsize/4_, e.g. 256 for the example above. _ioverlap_ determines the underlying analysis rate, as _sr/ioverlap_. _ioverlap_ does not require to be a simple factor of _ifftsize_; for example a value of 160 would be legal. The choice of _ioverlap_ may be dictated by the degree of pitch modification applied to the _fsig_, if any. As a rule of thumb, the more extreme the pitch shift, the higher the analysis rate needs to be, and hence the smaller the value for _ioverlap_. A higher analysis rate can also be advantageous with broadband transient sounds, such as drums (where a small analysis window gives less smearing, but more frequency-related errors).', + type: 'initialization' + }, + { + name: 'iwinsize', + description: 'The size in samples of the analysis window filter (as set by _iwintype_). This must be at least _ifftsize_, and can usefully be larger. Though other proportions are permitted, it is recommended that _iwinsize_ always be an integral multiple of _ifftsize_, e.g. 2048 for the example above. Internally, the analysis window (Hamming, von Hann) is multiplied by a sinc function, so that amplitudes are zero at the boundaries between frames. The larger analysis window size has been found to be especially important for oscillator bank resynthesis (e.g. using _pvsadsyn_), as it has the effect of increasing the frequency resolution of the analysis, and hence the accuracy of the resynthesis. As noted above, _iwinsize_ determines the overall latency of the analysis/resynthesis system. In many cases, and especially in the absence of pitch modifications, it will be found that setting _iwinsize=ifftsize_ works very well, and offers the lowest latency.', + type: 'initialization' + }, + { + name: 'iwintype', + description: 'The shape of the analysis window. Currently three choices computed windows implemented:', + type: 'initialization' + }, + { + name: 'iformat', + description: '(optional) The analysis format. Currently only one format is implemented by this opcode:', + type: 'initialization' + }, + { + name: 'iinit', + description: '(optional) Skip reinitialization. This is not currently implemented for any of these opcodes, and it remains to be seen if it is even practical.', + type: 'initialization' + }, + ], + seeAlso: ['Tools for Real-time Spectral Processing (pvs opcodes)'] +}, +{ + name: 'pvsarp', + type: 'opcode', + category: 'Spectral Processing:Streaming', + description: 'Arpeggiate the spectral components of a streaming pv signal.', + syntax: 'fsig = pvsarp(fsigin, kbin, kdepth, kgain)', + example: '--8<-- "examples/pvsarp.csd"', + parameters: [ + { + name: 'fsig', + description: 'output pv stream', + type: 'performance' + }, + { + name: 'fsigin', + description: 'input pv stream', + type: 'performance' + }, + { + name: 'kbin', + description: 'target bin, normalised 0 - 1 (0Hz - Nyquist).', + type: 'performance' + }, + { + name: 'kdepth', + description: 'depth of attenuation of surrounding bins', + type: 'performance' + }, + { + name: 'kgain', + description: 'gain boost applied to target bin', + type: 'performance' + }, + ], + seeAlso: ['Tools for Real-time Spectral Processing (pvs opcodes)'] +}, +{ + name: 'pvsbandp', + type: 'opcode', + category: 'Spectral Processing:Streaming', + description: 'A band pass filter working in the spectral domain.', + syntax: 'fsig = pvsbandp(fsigin, xlowcut, xlowfull, xhighfull, xhighcut [, ktype])', + example: '--8<-- "examples/pvsbandp.csd"', + parameters: [ + { + name: 'fsig', + description: 'output pv stream', + type: 'performance' + }, + { + name: 'fsigin', + description: 'input pv stream.', + type: 'performance' + }, + { + name: 'xlowcut', + description: 'define a trapezium shape for the band that is passed. The a-rate versions only apply to the sliding case.', + type: 'performance' + }, + { + name: 'xlowfull', + description: 'define a trapezium shape for the band that is passed. The a-rate versions only apply to the sliding case.', + type: 'performance' + }, + { + name: 'xhighfull', + description: 'define a trapezium shape for the band that is passed. The a-rate versions only apply to the sliding case.', + type: 'performance' + }, + { + name: 'xhighcut', + description: 'define a trapezium shape for the band that is passed. The a-rate versions only apply to the sliding case.', + type: 'performance' + }, + { + name: 'ktype', + description: 'specifies the shape of the transitional band. If at the default value of zero the shape is as below, with linear transition in amplitude. Other values yield and exponential shape:', + type: 'performance' + }, + ], + seeAlso: ['Tools for Real-time Spectral Processing (pvs opcodes)'] +}, +{ + name: 'pvsbandr', + type: 'opcode', + category: 'Spectral Processing:Streaming', + description: 'A band reject filter working in the spectral domain.', + syntax: 'fsig = pvsbandr(fsigin, xlowcut, xlowfull, xhighfull, xhighcut [, ktype])', + example: '--8<-- "examples/pvsbandr.csd"', + parameters: [ + { + name: 'fsig', + description: 'output pv stream', + type: 'performance' + }, + { + name: 'fsigin', + description: 'input pv stream.', + type: 'performance' + }, + { + name: 'xlowcut', + description: 'define a trapezium shape for the band that is rejected. The a-rate versions only apply to the sliding case.', + type: 'performance' + }, + { + name: 'xlowfull', + description: 'define a trapezium shape for the band that is rejected. The a-rate versions only apply to the sliding case.', + type: 'performance' + }, + { + name: 'xhighfull', + description: 'define a trapezium shape for the band that is rejected. The a-rate versions only apply to the sliding case.', + type: 'performance' + }, + { + name: 'xhighcut', + description: 'define a trapezium shape for the band that is rejected. The a-rate versions only apply to the sliding case.', + type: 'performance' + }, + { + name: 'ktype', + description: 'specifies the shape of the transitional band. If at the default value of zero the shape is as below, with linear transition in amplitude. Other values give an exponential curve', + type: 'performance' + }, + ], + seeAlso: ['Tools for Real-time Spectral Processing (pvs opcodes)'] +}, +{ + name: 'pvsbandwidth', + type: 'opcode', + category: 'Spectral Processing:Streaming', + description: 'Calculate the spectral bandwidth of a signal from its discrete Fourier transform.', + syntax: 'kbnd = pvsbandwidth(fsig)', + example: '--8<-- "examples/pvsbandwidth.csd"', + parameters: [ + { + name: 'kbnd', + description: 'the spectral bandwidth', + type: 'performance' + }, + { + name: 'fsig', + description: 'an input pv stream', + type: 'performance' + }, + ], + seeAlso: ['Tools for Real-time Spectral Processing (pvs opcodes)'] +}, +{ + name: 'pvsbin', + type: 'opcode', + category: 'Spectral Processing:Streaming', + description: 'Obtain the amp and freq values off a PVS signal bin as k-rate variables.', + syntax: 'kamp, kfr = pvsbin(fsig, kbin)', + example: '--8<-- "examples/pvsbin.csd"', + rates: ['k-rate'], + parameters: [ + { + name: 'kamp', + description: 'bin amplitude', + type: 'performance' + }, + { + name: 'kfr', + description: 'bin frequency', + type: 'performance' + }, + { + name: 'fsig', + description: 'an input pv stream', + type: 'performance' + }, + { + name: 'kbin', + description: 'bin number', + type: 'performance' + }, + ], + seeAlso: ['Tools for Real-time Spectral Processing (pvs opcodes)'] +}, +{ + name: 'pvsblur', + type: 'opcode', + category: 'Spectral Processing:Streaming', + description: 'Average the amp/freq time functions of each analysis channel for a specified time (truncated to number of frames).', + syntax: 'fsig = pvsblur(fsigin, kblurtime, imaxdel)', + example: '--8<-- "examples/pvsblur.csd"', + parameters: [ + { + name: 'fsig', + description: 'output pv stream', + type: 'performance' + }, + { + name: 'fsigin', + description: 'input pv stream.', + type: 'performance' + }, + { + name: 'kblurtime', + description: 'time in secs during which windows will be averaged .', + type: 'performance' + }, + { + name: 'imaxdel', + description: 'maximum delay time, used for allocating memory used in the averaging operation.', + type: 'performance' + }, + ], + seeAlso: ['Tools for Real-time Spectral Processing (pvs opcodes)'] +}, +{ + name: 'pvsbuffer', + type: 'opcode', + category: 'Spectral Processing:Streaming', + description: 'This opcode creates and writes to a circular buffer for f-signals (streaming PV signals).', + syntax: 'ihandle, ktime = pvsbuffer(fsig, ilen)', + example: '--8<-- "examples/pvsbuffer.csd"', + parameters: [ + { + name: 'fsig', + description: 'an input pv stream', + type: 'performance' + }, + { + name: 'ktime', + description: 'the current time of writing in the buffer', + type: 'performance' + }, + ], + seeAlso: ['Tools for Real-time Spectral Processing (pvs opcodes)'] +}, +{ + name: 'pvsbufread', + type: 'opcode', + category: 'Spectral Processing:Streaming', + description: 'This opcode reads a circular buffer of f-signals (streaming PV signals).', + syntax: 'fsig = pvsbufread(ktime, khandle [, ilo, ihi, iclear])', + example: 'fsig1 pvsanal asig1, 1024, 256, 1024, 1\nfsig2 pvsanal asig2, 1024, 256, 1024, 1\n\n\nibuf1, kt1 pvsbuffer fsig1, 10 ; 10-sec buf with fsig1\nibuf2, kt2 pvsbuffer fsig2, 7 ; 7-sec buf with fsig2\n\nkhan init ibuf1 ; initialise handle to buf1\n\nif ktrig > 0 then ; switch buffers according to trigger\nkhan = ibuf2\nelse\nkhan = ibuf1\nendif\n\nfsb pvsbufread kt1, khan ; read buffer', + parameters: [ + { + name: 'fsig', + description: 'output pv stream', + type: 'performance' + }, + { + name: 'ktime', + description: 'time position of reading pointer (in secs).', + type: 'performance' + }, + { + name: 'khandle', + description: 'handle identifying the buffer to be read. When using k-rate handles, it is important to initialise the k-rate variable to a given existing handle. When changing buffers, fsig buffers need to be compatible (same fsig format).', + type: 'performance' + }, + ], + seeAlso: ['Tools for Real-time Spectral Processing (pvs opcodes)'] +}, +{ + name: 'pvsbufread2', + type: 'opcode', + category: 'Spectral Processing:Streaming', + description: 'This opcode reads a circular buffer of f-signals (streaming PV signals), with binwise additional delays.', + syntax: 'fsig = pvsbufread2(ktime, khandle, ift1, ift2)', + example: '--8<-- "examples/pvsbufread2.csd"', + parameters: [ + { + name: 'ift1', + description: 'function table with at least fftisze/2+1 points where delays (in secs) for bin amplitudes are set (function table positions are equivalent to bin numbers)', + type: 'initialization' + }, + { + name: 'ift2', + description: 'function table with at least fftisze/2+1 points where delays (in secs) for bin frequencies are set (function table positions are equivalent to bin numbers)', + type: 'initialization' + }, + { + name: 'fsig', + description: 'output pv stream', + type: 'performance' + }, + { + name: 'ktime', + description: 'time position of reading pointer (in secs).', + type: 'performance' + }, + { + name: 'khandle', + description: 'handle identifying the buffer to be read. When using k-rate handles, it is important to initialise the k-rate variable to a given existing handle. When changing buffers, fsig buffers need to be compatible (same fsig format).', + type: 'performance' + }, + ], + seeAlso: ['Tools for Real-time Spectral Processing (pvs opcodes)'] +}, +{ + name: 'pvscale', + type: 'opcode', + category: 'Spectral Processing:Streaming', + description: 'Scale the frequency components of a pv stream, resulting in pitch shift.', + syntax: 'fsig = pvscale(fsigin, kscal [, kkeepform, kgain, kcoefs])', + example: 'asig in ; get the signal in\n\nfsig pvsanal asig, 1024, 256, 1024, 1 ; analyse it\nftps pvscale fsig, 1.5, 1, 1 ; transpose it keeping formants\natps pvsynth ftps ; synthesise it\n\nadp delayr 0.1 ; delay original signal\nadel deltapn 1024 ; by 1024 samples\n delayw asig\n out atps + adel ; add tranposed and original', + parameters: [ + { + name: 'fsig', + description: 'output pv stream', + type: 'performance' + }, + { + name: 'fsigin', + description: 'input pv stream', + type: 'performance' + }, + { + name: 'kscal', + description: 'scaling ratio.', + type: 'performance' + }, + { + name: 'kkeepform', + description: 'attempt to keep input signal formants; 0: do not keep formants; 1: keep formants using a liftered cepstrum method; 2: keep formants by using a true envelope method (defaults to 0).', + type: 'performance' + }, + { + name: 'kgain', + description: 'amplitude scaling (defaults to 1).', + type: 'performance' + }, + { + name: 'kcoefs', + description: 'number of cepstrum coefs used in formant preservation (defaults to 80).', + type: 'performance' + }, + ], + seeAlso: ['Tools for Real-time Spectral Processing (pvs opcodes)'] +}, +{ + name: 'pvscent', + type: 'opcode', + category: 'Spectral Processing:Streaming', + description: 'Calculate the spectral centroid of a signal from its discrete Fourier transform.', + syntax: 'kcent = pvscent(fsig)\n acent = pvscent(fsig)', + example: '--8<-- "examples/pvscent.csd"', + parameters: [ + { + name: 'kcent', + description: 'the spectral centroid', + type: 'performance' + }, + { + name: 'acent', + description: 'the spectral centroid', + type: 'performance' + }, + { + name: 'fsig', + description: 'an input pv stream', + type: 'performance' + }, + ], + seeAlso: ['Tools for Real-time Spectral Processing (pvs opcodes)'] +}, +{ + name: 'pvsceps', + type: 'opcode', + category: 'Spectral Processing:Streaming', + description: 'Calculate the cepstrum of a pvs input, optionally liftering coefficients.', + syntax: 'keps[] = pvsceps(fsig[, icoefs])', + example: '--8<-- "examples/pvsceps.csd"', + parameters: [ + { + name: 'icoefs', + description: 'the number of retained coefficients in the cepstrum output. By default, no coefficients are liftered.', + type: 'initialization' + }, + { + name: 'fsig', + description: 'an input pv stream', + type: 'performance' + }, + ], + seeAlso: ['Tools for Real-time Spectral Processing (pvs opcodes)'] +}, +{ + name: 'pvscross', + type: 'opcode', + category: 'Spectral Processing:Streaming', + description: 'Performs cross-synthesis between two source fsigs.', + syntax: 'fsig = pvscross(fsrc, fdest, kamp1, kamp2)', + example: '--8<-- "examples/pvscross.csd"', + seeAlso: ['Tools for Real-time Spectral Processing (pvs opcodes)'] +}, +{ + name: 'pvsdemix', + type: 'opcode', + category: 'Spectral Processing:Streaming', + description: 'Spectral azimuth-based de-mixing of stereo sources, with a reverse-panning result.', + syntax: 'fsig = pvsdemix(fleft, fright, kpos, kwidth, ipoints)', + example: 'ifftsize = 1024 \niwtype = 1 /* cleaner with hanning window */\nipos = -0.8 /* to the left of the stereo image */\niwidth = 20 /* use peaks of 20 points around it */\n\nal,ar soundin "sinput.wav"\n\nflc pvsanal al, ifftsize, ifftsize/4, ifftsize, iwtype\nfrc pvsanal ar, ifftsize, ifftsize/4, ifftsize, iwtype\nfdm pvsdemix flc, frc, kpos, kwidth, 100\nadm pvsynth fdm\n \n outs adm, adm', + parameters: [ + { + name: 'fsig', + description: 'output pv stream', + type: 'performance' + }, + { + name: 'fleft', + description: 'left channel input pv stream.', + type: 'performance' + }, + { + name: 'fright', + description: 'right channel pv stream.', + type: 'performance' + }, + { + name: 'kpos', + description: 'the azimuth target centre position, which will be de-mixed, from left to right (-1 <= _kpos_ <= 1). This is the reverse pan-pot control.', + type: 'performance' + }, + { + name: 'kwidth', + description: 'the azimuth subspace width, which will determine the number of points around _kpos_ which will be used in the de-mixing process. (1 <= _kwidth_ <= _ipoints_)', + type: 'performance' + }, + { + name: 'ipoints', + description: 'total number of discrete points, which will divide each pan side of the stereo image. This ultimately affects the resolution of the process.', + type: 'performance' + }, + ], + seeAlso: ['Tools for Real-time Spectral Processing (pvs opcodes)'] +}, +{ + name: 'pvsdiskin', + type: 'opcode', + category: 'Spectral Processing:Streaming', + description: 'Create an fsig stream by reading a selected channel from a PVOC-EX analysis file, with frame interpolation.', + syntax: 'fsig = pvsdiskin(SFname, ktscal, kgain [, ioffset, ichan])', + example: '--8<-- "examples/pvsdiskin.csd"', + parameters: [ + { + name: 'Sfname', + description: 'Name of the analysis file. This must have the .pvx file extension.', + type: 'initialization' + }, + { + name: 'ichan', + description: '(optional) The channel to read (counting from 1). Default is 1.', + type: 'initialization' + }, + { + name: 'ioff', + description: 'start offset from beginning of file (secs) (default: 0) .', + type: 'initialization' + }, + { + name: 'ktscal', + description: 'time scale, ie. the read pointer speed (1 is normal speed, negative is backwards, 0 < ktscal < 1 is slower and ktscal > 1 is faster)', + type: 'performance' + }, + { + name: 'kgain', + description: 'gain scaling.', + type: 'performance' + }, + ], + seeAlso: ['Tools for Real-time Spectral Processing (pvs opcodes)'] +}, +{ + name: 'pvsdisp', + type: 'opcode', + category: 'Spectral Processing:Streaming', + description: 'Displays a PVS signal as an amplitude vs. freq graph.', + syntax: 'pvsdisp(fsig [, ibins, iwtflg])', + example: '--8<-- "examples/pvsdisp.csd"', + parameters: [ + { + name: 'pvsdisp', + description: 'displays the PVS signal frame-by-frame.', + type: 'performance' + }, + ], + seeAlso: ['Tools for Real-time Spectral Processing (pvs opcodes)'] +}, +{ + name: 'pvsfilter', + type: 'opcode', + category: 'Spectral Processing:Streaming', + description: 'Multiply amplitudes of a pvoc stream by those of a second pvoc stream, with dynamic scaling.', + syntax: 'fsig = pvsfilter(fsigin, fsigfil, kdepth [, igain])', + example: 'kfreq expon 500, p3, 4000 ; 3-octave sweep\nkdepth linseg 1, p3/2, 0.5, p3/2, 1 ; varying filter depth\n\nasig in ; input\nafil oscili 1, kfreq, 1 ; filter t-domain signal\n\nfim pvsanal asig,1024,256,1024,0 ; pvoc analysis\nfil pvsanal afil,1024,256,1024,0 \nfou pvsfilter fim, fil, kdepth ; filter signal\naout pvsynth fou ; pvoc synthesis', + parameters: [ + { + name: 'fsig', + description: 'output pv stream', + type: 'performance' + }, + { + name: 'fsigin', + description: 'input pv stream.', + type: 'performance' + }, + { + name: 'fsigfil', + description: 'filtering pvoc stream.', + type: 'performance' + }, + { + name: 'kdepth', + description: 'controls the depth of filtering of fsigin by fsigfil .', + type: 'performance' + }, + { + name: 'igain', + description: 'amplitude scaling (optional, defaults to 1).', + type: 'performance' + }, + ], + seeAlso: ['Tools for Real-time Spectral Processing (pvs opcodes)'] +}, +{ + name: 'pvsfread', + type: 'opcode', + category: 'Spectral Processing:Streaming', + description: 'Read a selected channel from a PVOC-EX analysis file.', + syntax: 'fsig = pvsfread(ktimpt, ifn [, ichan])', + example: '--8<-- "examples/pvsfread.csd"', + rates: ['i-rate'], + parameters: [ + { + name: 'ifn', + description: 'Name of the analysis file. This must have the .pvx file extension.', + type: 'initialization' + }, + { + name: 'ichan', + description: '(optional) The channel to read (counting from 0). Default is 0.', + type: 'initialization' + }, + { + name: 'ktimpt', + description: 'Time pointer into analysis file, in seconds. See the description of the same parameter of [pvoc](../opcodes/pvoc.md) for usage.', + type: 'performance' + }, + ], + seeAlso: ['Tools for Real-time Spectral Processing (pvs opcodes)'] +}, +{ + name: 'pvsfreeze', + type: 'opcode', + category: 'Spectral Processing:Streaming', + description: 'Freeze the amplitude and frequency time functions of a pv stream according to a control-rate trigger.', + syntax: 'fsig = pvsfreeze(fsigin, kfreeza, kfreezf)', + example: 'asig in ; input\nktrig oscil 1.5, 0.25, 1 ; trigger\nfim pvsanal asig1, 1024, 256, 1024, 0 ; pvoc analysis \nfou pvsfreeze fim, abs(ktrig), abs(ktrig) ; regular \'freeze\' of spectra\naout pvsynth fou ; pvoc synthesis', + parameters: [ + { + name: 'fsig', + description: 'output pv stream', + type: 'performance' + }, + { + name: 'fsigin', + description: 'input pv stream.', + type: 'performance' + }, + { + name: 'kfreeza', + description: 'freezing switch for amplitudes. Freezing is on if above or equal to 1 and off if below 1.', + type: 'performance' + }, + { + name: 'kfcf', + description: 'freezing switch for frequencies. Freezing is on if above or equal to 1 and off if below 1.', + type: 'performance' + }, + ], + seeAlso: ['Tools for Real-time Spectral Processing (pvs opcodes)'] +}, +{ + name: 'pvsfromarray', + type: 'opcode', + category: 'Spectral Processing:Streaming', + description: 'Same as the [tab2pvs](../opcodes/tab2pvs.md) opcode.', + syntax: 'fsig = pvsfromarray(karr[] [,ihopsize, iwinsize, iwintype])\n fsig = pvsfromarray(kmags[], kfreqs[] [,ihopsize, iwinsize, iwintype])', +}, +{ + name: 'pvsftr', + type: 'opcode', + category: 'Spectral Processing:Streaming', + description: 'Reads amplitude and/or frequency data from function tables.', + syntax: 'pvsftr(fsrc, ifna [, ifnf])', + example: '--8<-- "examples/pvsftr.csd"', + parameters: [ + { + name: 'ifna', + description: 'A table, at least inbins in size, that stores amplitude data. Ignored if ifna = 0', + type: 'initialization' + }, + { + name: 'fsrc', + description: 'a PVOC-EX formatted source.', + type: 'performance' + }, + ], + seeAlso: ['Tools for Real-time Spectral Processing (pvs opcodes)'] +}, +{ + name: 'pvsftw', + type: 'opcode', + category: 'Spectral Processing:Streaming', + description: 'Writes amplitude and/or frequency data to function tables.', + syntax: 'kflag = pvsftw(fsrc, ifna [, ifnf])', + example: '--8<-- "examples/pvsftw.csd"', + parameters: [ + { + name: 'ifna', + description: 'A table, at least inbins in size, that stores amplitude data. Ignored if ifna = 0', + type: 'initialization' + }, + { + name: 'ifnf', + description: 'A table, at least inbins in size, that stores frequency data. Ignored if ifnf = 0', + type: 'initialization' + }, + { + name: 'kflag', + description: 'A flag that has the value of 1 when new data is available, 0 otherwise.', + type: 'performance' + }, + { + name: 'fsrc', + description: 'a PVOC-EX formatted source.', + type: 'performance' + }, + ], + seeAlso: ['Tools for Real-time Spectral Processing (pvs opcodes)'] +}, +{ + name: 'pvsfwrite', + type: 'opcode', + category: 'Spectral Processing:Streaming', + description: 'Write a fsig to a PVOCEX file (which in turn can be read by _pvsfread_ or other programs that support PVOCEX file input).', + syntax: 'pvsfwrite(fsig, ifile)', + example: '--8<-- "examples/pvsfwrite.csd"', + parameters: [ + { + name: 'fsig', + description: 'fsig input data.', + type: 'initialization' + }, + { + name: 'ifile', + description: 'filename (a string in double-quotes) .', + type: 'initialization' + }, + ], + seeAlso: ['Tools for Real-time Spectral Processing (pvs opcodes)'] +}, +{ + name: 'pvsgain', + type: 'opcode', + category: 'Spectral Processing:Streaming', + description: 'Scale the amplitude of a pv stream.', + syntax: 'fsig = pvsgain(fsigin, kgain)', + example: '--8<-- "examples/pvsgain.csd"', + parameters: [ + { + name: 'fsig', + description: 'output pv stream', + type: 'performance' + }, + { + name: 'fsigin', + description: 'input pv stream', + type: 'performance' + }, + { + name: 'kgain', + description: 'amplitude scaling (defaults to 1).', + type: 'performance' + }, + ], + seeAlso: ['Tools for Real-time Spectral Processing (pvs opcodes)'] +}, +{ + name: 'pvshift', + type: 'opcode', + category: 'Spectral Processing:Streaming', + description: 'Shift the frequency components of a pv stream, stretching/compressing its spectrum.', + syntax: 'fsig = pvshift(fsigin, kshift, klowest [, kkeepform, igain, kcoefs])', + example: 'asig in ; get the signal in\n\nfsig pvsanal asig, 1024, 256, 1024, 1 ; analyse it\nftps pvshift fsig, 100, 0 ; add 100 Hz to each component\natps pvsynth ftps ; synthesise it', + parameters: [ + { + name: 'fsig', + description: 'output pv stream', + type: 'performance' + }, + { + name: 'fsigin', + description: 'input pv stream', + type: 'performance' + }, + { + name: 'kshift', + description: 'shift amount (in Hz, positive or negative).', + type: 'performance' + }, + { + name: 'klowest', + description: 'lowest frequency to be shifted.', + type: 'performance' + }, + { + name: 'kkeepform', + description: 'attempt to keep input signal formants; 0: do not keep formants; 1: keep formants using a liftered cepstrum method; 2: keep formants by using a true envelope method (defaults to 0).', + type: 'performance' + }, + { + name: 'kgain', + description: 'amplitude scaling (defaults to 1).', + type: 'performance' + }, + { + name: 'kcoefs', + description: 'number of cepstrum coefs used in formant preservation (defaults to 80).', + type: 'performance' + }, + ], + seeAlso: ['Tools for Real-time Spectral Processing (pvs opcodes)'] +}, +{ + name: 'pvsifd', + type: 'opcode', + category: 'Spectral Processing:Streaming', + description: 'Instantaneous Frequency Distribution, magnitude and phase analysis.', + syntax: 'ffr, fphs = pvsifd(ain, ifftsize, ihopsize, iwintype [,iscal])', + example: '--8<-- "examples/pvsifd.csd"', + parameters: [ + { + name: 'ffr', + description: 'output pv stream in AMP_FREQ format', + type: 'performance' + }, + { + name: 'fphs', + description: 'output pv stream in AMP_PHASE format', + type: 'performance' + }, + { + name: 'ifftsize', + description: 'FFT analysis size, must be power-of-two and integer multiple of the hopsize.', + type: 'performance' + }, + { + name: 'ihopsize', + description: 'hopsize in samples', + type: 'performance' + }, + { + name: 'iwintype', + description: 'window type (O: Hamming, 1: Hanning)', + type: 'performance' + }, + { + name: 'iscal', + description: 'amplitude scaling (defaults to 1).', + type: 'performance' + }, + ], + seeAlso: ['Tools for Real-time Spectral Processing (pvs opcodes)'] +}, +{ + name: 'pvsin', + type: 'opcode', + category: 'Spectral Processing:Streaming', + description: 'Retrieve an fsig from the input software bus; a pvs equivalent to _chani_.', + syntax: 'fsig = pvsin(kchan [, isize, iolap, iwinsize, iwintype, iformat])', + example: 'fsig pvsin 0 ; get data from pvs in bus channel 0', + parameters: [ + { + name: 'isize', + description: 'initial DFT size,defaults to 1024.', + type: 'initialization' + }, + { + name: 'iolap', + description: 'size of overlap, defaults to _isize_/4.', + type: 'initialization' + }, + { + name: 'iwinsize', + description: 'size of analysis window, defaults to _isize_.', + type: 'initialization' + }, + { + name: 'iwintype', + description: 'type of window, defaults to Hanning (1) (see _pvsanal_)', + type: 'initialization' + }, + { + name: 'iformat', + description: 'data format, defaults 0 (PVS_AMP_FREQ). Other possible values are 1 (PVS_AMP_PHASE), 2 (PVS_COMPLEX) or 3 (PVS_TRACKS).', + type: 'initialization' + }, + { + name: 'fsig', + description: 'output fsig.', + type: 'performance' + }, + { + name: 'kchan', + description: 'channel number. If non-existent, a channel will be created.', + type: 'performance' + }, + ], + seeAlso: ['Tools for Real-time Spectral Processing (pvs opcodes)'] +}, +{ + name: 'pvsinfo', + type: 'opcode', + category: 'Spectral Processing:Streaming', + description: 'Get information from a PVOC-EX formatted source.', + syntax: 'ioverlap, inumbins, iwinsize, iformat = pvsinfo(fsrc)', + example: '--8<-- "examples/pvsinfo.csd"', + parameters: [ + { + name: 'ioverlap', + description: 'The stream overlap size.', + type: 'initialization' + }, + { + name: 'inumbins', + description: 'The number of analysis bins (amplitude+frequency) in fsrc. The underlying FFT size is calculated as (inumbins -1) * 2.', + type: 'initialization' + }, + { + name: 'iwinsize', + description: 'The analysis window size. May be larger than the FFT size.', + type: 'initialization' + }, + { + name: 'iformat', + description: 'The analysis frame format. If fsrc is created by an opcode, iformat will always be 0, signifying amplitude+frequency. If fsrc is defined from a PVOC-EX file, iformat may also have the value 1 or 2 (amplitude+phase, complex).', + type: 'initialization' + }, + ], + seeAlso: ['Tools for Real-time Spectral Processing (pvs opcodes)'] +}, +{ + name: 'pvsinit', + type: 'opcode', + category: 'Spectral Processing:Streaming', + description: 'Initialise a spectral (f) variable to zero.', + syntax: 'fsig = pvsinit(isize [, iolap, iwinsize, iwintype, iformat])', + example: '--8<-- "examples/pvsinit.csd"', + parameters: [ + { + name: 'fsig', + description: 'output pv stream set to zero.', + type: 'performance' + }, + { + name: 'isize', + description: 'size of the DFT frame.', + type: 'performance' + }, + { + name: 'iolap', + description: 'size of the analysis overlap, defaults to _isize_/4.', + type: 'performance' + }, + { + name: 'iwinsize', + description: 'size of the analysis window, defaults to _isize_.', + type: 'performance' + }, + { + name: 'iwintype', + description: 'type of analysis window, defaults to 1, Hanning.', + type: 'performance' + }, + { + name: 'iformat', + description: 'pvsdata format, defaults to 0:PVS_AMP_FREQ.', + type: 'performance' + }, + ], + seeAlso: ['Tools for Real-time Spectral Processing (pvs opcodes)'] +}, +{ + name: 'pvsmaska', + type: 'opcode', + category: 'Spectral Processing:Streaming', + description: 'Modify amplitudes using a function table, with dynamic scaling.', + syntax: 'fsig = pvsmaska(fsrc, ifn, kdepth)', + example: '--8<-- "examples/pvsmaska.csd"', + rates: ['i-rate'], + parameters: [ + { + name: 'ifn', + description: 'The f-table to use. Given fsrc has N analysis bins, table ifn must be of size N or larger. The table need not be normalized, but values should lie within the range 0 to 1. It can be supplied from the score in the usual way, or from within the orchestra by using [pvsinfo](../opcodes/pvsinfo.md) to find the size of fsrc, (returned by pvsinfo in inbins), which can then be passed to ftgen to create the f-table.', + type: 'initialization' + }, + { + name: 'kdepth', + description: 'Controls the degree of modification applied to fsrc, using simple linear scaling. 0 leaves amplitudes unchanged, 1 applies the full profile of ifn.', + type: 'performance' + }, + ], + seeAlso: ['Tools for Real-time Spectral Processing (pvs opcodes)'] +}, +{ + name: 'pvsmix', + type: 'opcode', + category: 'Spectral Processing:Streaming', + description: 'Mix \'seamlessly\' two pv signals.', + syntax: 'fsig = pvsmix(fsigin1, fsigin2)', + example: '--8<-- "examples/pvsmix.csd"', + parameters: [ + { + name: 'fsig', + description: 'output pv stream', + type: 'performance' + }, + { + name: 'fsigin1', + description: 'input pv stream.', + type: 'performance' + }, + { + name: 'fsigin2', + description: 'input pv stream, which must have same format as _fsigin1_.', + type: 'performance' + }, + ], + seeAlso: ['Tools for Real-time Spectral Processing (pvs opcodes)'] +}, +{ + name: 'pvsmooth', + type: 'opcode', + category: 'Spectral Processing:Streaming', + description: 'Smooth the amplitude and frequency time functions of a pv stream using parallel 1st order lowpass IIR filters with time-varying cutoff frequency.', + syntax: 'fsig = pvsmooth(fsigin, kacf, kfcf)', + example: '--8<-- "examples/pvsmooth.csd"', + parameters: [ + { + name: 'fsig', + description: 'output pv stream', + type: 'performance' + }, + { + name: 'fsigin', + description: 'input pv stream.', + type: 'performance' + }, + { + name: 'kacf', + description: 'amount of cutoff frequency for amplitude function filtering, between 0 and 1, in fractions of 1/2 frame-rate.', + type: 'performance' + }, + { + name: 'kfcf', + description: 'amount of cutoff frequency for frequency function filtering, between 0 and 1, in fractions of 1/2 frame-rate.', + type: 'performance' + }, + ], + seeAlso: ['Tools for Real-time Spectral Processing (pvs opcodes)'] +}, +{ + name: 'pvsmorph', + type: 'opcode', + category: 'Spectral Processing:Streaming', + description: 'Performs morphing (or interpolation) between two source fsigs.', + syntax: 'fsig = pvsmorph(fsig1, fsig2, kampint, kfrqint)', + example: '--8<-- "examples/pvsmorph.csd"', + seeAlso: ['Tools for Real-time Spectral Processing (pvs opcodes)'] +}, +{ + name: 'pvsosc', + type: 'opcode', + category: 'Spectral Processing:Streaming', + description: 'PVS-based oscillator simulator.', + syntax: 'fsig = pvsosc(kamp, kfreq, ktype, isize [,ioverlap] [, iwinsize] [, iwintype] \\\n [, iformat])', + example: '--8<-- "examples/pvsosc.csd"', + rates: ['k-rate'], + parameters: [ + { + name: 'kamp', + description: 'signal amplitude. Note that the actual signal amplitude can, depending on wave type and frequency, vary slightly above or below this value. Generally the amplitude will tend to exceed kamp on higher frequencies (> 1000 Hz) and be reduced on lower ones. Also due to the overlap-add process, when resynthesing with pvsynth, frequency glides will cause the output amplitude to fluctuate above and below kamp.', + type: 'performance' + }, + { + name: 'kfreq', + description: 'fundamental frequency in Hz.', + type: 'performance' + }, + { + name: 'ktype', + description: 'wave type: 1. sawtooh-like, 2.square-like, 3.pulse and any other value for cosine.', + type: 'performance' + }, + ], + seeAlso: ['Tools for Real-time Spectral Processing (pvs opcodes)'] +}, +{ + name: 'pvsout', + type: 'opcode', + category: 'Spectral Processing:Streaming', + description: 'Write a fsig to the pvs output bus.', + syntax: 'pvsout(fsig, kchan)', + example: 'asig in ; input\nfsig pvsanal asig, 1024, 256, 1024, 1 ; analysis\n pvsout fsig, 0 ; write signal to pvs out bus channel 0', + parameters: [ + { + name: 'fsig', + description: 'fsig input data.', + type: 'performance' + }, + { + name: 'kchan', + description: 'pvs out bus channel number.', + type: 'performance' + }, + ], + seeAlso: ['Tools for Real-time Spectral Processing (pvs opcodes)'] +}, +{ + name: 'pvspitch', + type: 'opcode', + category: 'Spectral Processing:Streaming', + description: 'Track the pitch and amplitude of a PVS signal as k-rate variables.', + syntax: 'kfr, kamp = pvspitch(fsig, kthresh)', + example: '--8<-- "examples/pvspitch.csd"', + rates: ['k-rate'], + parameters: [ + { + name: 'kamp', + description: 'Amplitude of fundamental frequency', + type: 'performance' + }, + { + name: 'kfr', + description: 'Fundamental frequency', + type: 'performance' + }, + { + name: 'fsig', + description: 'an input pv stream', + type: 'performance' + }, + { + name: 'kthresh', + description: 'analysis threshold (between 0 and 1). Higher values will eliminate low-amplitude components from the analysis.', + type: 'performance' + }, + ], + seeAlso: ['Tools for Real-time Spectral Processing (pvs opcodes)', 'Sensing and Control: Tempo and Pitch estimation'] +}, +{ + name: 'pvstanal', + type: 'opcode', + category: 'Spectral Processing:Streaming', + description: 'Phase vocoder analysis processing with onset detection/processing.', + syntax: 'fsig = pvstanal(ktimescal, kamp, kpitch, ktab, [kdetect, kwrap, ioffset, \\\n ifftsize, ihop, idbthresh])\n )', + example: '--8<-- "examples/pvstanal.csd"', + rates: ['k-rate'], + parameters: [ + { + name: 'ifftsize', + description: 'FFT size (power-of-two), defaults to 2048.', + type: 'initialization' + }, + { + name: 'ihop', + description: 'hopsize, defaults to 512', + type: 'initialization' + }, + { + name: 'ioffset', + description: 'startup read offset into table, in secs.', + type: 'initialization' + }, + { + name: 'idbthresh', + description: 'threshold for onset detection, based on dB power spectrum ratio between two successive windows. A detected ratio above it will cancel timescaling momentarily, to avoid smearing (defaults to 1). By default anything more than a 1 dB inter-frame power difference will be detected as an onset.', + type: 'initialization' + }, + { + name: 'ktimescal', + description: 'timescaling ratio, < 1 stretch, > 1 contract.', + type: 'performance' + }, + { + name: 'kamp', + description: 'amplitude scaling', + type: 'performance' + }, + { + name: 'kpitch', + description: 'grain pitch scaling (1=normal pitch, < 1 lower, > 1 higher; negative, backwards)', + type: 'performance' + }, + { + name: 'kdetect', + description: '0 or 1, to switch onset detection/processing. The onset detector checks for power difference between analysis windows. If more than what has been specified in the dbthresh parameter, an onset is declared. It suspends timescaling momentarily so the onsets are not modified. The default is 1, so onset detection/processing is on.', + type: 'performance' + }, + { + name: 'ktab', + description: 'source signal function table. Deferred-allocation tables (see [GEN01](../scoregens/gen01.md)) are accepted, but the opcode expects a mono source. Tables can be switched at k-rate.', + type: 'performance' + }, + { + name: 'kwrap', + description: '0 or 1, to switch on/off table wrap-around read (default to 1)', + type: 'performance' + }, + ], + seeAlso: ['Tools for Real-time Spectral Processing (pvs opcodes)'] +}, +{ + name: 'pvstencil', + type: 'opcode', + category: 'Spectral Processing:Streaming', + description: 'Transforms a pvoc stream according to a masking function table.', + syntax: 'fsig = pvstencil(fsigin, kgain, klevel, iftable)', + example: '--8<-- "examples/pvstencil.csd"', + parameters: [ + { + name: 'fsig', + description: 'output pv stream', + type: 'performance' + }, + { + name: 'fsigin', + description: 'input pv stream.', + type: 'performance' + }, + { + name: 'kgain', + description: '`stencil\' gain.', + type: 'performance' + }, + { + name: 'klevel', + description: 'masking function level (scales the ftable prior to `stenciling\') .', + type: 'performance' + }, + { + name: 'iftable', + description: 'masking function table.', + type: 'performance' + }, + ], + seeAlso: ['Tools for Real-time Spectral Processing (pvs opcodes)'] +}, +{ + name: 'pvstrace', + type: 'opcode', + category: 'Spectral Processing:Streaming', + description: 'Process a PV stream by retaining only the N bins with the highest amplitude, zeroing the others.', + syntax: 'fsig = pvstrace(fsigin, kn)\n fsig, kBins[] = pvstrace(fsigin, kn [, isort, imin, imax])', + example: '--8<-- "examples/pvstrace.csd"', + parameters: [ + { + name: 'fsig', + description: 'output pv stream', + type: 'performance' + }, + { + name: 'fsigin', + description: 'input pv stream', + type: 'performance' + }, + { + name: 'kn', + description: 'number of bins to be retained', + type: 'performance' + }, + ], + seeAlso: ['Tools for Real-time Spectral Processing (pvs opcodes)'] +}, +{ + name: 'pvsvoc', + type: 'opcode', + category: 'Spectral Processing:Streaming', + description: 'Combine the spectral envelope of one fsig with the excitation (frequencies) of another.', + syntax: 'fsig = pvsvoc(famp, fexc, kdepth, kgain [, kcoefs])', + example: '--8<-- "examples/pvsvoc.csd"', + parameters: [ + { + name: 'fsig', + description: 'output pv stream', + type: 'performance' + }, + { + name: 'famp', + description: 'input pv stream from which the amplitudes will be extracted', + type: 'performance' + }, + { + name: 'fexc', + description: 'input pv stream from which the frequencies will be taken', + type: 'performance' + }, + { + name: 'kdepth', + description: 'depth of effect, affecting how much of the frequencies will be taken from the second fsig: 0, the output is the famp signal, 1 the output is the famp amplitudes and fexc frequencies.', + type: 'performance' + }, + { + name: 'kgain', + description: 'gain boost/attenuation applied to the output.', + type: 'performance' + }, + { + name: 'kcoefs', + description: 'number of cepstrum coefs used in spectral envelope estimation (defaults to 80).', + type: 'performance' + }, + ], + seeAlso: ['Tools for Real-time Spectral Processing (pvs opcodes)'] +}, +{ + name: 'pvswarp', + type: 'opcode', + category: 'Spectral Processing:Streaming', + description: 'Warp the spectral envelope of a PVS signal by means of shifting and scaling.', + syntax: 'fsig = pvswarp(fsigin, kscal, kshift [, klowest, kmeth, kgain, kcoefs])', + example: '--8<-- "examples/pvswarp.csd"', + parameters: [ + { + name: 'fsig', + description: 'output pv stream', + type: 'performance' + }, + { + name: 'fsigin', + description: 'input pv stream', + type: 'performance' + }, + { + name: 'kscal', + description: 'spectral envelope scaling ratio. Values > 1 stretch the envelope and < 1 compress it.', + type: 'performance' + }, + { + name: 'kshift', + description: 'spectral envelope shift (in Hz), values > 0 shift the envelope linearly upwards and values < 0 shift it downwards.', + type: 'performance' + }, + { + name: 'klowest', + description: 'lowest frequency shifted (affects only kshift, defaults to 0).', + type: 'performance' + }, + { + name: 'kmethod', + description: 'spectral envelope extraction method. 1: liftered cepstrum method; 2: true envelope method (defaults to 1).', + type: 'performance' + }, + { + name: 'kgain', + description: 'amplitude scaling (defaults to 1).', + type: 'performance' + }, + { + name: 'kcoefs', + description: 'number of cepstrum coefs used in formant preservation (defaults to 80).', + type: 'performance' + }, + ], + seeAlso: ['Tools for Real-time Spectral Processing (pvs opcodes)'] +}, +{ + name: 'pvsynth', + type: 'opcode', + category: 'Spectral Processing:Streaming', + description: 'Resynthesise phase vocoder data (f-signal) using a FFT overlap-add.', + syntax: 'ares = pvsynth(fsrc, [iinit])', + example: '; score f-table using cubic spline to define shaped peaks\nf1 0 513 8 0 2 1 3 0 4 1 6 0 10 1 12 0 16 1 32 0 1 0 436 0\n\nasig buzz 20000, 199, 50, 1 ; pulsewave source\nfsig pvsanal asig, 1024, 256, 1024, 0 ; create fsig\nkmod linseg 0, p3/2, 1, p3/2, 0 ; simple control sig\n\nfsigout pvsmaska fsig, 2, kmod ; apply weird eq to fsig\naout pvsynth fsigout ; resynthesize,\n dispfft aout, 0.1, 1024 ; and view the effect', + rates: ['a-rate'], + parameters: [ + { + name: 'ares', + description: 'output audio signal', + type: 'performance' + }, + { + name: 'fsrc', + description: 'input signal', + type: 'performance' + }, + { + name: 'iinit', + description: 'not yet implemented.', + type: 'performance' + }, + ], + seeAlso: ['Tools for Real-time Spectral Processing (pvs opcodes)'] +}, +{ + name: 'resyn', + type: 'opcode', + category: 'Spectral Processing:Streaming', + description: 'Streaming partial track additive synthesis with cubic phase interpolation.', + syntax: 'asig = resyn(fin, kscal, kpitch, kmaxtracks, ifn)', + example: '--8<-- "examples/resyn.csd"', + rates: ['a-rate', 'i-rate'], + parameters: [ + { + name: 'asig', + description: 'output audio rate signal', + type: 'performance' + }, + { + name: 'fin', + description: 'input pv stream in TRACKS format', + type: 'performance' + }, + { + name: 'kscal', + description: 'amplitude scaling', + type: 'performance' + }, + { + name: 'kpitch', + description: 'pitch scaling', + type: 'performance' + }, + { + name: 'kmaxtracks', + description: 'max number of tracks in resynthesis. Limiting this will cause a non-linear filtering effect, by discarding newer and higher-frequency tracks (tracks are ordered by start time and ascending frequency, respectively)', + type: 'performance' + }, + { + name: 'ifn', + description: 'function table containing one cycle of a sinusoid (sine or cosine)', + type: 'performance' + }, + ], + seeAlso: ['Tools for Real-time Spectral Processing (pvs opcodes)'] +}, +{ + name: 'sinsyn', + type: 'opcode', + category: 'Spectral Processing:Streaming', + description: 'Streaming partial track additive synthesis with cubic phase interpolation.', + syntax: 'asig = sinsyn(fin, kscal, kmaxtracks, ifn)', + example: '--8<-- "examples/sinsyn.csd"', + rates: ['a-rate', 'i-rate'], + parameters: [ + { + name: 'asig', + description: 'output audio rate signal', + type: 'performance' + }, + { + name: 'fin', + description: 'input pv stream in TRACKS format', + type: 'performance' + }, + { + name: 'kscal', + description: 'amplitude scaling', + type: 'performance' + }, + { + name: 'kmaxtracks', + description: 'max number of tracks in sinsynthesis. Limiting this will cause a non-linear filtering effect, by discarding newer and higher-frequency tracks (tracks are ordered by start time and ascending frequency, respectively)', + type: 'performance' + }, + { + name: 'ifn', + description: 'function table containing one cycle of a sinusoid (sine or cosine).', + type: 'performance' + }, + ], + seeAlso: ['Tools for Real-time Spectral Processing (pvs opcodes)'] +}, +] diff --git a/src/lib/csound-reference/strings-conversion.ts b/src/lib/csound-reference/strings-conversion.ts new file mode 100644 index 0000000..ef5c635 --- /dev/null +++ b/src/lib/csound-reference/strings-conversion.ts @@ -0,0 +1,39 @@ +import type { CsoundReference } from './types' + +// Strings:Conversion +export const stringsConversion: CsoundReference[] = [ +{ + name: 'strchar', + type: 'opcode', + category: 'Strings:Conversion', + description: 'Return the ASCII code of the character in Sstr at ipos (defaults to zero which means the first character), or zero if ipos is out of range.', + syntax: 'ichr = strchar(Sstr [, ipos])', + example: '--8<-- "examples/strchar.csd"', + seeAlso: ['String Conversion Opcodes'] +}, +{ + name: 'strchark', + type: 'opcode', + category: 'Strings:Conversion', + description: 'Return the ASCII code of the character in Sstr at kpos (defaults to zero which means the first character), or zero if kpos is out of range.', + syntax: 'kchr = strchark(Sstr [, kpos])', + seeAlso: ['String Conversion Opcodes'] +}, +{ + name: 'strlower', + type: 'opcode', + category: 'Strings:Conversion', + description: 'Convert Ssrc to lower case, and write the result to Sdst.', + syntax: 'Sdst = strlower(Ssrc)', + example: '--8<-- "examples/strlower.csd"', + seeAlso: ['String Conversion Opcodes'] +}, +{ + name: 'strlowerk', + type: 'opcode', + category: 'Strings:Conversion', + description: 'Convert Ssrc to lower case, and write the result to Sdst.', + syntax: 'Sdst = strlowerk(Ssrc)', + seeAlso: ['String Conversion Opcodes'] +}, +] diff --git a/src/lib/csound-reference/strings-definition.ts b/src/lib/csound-reference/strings-definition.ts new file mode 100644 index 0000000..68f5d93 --- /dev/null +++ b/src/lib/csound-reference/strings-definition.ts @@ -0,0 +1,68 @@ +import type { CsoundReference } from './types' + +// Strings:Definition +export const stringsDefinition: CsoundReference[] = [ +{ + name: 'strfromurl', + type: 'opcode', + category: 'Strings:Definition', + description: 'Set a string variable to the value found from reading an URL.', + syntax: 'Sdst = strfromurl(StringURL)', + example: '--8<-- "examples/strfromurl.csd"', + parameters: [ + { + name: 'StringURL', + description: 'string naming an URL.', + type: 'initialization' + }, + { + name: 'Sdst', + description: 'destination string variable', + type: 'initialization' + }, + ], + seeAlso: ['String Manipulation Opcodes'] +}, +{ + name: 'strget', + type: 'opcode', + category: 'Strings:Definition', + description: 'Set a string variable at initialization time to the value stored in [strset](../opcodes/strset.md) table at the specified index, or a string p-field from the score.', + syntax: 'Sdst = strget(indx)', + example: '--8<-- "examples/strget.csd"', + parameters: [ + { + name: 'indx', + description: 'strset index, or score p-field', + type: 'initialization' + }, + { + name: 'Sdst', + description: 'destination string variable', + type: 'initialization' + }, + ], + seeAlso: ['String Manipulation Opcodes'] +}, +{ + name: 'strset', + type: 'opcode', + category: 'Strings:Definition', + description: 'Allows a string to be linked with a numeric value.', + syntax: 'strset(iarg, istring)', + example: 'strset 10, "asound.wav"', + parameters: [ + { + name: 'iarg', + description: 'the numeric value.', + type: 'initialization' + }, + { + name: 'istring', + description: 'the alphanumeric string (in double-quotes).', + type: 'initialization' + }, + ], + seeAlso: ['String Manipulation Opcodes', 'Orchestra Header Statements'] +}, +] diff --git a/src/lib/csound-reference/strings-manipulation.ts b/src/lib/csound-reference/strings-manipulation.ts new file mode 100644 index 0000000..1bb3e26 --- /dev/null +++ b/src/lib/csound-reference/strings-manipulation.ts @@ -0,0 +1,223 @@ +import type { CsoundReference } from './types' + +// Strings:Manipulation +export const stringsManipulation: CsoundReference[] = [ +{ + name: 'puts', + type: 'opcode', + category: 'Strings:Manipulation', + description: 'Print a string with an optional newline at the end whenever the trigger signal is positive and changes.', + syntax: 'puts(Sstr, ktrig [, inonl])', + example: '--8<-- "examples/puts.csd"', + parameters: [ + { + name: 'Sstr', + description: 'string to be printed', + type: 'initialization' + }, + { + name: 'ktrig', + description: 'trigger signal, should be valid at i-time. The string is printed at initialization time if ktrig is positive, and at performance time whenever ktrig is both positive and different from the previous value. Use a constant value of 1 to print once at note initialization.', + type: 'performance' + }, + ], + seeAlso: ['String Manipulation Opcodes'] +}, +{ + name: 'sprintf', + type: 'opcode', + category: 'Strings:Manipulation', + description: 'printf-style formatted output to a string variable.', + syntax: 'Sdst = sprintf(Sfmt, xarg1[, xarg2[, ... ]])', + example: '--8<-- "examples/sprintf.csd"', + parameters: [ + { + name: 'Sfmt', + description: 'format string, has the same format as in printf() and other similar C functions, except length modifiers (l, ll, h, etc.) are not supported. The following conversion specifiers are allowed:', + type: 'initialization' + }, + { + name: 'Sdst', + description: 'output string variable', + type: 'performance' + }, + ], + seeAlso: ['String Manipulation Opcodes'] +}, +{ + name: 'sprintfk', + type: 'opcode', + category: 'Strings:Manipulation', + description: 'printf-style formatted output to a string variable at k-rate.', + syntax: 'Sdst = sprintfk(Sfmt, xarg1[, xarg2[, ... ]])', + example: '--8<-- "examples/sprintfk.csd"', + parameters: [ + { + name: 'Sfmt', + description: 'format string, has the same format as in printf() and other similar C functions, except length modifiers (l, ll, h, etc.) are not supported. The following conversion specifiers are allowed:', + type: 'initialization' + }, + { + name: 'Sdst', + description: 'output string variable', + type: 'performance' + }, + ], + seeAlso: ['String Manipulation Opcodes'] +}, +{ + name: 'strcat', + type: 'opcode', + category: 'Strings:Manipulation', + description: 'Concatenate two strings and store the result in a variable.', + syntax: 'Sdst = strcat(Ssrc1, Ssrc2)', + example: '--8<-- "examples/strcat.csd"', + seeAlso: ['String Manipulation Opcodes'] +}, +{ + name: 'strcatk', + type: 'opcode', + category: 'Strings:Manipulation', + description: 'Concatenate two strings and store the result in a variable.', + syntax: 'Sdst = strcatk(Ssrc1, Ssrc2)', + example: '--8<-- "examples/strcatk.csd"', + seeAlso: ['String Manipulation Opcodes'] +}, +{ + name: 'strcmp', + type: 'opcode', + category: 'Strings:Manipulation', + description: 'Compare strings.', + syntax: 'ires = strcmp(S1, S2)', + example: '--8<-- "examples/strcmp.csd"', + rates: ['i-rate'], + seeAlso: ['String Manipulation Opcodes'] +}, +{ + name: 'strcmpk', + type: 'opcode', + category: 'Strings:Manipulation', + description: 'Compare strings.', + syntax: 'kres = strcmpk(S1, S2)', + rates: ['k-rate'], + seeAlso: ['String Manipulation Opcodes'] +}, +{ + name: 'strcpy', + type: 'opcode', + category: 'Strings:Manipulation', + description: 'Assign to a string variable by copying the source which may be a constant or another string variable.', + syntax: 'Sdst = strcpy(Ssrc)\n Sdst = Ssrc', + example: 'Sfoo strcpy "Hello, world !"\n puts Sfoo, 1', + seeAlso: ['String Manipulation Opcodes'] +}, +{ + name: 'strcpyk', + type: 'opcode', + category: 'Strings:Manipulation', + description: 'Assign to a string variable by copying the source which may be a constant or another string variable.', + syntax: 'Sdst = strcpyk(Ssrc)', + example: '--8<-- "examples/strcpyk.csd"', + seeAlso: ['String Manipulation Opcodes'] +}, +{ + name: 'strindex', + type: 'opcode', + category: 'Strings:Manipulation', + description: 'Return the position of the first occurence of S2 in S1, or -1 if not found. If S2 is empty, 0 is returned.', + syntax: 'ipos = strindex(S1, S2)', + seeAlso: ['String Manipulation Opcodes'] +}, +{ + name: 'strindexk', + type: 'opcode', + category: 'Strings:Manipulation', + description: 'Return the position of the first occurence of S2 in S1, or -1 if not found. If S2 is empty, 0 is returned.', + syntax: 'kpos = strindexk(S1, S2)', + example: '--8<-- "examples/strindexk.csd"', + seeAlso: ['String Manipulation Opcodes'] +}, +{ + name: 'strlen', + type: 'opcode', + category: 'Strings:Manipulation', + description: 'Return the length of a string, or zero if it is empty. strlen runs at init time only.', + syntax: 'ilen = strlen(Sstr)', + seeAlso: ['String Manipulation Opcodes'] +}, +{ + name: 'strlenk', + type: 'opcode', + category: 'Strings:Manipulation', + description: 'Return the length of a string, or zero if it is empty. strlenk runs both at init and performance time.', + syntax: 'klen = strlenk(Sstr)', + seeAlso: ['String Manipulation Opcodes'] +}, +{ + name: 'strrindex', + type: 'opcode', + category: 'Strings:Manipulation', + description: 'Return the position of the last occurence of S2 in S1, or -1 if not found. If S2 is empty, the length of S1 is returned.', + syntax: 'ipos = strrindex(S1, S2)', + example: '--8<-- "examples/strrindex.csd"', + seeAlso: ['String Manipulation Opcodes'] +}, +{ + name: 'strrindexk', + type: 'opcode', + category: 'Strings:Manipulation', + description: 'Return the position of the last occurence of S2 in S1, or -1 if not found. If S2 is empty, the length of S1 is returned.', + syntax: 'kpos = strrindexk(S1, S2)', + seeAlso: ['String Manipulation Opcodes'] +}, +{ + name: 'strstrip', + type: 'opcode', + category: 'Strings:Manipulation', + description: 'Strip whitespace from string.', + syntax: 'Sout = strstrip(Sin [, Smode])', + example: '--8<-- "examples/strstrip.csd"', + parameters: [ + { + name: 'Sin', + description: 'Input string', + type: 'initialization' + }, + { + name: 'Smode', + description: 'If not given, whitespace is stripped from both sides. If "l", strip whitespace from left side. If "r", strip whitespace from right side.', + type: 'initialization' + }, + ], + seeAlso: ['String Manipulation Opcodes'] +}, +{ + name: 'strsub', + type: 'opcode', + category: 'Strings:Manipulation', + description: 'Extract a substring of the source string.', + syntax: 'Sdst = strsub(Ssrc [, istart[, iend]])', + example: '--8<-- "examples/strsub.csd"', + seeAlso: ['String Manipulation Opcodes'] +}, +{ + name: 'strsubk', + type: 'opcode', + category: 'Strings:Manipulation', + description: 'Extract a substring of the source string.', + syntax: 'Sdst = strsubk(Ssrc, kstart, kend)', + parameters: [ + { + name: 'kstart', + description: 'start position in Ssrc, counting from 0. A negative value means the end of the string.', + type: 'performance' + }, + { + name: 'kend', + description: 'end position in Ssrc, counting from 0. A negative value means the end of the string. If kend is less than kstart, the output is reversed.', + type: 'performance' + }, + ], + seeAlso: ['String Manipulation Opcodes'] +}, +] diff --git a/src/lib/csound-reference/table-control-read-write-operations.ts b/src/lib/csound-reference/table-control-read-write-operations.ts new file mode 100644 index 0000000..283a2b7 --- /dev/null +++ b/src/lib/csound-reference/table-control-read-write-operations.ts @@ -0,0 +1,354 @@ +import type { CsoundReference } from './types' + +// Table Control:Read/Write Operations +export const tableControlReadWriteOperations: CsoundReference[] = [ +{ + name: 'ftaudio', + type: 'opcode', + category: 'Table Control:Read/Write Operations', + description: 'Write a previously-allocated table to an audio file in a variety of formats.', + syntax: 'ians = ftaudio(ifn, "filename", iformat[, ibeg, iend])\n kans = ftaudio(ktrig, kfn, "filename", kformat [, isync, kbeg, kend])', + example: '--8<-- "examples/ftaudio.csd"', + rates: ['i-rate'], + parameters: [ + { + name: 'ifn', + description: 'Number of table to write.', + type: 'initialization' + }, + { + name: 'kfn', + description: 'Number of table to write.', + type: 'initialization' + }, + { + name: 'iformat', + description: 'Format of the file to save.', + type: 'initialization' + }, + { + name: 'kformat', + description: 'Format of the file to save.', + type: 'initialization' + }, + { + name: 'isync', + description: 'if zero the k-rate version waits for the write to finish. If non-zero (default) the writing of data is delegated to a separate thread which then allows Csound to continue with the rendering.', + type: 'initialization' + }, + { + name: 'ibeg', + description: 'gives limits to start and end of section of the table to write, in samples. Default values of zero means from start to end.', + type: 'initialization' + }, + { + name: 'iend', + description: 'gives limits to start and end of section of the table to write, in samples. Default values of zero means from start to end.', + type: 'initialization' + }, + { + name: 'kbeg', + description: 'gives limits to start and end of section of the table to write, in samples. Default values of zero means from start to end.', + type: 'initialization' + }, + { + name: 'kend', + description: 'gives limits to start and end of section of the table to write, in samples. Default values of zero means from start to end.', + type: 'initialization' + }, + { + name: 'ians', + description: 'returns zero if the operation fails or 1 on success. In the asynchronous mode this is updated when the writing finishes, until when it has the value -1', + type: 'initialization' + }, + { + name: 'kans', + description: 'returns zero if the operation fails or 1 on success. In the asynchronous mode this is updated when the writing finishes, until when it has the value -1', + type: 'initialization' + }, + { + name: 'ktrig', + description: 'the k-rate version only happens on a k-cycle when ktrig is non-zero.', + type: 'performance' + }, + ], + seeAlso: ['Read/Write Operations'] +}, +{ + name: 'ftload', + type: 'opcode', + category: 'Table Control:Read/Write Operations', + description: 'Load a set of previously-allocated tables from a file.', + syntax: 'ftload(Sfilename, iflag, ifn1 [, ifn2] [...])', + parameters: [ + { + name: 'iflag', + description: 'Type of the file to load/save. (0 = binary file, Non-zero = text file)', + type: 'initialization' + }, + ], + seeAlso: ['Read/Write Operations'] +}, +{ + name: 'ftloadk', + type: 'opcode', + category: 'Table Control:Read/Write Operations', + description: 'Load a set of previously-allocated tables from a file.', + syntax: 'ftloadk(Sfilename, ktrig, iflag, ifn1 [, ifn2] [...])', + parameters: [ + { + name: 'Sfilename', + description: 'A string value denoting the name of the file to load.', + type: 'initialization' + }, + { + name: 'iflag', + description: 'Type of the file to load/save. (0 = binary file, Non-zero = text file)', + type: 'initialization' + }, + { + name: 'ktrig', + description: 'The trigger signal. Load the file each time it is non-zero.', + type: 'performance' + }, + ], + seeAlso: ['Read/Write Operations'] +}, +{ + name: 'ftprint', + type: 'opcode', + category: 'Table Control:Read/Write Operations', + description: 'Print the contents of a table (for debugging).', + syntax: 'ftprint(ifn [, ktrig, kstart, kend, kstep, inumcols ])', + example: '--8<-- "examples/ftprint.csd"', + rates: ['i-rate'], + parameters: [ + { + name: 'ifn', + description: 'The table to print', + type: 'initialization' + }, + { + name: 'inumcols', + description: 'The number of elements to print in one column (default = 10)', + type: 'initialization' + }, + { + name: 'ktrig', + description: 'The table will be printed whenever this value changes from 0 to possitive. Can be used together with metro to print at a given time interval. A value of -1 indicates to print at each k-cycle (default = 1)', + type: 'performance' + }, + { + name: 'kstart', + description: 'The first index to print. (default = 0)', + type: 'performance' + }, + { + name: 'kend', + description: 'The end index to print (non inclusive). (default = length of table)', + type: 'performance' + }, + { + name: 'kstep', + description: 'How many elements to skip (default = 1)', + type: 'performance' + }, + ], + seeAlso: ['Printing and Display', 'Read/Write Operations'] +}, +{ + name: 'ftsamplebank', + type: 'opcode', + category: 'Table Control:Read/Write Operations', + description: 'Reads a directory for sound files and loads them to a series of GEN01 function tables.', + syntax: 'iNumberOfFile = ftsamplebank(SDirectory, iFirstTableNumber, iSkipTime, iFormat, \\\n iChannel,)\n kNumberOfFile = ftsamplebank(SDirectory, kFirstTableNumber, kTrigger, kSkipTime, \\\n kFormat, kChannel,)', + example: '--8<-- "examples/ftsamplebank.csd"', + parameters: [ + { + name: 'SDirectory', + description: 'a string that identifies the directory to browse for files', + type: 'initialization' + }, + { + name: 'FirstTableNumber', + description: 'this sets the number of the first table into which a soundfile will be loaded', + type: 'initialization' + }, + { + name: 'Trigger', + description: 'updates the tables when kTrigger is 1, only applicable to k-rate version.', + type: 'initialization' + }, + { + name: 'SkipTime', + description: 'begin reading at _skiptime_ seconds into the file.', + type: 'initialization' + }, + { + name: 'Format', + description: 'specifies the audio data-file format:', + type: 'initialization' + }, + { + name: 'Channel', + description: 'channel number to read in. 0 denotes read all channels.', + type: 'initialization' + }, + { + name: 'iNumberOfFile', + description: 'the number of tables that have been created', + type: 'performance' + }, + { + name: 'kNumberOfFile', + description: 'the number of tables that have been created', + type: 'performance' + }, + ], + seeAlso: ['Read/Write Operations'] +}, +{ + name: 'ftsave', + type: 'opcode', + category: 'Table Control:Read/Write Operations', + description: 'Save a set of previously-allocated tables to a file.', + syntax: 'ftsave("filename", iflag, ifn1 [, ifn2] [...])', + example: '--8<-- "examples/ftsave.csd"', + parameters: [ + { + name: 'iflag', + description: 'Type of the file to save. (0 = binary file, Non-zero = text file)', + type: 'initialization' + }, + ], + seeAlso: ['Read/Write Operations'] +}, +{ + name: 'ftsavek', + type: 'opcode', + category: 'Table Control:Read/Write Operations', + description: 'Save a set of previously-allocated tables to a file.', + syntax: 'ftsavek("filename", ktrig, iflag, ifn1 [, ifn2] [...])', + parameters: [ + { + name: 'iflag', + description: 'Type of the file to save. (0 = binary file, Non-zero = text file)', + type: 'initialization' + }, + { + name: 'ktrig', + description: 'The trigger signal. Save the file each time it is non-zero.', + type: 'performance' + }, + ], + seeAlso: ['Read/Write Operations'] +}, +{ + name: 'ftset', + type: 'opcode', + category: 'Table Control:Read/Write Operations', + description: 'Sets multiple elements of a table to a given value.', + syntax: 'ftset(ktablenum, kvalue [, kstart=0, kend=0, kstep=1 ])\n ftset(itablenum, ivalue [, istart=0, iend=0, istep=1 ])', + example: '--8<-- "examples/ftset.csd"', + parameters: [ + { + name: 'ktablenum', + description: 'the number of the table to be modified', + type: 'performance' + }, + { + name: 'kvalue', + description: 'the value to write to the table', + type: 'performance' + }, + { + name: 'kstart', + description: 'the start index to modify (defaults to 0)', + type: 'performance' + }, + { + name: 'kend', + description: 'the end index to modify. Defaults to 0, which indicates the end of the table. A negative index can be used to count from the end, so for example -1 will modifiy the table without changing the last element.', + type: 'performance' + }, + { + name: 'kstep', + description: 'the increment to use between modified indexes. Defaults to 1, which means to modify every element between start and end', + type: 'performance' + }, + ], + seeAlso: ['Read/Write Operations'] +}, +{ + name: 'ftslice', + type: 'opcode', + category: 'Table Control:Read/Write Operations', + description: 'Copy a slice from an f-table to another f-table at performance.', + syntax: 'ftslice(ifnsource, ifndest [, kstart, kend, kstep ])\n ftslice(kfnsource, kfndest [, kstart, kend, kstep ])', + example: '--8<-- "examples/ftslice.csd"', + parameters: [ + { + name: 'ifnsource', + description: 'The table number to copy data from', + type: 'initialization' + }, + { + name: 'ifndest', + description: 'The table number to copy data to', + type: 'initialization' + }, + { + name: 'kstart', + description: 'The index to start copying from. _Defaults to 0_', + type: 'performance' + }, + { + name: 'kend', + description: 'The end index to stop copying. This is NOT inclusive. 0 means copy to the end of the table. _Defaults to end of table_', + type: 'performance' + }, + { + name: 'kstep', + description: 'How many elements to skip. _Defaults to 1_', + type: 'performance' + }, + ], + seeAlso: ['Read/Write Operations'] +}, +{ + name: 'ftslicei', + type: 'opcode', + category: 'Table Control:Read/Write Operations', + description: 'Copy a slice from an f-table to another f-table at init.', + syntax: 'ftslicei(ifnsource, ifndest [, istart, iend, istep ])', + example: '--8<-- "examples/ftslice.csd"', + parameters: [ + { + name: 'ifnsource', + description: 'The table number to copy data from', + type: 'initialization' + }, + { + name: 'ifndest', + description: 'The table number to copy data to', + type: 'initialization' + }, + { + name: 'istart', + description: 'The index to start copying from. _Defaults to 0_', + type: 'initialization' + }, + { + name: 'iend', + description: 'The end index to stop copying. This is NOT inclusive. 0 means copy to the end of the table. _Defaults to end of table_', + type: 'initialization' + }, + { + name: 'istep', + description: 'How many elements to skip. _Defaults to 1_', + type: 'initialization' + }, + ], + seeAlso: ['Read/Write Operations'] +}, +] diff --git a/src/lib/csound-reference/table-control-table-queries.ts b/src/lib/csound-reference/table-control-table-queries.ts new file mode 100644 index 0000000..98d1320 --- /dev/null +++ b/src/lib/csound-reference/table-control-table-queries.ts @@ -0,0 +1,162 @@ +import type { CsoundReference } from './types' + +// Table Control:Table Queries +export const tableControlTableQueries: CsoundReference[] = [ +{ + name: 'ftchnls', + type: 'opcode', + category: 'Table Control:Table Queries', + description: 'Returns the number of channels in a stored function table.', + example: '--8<-- "examples/ftchnls.csd"', + seeAlso: ['Table Control:Table Queries'] +}, +{ + name: 'ftcps', + type: 'opcode', + category: 'Table Control:Table Queries', + description: 'Returns the base frequency of a stored function table in Hz.', + example: '--8<-- "examples/ftcps.csd"', + seeAlso: ['Table Control:Table Queries'] +}, +{ + name: 'ftexists', + type: 'opcode', + category: 'Table Control:Table Queries', + description: 'Query if a given table exists.', + syntax: 'iexists = ftexists(ifn)\n kexists = ftexists(kfn / ifn)', + example: '--8<-- "examples/ftexists.csd"', + rates: ['i-rate'], + seeAlso: ['Table Control:Table Queries'] +}, +{ + name: 'ftlen', + type: 'opcode', + category: 'Table Control:Table Queries', + description: 'Returns the size of a stored function table.', + example: '--8<-- "examples/ftlen.csd"', + seeAlso: ['Table Control:Table Queries'] +}, +{ + name: 'ftlptim', + type: 'opcode', + category: 'Table Control:Table Queries', + description: 'Returns the loop segment start-time of a stored function table number.', + example: '--8<-- "examples/ftlptim.csd"', + seeAlso: ['Table Control:Table Queries'] +}, +{ + name: 'ftsr', + type: 'opcode', + category: 'Table Control:Table Queries', + description: 'Returns the sampling-rate of a stored function table.', + example: '--8<-- "examples/ftsr.csd"', + seeAlso: ['Table Control:Table Queries'] +}, +{ + name: 'genarray_i', + type: 'opcode', + category: 'Table Control:Table Queries', + description: 'Generate a vector (one-dimensional k-rate) with an arithmetic sequence at initialisation time.', + syntax: 'karray = genarray_i(istart, iend [,inc])', + example: '--8<-- "examples/genarray_i.csd"', + parameters: [ + { + name: 'istart', + description: 'value to place in first element.', + type: 'initialization' + }, + { + name: 'iend', + description: 'last value to place in array.', + type: 'initialization' + }, + { + name: 'inc', + description: 'amount to add to previous value (default 1).', + type: 'initialization' + }, + ], + seeAlso: ['Vectorial opcodes', 'fillarray'] +}, +{ + name: 'lenarray', + type: 'opcode', + category: 'Table Control:Table Queries', + description: 'Evaluates the size or number of dimensions of an array.', + syntax: 'ir = lenarray(karray[, iwhich])\n kr = lenarray(karray[, iwhich])', + example: '--8<-- "examples/lenarray.csd"', + parameters: [ + { + name: 'kr', + description: 'length of vector.', + type: 'performance' + }, + { + name: 'karray', + description: 'array to query.', + type: 'performance' + }, + ], + seeAlso: ['Array opcodes'] +}, +{ + name: 'maparray', + type: 'opcode', + category: 'Table Control:Table Queries', + description: 'Apply a function of one argument to every element of a vector (one-dimensional k-rate array).', + syntax: 'karray = maparray(kinarray, String)\n karray = maparray_i(kinarray, String)', + example: '--8<-- "examples/maparray.csd"', + parameters: [ + { + name: 'String', + description: 'a string that names an opcode function, at i-rate for maparray_i or k-rate for maparray.', + type: 'initialization' + }, + { + name: 'karray', + description: 'array for answers.', + type: 'performance' + }, + { + name: 'kinarray', + description: 'array for arguments to the function.', + type: 'performance' + }, + ], + seeAlso: ['Array opcodes'] +}, +{ + name: 'nsamp', + type: 'opcode', + category: 'Table Control:Table Queries', + description: 'Returns the number of samples loaded into a stored function table number.', + example: '--8<-- "examples/nsamp.csd"', + seeAlso: ['Table Control:Table Queries'] +}, +{ + name: 'slicearray', + type: 'opcode', + category: 'Table Control:Table Queries', + description: 'Take a slice of a vector (one-dimensional k-rate array).', + syntax: 'karray = slicearray(kinarray, istart, iend [,istride])', + example: '--8<-- "examples/slicearray.csd"', + parameters: [ + { + name: 'istart', + description: 'index of the first part of the answer.', + type: 'initialization' + }, + { + name: 'iend', + description: 'index of the last element of the answer.', + type: 'initialization' + }, + { + name: 'istride', + description: 'increment for source elements (optional), defaults to 1.', + type: 'initialization' + }, + ], + seeAlso: ['Array opcodes'] +}, +] diff --git a/src/lib/csound-reference/table-control.ts b/src/lib/csound-reference/table-control.ts new file mode 100644 index 0000000..87a3c7b --- /dev/null +++ b/src/lib/csound-reference/table-control.ts @@ -0,0 +1,144 @@ +import type { CsoundReference } from './types' + +// Table Control +export const tableControl: CsoundReference[] = [ +{ + name: 'ftfree', + type: 'opcode', + category: 'Table Control', + description: 'Deletes function table.', + syntax: 'ftfree(ifno, iwhen)', + example: '--8<-- "examples/ftfree.csd"', + parameters: [ + { + name: 'ifno', + description: 'the number of the table to be deleted', + type: 'initialization' + }, + { + name: 'iwhen', + description: 'if zero the table is deleted at init time; otherwise the table number is registered for being deleted at note deactivation.', + type: 'initialization' + }, + ], + seeAlso: ['Function Table Control'] +}, +{ + name: 'ftgen', + type: 'opcode', + category: 'Table Control', + description: 'Generate a score function table from within the orchestra.', + syntax: 'gir = ftgen(ifn, itime, isize, igen, iarga [, iargb ] [...])\n gir = ftgen(ifn, itime, isize, igen, iarray)', + example: '--8<-- "examples/ftgen.csd"', + rates: ['i-rate'], + parameters: [ + { + name: 'gir', + description: 'either a requested or automatically assigned table number above 100.', + type: 'initialization' + }, + { + name: 'ifn', + description: 'requested table number If _ifn_ is zero, the number is assigned automatically and the value placed in _gir_. Any other value is used as the table number', + type: 'initialization' + }, + { + name: 'itime', + description: 'is ignored, but otherwise corresponds to p2 in the score _f statement_.', + type: 'initialization' + }, + { + name: 'isize', + description: 'table size. Corresponds to p3 of the score _f statement_.', + type: 'initialization' + }, + { + name: 'igen', + description: 'function table _GEN_ routine. Corresponds to p4 of the score _f statement_.', + type: 'initialization' + }, + { + name: 'iarray', + description: 'ane dimensionl array holding the function table arguments. Correspond to p5 through pn of the score _f statement_.', + type: 'initialization' + }, + ], + seeAlso: ['GEN routine overview', 'Orchestra Header Statements'] +}, +{ + name: 'ftgentmp', + type: 'opcode', + category: 'Table Control', + description: 'Generate a score function table from within the orchestra, which is deleted at the end of the note.', + syntax: 'ifno = ftgentmp(ip1, ip2dummy, isize, igen, iarga, iargb, ...)', + example: '--8<-- "examples/ftgentmp.csd"', + parameters: [ + { + name: 'ifno', + description: 'either a requested or automatically assigned table number above 100.', + type: 'initialization' + }, + { + name: 'ip1', + description: 'the number of the table to be generated or 0 if the number is to be assigned, in which case the table is deleted at the end of the note activation.', + type: 'initialization' + }, + { + name: 'ip2dummy', + description: 'ignored.', + type: 'initialization' + }, + { + name: 'isize', + description: 'table size. Corresponds to p3 of the score _f statement_.', + type: 'initialization' + }, + { + name: 'igen', + description: 'function table _GEN_ routine. Corresponds to p4 of the score _f statement_.', + type: 'initialization' + }, + ], + seeAlso: ['Function Table Control'] +}, +{ + name: 'getftargs', + type: 'opcode', + category: 'Table Control', + description: 'Fill a string variable with the arguments used to create a function table at k-rate.', + syntax: 'Sdst = getftargs(iftno, ktrig)', + example: '--8<-- "examples/getftargs.csd"', + parameters: [ + { + name: 'ifno', + description: 'Number of the table whose arguments we want to request.', + type: 'initialization' + }, + { + name: 'Sdst', + description: 'output string variable.', + type: 'performance' + }, + { + name: 'ktrig', + description: 'trigger signal, should be valid at i-time. The output string variable is filled at initialization time if ktrig is positive, and at performance time whenever ktrig is both positive and different from the previous value. Use a constant value of 1 to print once at note initialization.', + type: 'performance' + }, + ], + seeAlso: ['Table Control:Table Queries'] +}, +{ + name: 'sndload', + type: 'opcode', + category: 'Table Control', + description: 'Loads a sound file into memory for use by [loscilx](../opcodes/loscilx.md).', + syntax: 'sndload(Sfname[, ifmt[, ichns[, isr[, ibas[, iamp[, istrt [, ilpmod[, ilps \\\n [, ilpe]]]]]]]]])', + parameters: [ + { + name: 'Sfname', + description: 'file name as a string constant or variable, string p-field, or a number that is used either as an index to strings set with strset, or, if that is not available, a file name in the format soundin.n is used. If the file name does not include a full path, the file is searched in the current directory first, then those specified by [SSDIR](../invoke/environment-variables.md) (if defined), and finally [SFDIR](../invoke/environment-variables.md). If the same file was already loaded previously, it will not be read again, but the parameters ibas, iamp, istrt, ilpmod, ilps, and ilpe are still updated.', + type: 'initialization' + }, + ], +}, +] diff --git a/src/lib/csound-reference/types.ts b/src/lib/csound-reference/types.ts new file mode 100644 index 0000000..ee03138 --- /dev/null +++ b/src/lib/csound-reference/types.ts @@ -0,0 +1,35 @@ +export interface CsoundReference { + name: string + type: 'opcode' | 'keyword' | 'header' | 'constant' + category: string + description: string + syntax?: string + example?: string + rates?: string[] + parameters?: { + name: string + description: string + type: 'initialization' | 'performance' + }[] + seeAlso?: string[] +} + +export interface ParsedOpcode { + id: string + category: string + title: string + description: string + syntaxModern?: string + syntaxClassic?: string + initParams: { name: string; description: string }[] + perfParams: { name: string; description: string }[] + example?: string + seeAlso: string[] + rawContent: string +} + +export interface CategoryGroup { + categoryKey: string + categoryName: string + opcodes: CsoundReference[] +} diff --git a/src/lib/csound-reference/utilities.ts b/src/lib/csound-reference/utilities.ts new file mode 100644 index 0000000..db58750 --- /dev/null +++ b/src/lib/csound-reference/utilities.ts @@ -0,0 +1,46 @@ +import type { CsoundReference } from './types' + +// Utilities +export const utilities: CsoundReference[] = [ +{ + name: 'lufs', + type: 'opcode', + category: 'Utilities', + description: 'Momentary, Integrated and Short-Term Loudness meter in LUFS.', + syntax: 'kmom, kint, kshort = lufs(kreset, ain1 [, ain2])', + example: '--8<-- "examples/lufs.csd"', + parameters: [ + { + name: 'kreset', + description: 'reset input. It resets the value of the integrated loudness if kreset is not 0.', + type: 'performance' + }, + { + name: 'ain1', + description: 'input audio signal(s). Only mono and stereo are supported (see below)', + type: 'performance' + }, + { + name: 'ain2', + description: 'input audio signal(s). Only mono and stereo are supported (see below)', + type: 'performance' + }, + { + name: 'kmom', + description: 'momentary loudness in LUFS', + type: 'performance' + }, + { + name: 'kint', + description: 'integrated loudness in LUFS', + type: 'performance' + }, + { + name: 'kshort', + description: 'short-term loudness in LUFS', + type: 'performance' + }, + ], + seeAlso: ['Sensing and Control: Envelope followers'] +}, +] diff --git a/src/lib/csound-reference/vectorial-cellular-automata.ts b/src/lib/csound-reference/vectorial-cellular-automata.ts new file mode 100644 index 0000000..ae41694 --- /dev/null +++ b/src/lib/csound-reference/vectorial-cellular-automata.ts @@ -0,0 +1,46 @@ +import type { CsoundReference } from './types' + +// Vectorial:Cellular Automata +export const vectorialCellularAutomata: CsoundReference[] = [ +{ + name: 'cell', + type: 'opcode', + category: 'Vectorial:Cellular Automata', + description: 'Cellular Automaton.', + syntax: 'cell(ktrig, kreinit, ioutFunc, initStateFunc, iRuleFunc, ielements)', + example: '--8<-- "examples/cell-modern.csd"', + parameters: [ + { + name: 'ioutFunc', + description: 'number of the table where the state of each cell is stored.', + type: 'initialization' + }, + { + name: 'initStateFunc', + description: 'number of the table containing the inital states of cells.', + type: 'initialization' + }, + { + name: 'iRuleFunc', + description: 'number of a lookup table containing the 8-bit rule.', + type: 'initialization' + }, + { + name: 'ielements', + description: 'total number of cells in a row.', + type: 'initialization' + }, + { + name: 'ktri', + description: 'trigger signal. Each time it is non-zero, a new generation of cells is evaluated.', + type: 'performance' + }, + { + name: 'kreinit', + description: 'reset signal. Each time it is non-zero, state of all cells is forced to be that of initStateFunc.', + type: 'performance' + }, + ], + seeAlso: ['Models and Emulations'] +}, +] diff --git a/to_continue.md b/to_continue.md deleted file mode 100644 index b02c0af..0000000 --- a/to_continue.md +++ /dev/null @@ -1,1030 +0,0 @@ -# Project Mode Implementation - Continuation Guide - -## Overview - -This document provides a complete roadmap for continuing the implementation of dual-mode support in OldBoy: **Composition Mode** (full document evaluation) and **Live Coding Mode** (block-based evaluation with persistent Csound instance). - ---- - -## What Has Been Completed - -### 1. Type System & Data Model ✅ - -**Files Modified:** -- `/src/lib/project-system/types.ts` -- `/src/lib/project-system/project-manager.ts` - -**Changes:** -1. Created `ProjectMode` type: - ```typescript - export type ProjectMode = 'composition' | 'livecoding'; - ``` - -2. Added `mode` field to `CsoundProject` interface: - ```typescript - export interface CsoundProject { - // ... existing fields - mode: ProjectMode; // NEW: Execution mode - } - ``` - -3. Updated `CreateProjectData` to accept optional mode: - ```typescript - export interface CreateProjectData { - // ... existing fields - mode?: ProjectMode; // Defaults to 'composition' if not provided - } - ``` - -4. Updated `UpdateProjectData` to allow mode updates: - ```typescript - export interface UpdateProjectData { - // ... existing fields - mode?: ProjectMode; // Can change mode after creation - } - ``` - -5. Modified `ProjectManager.createProject()`: - - Line 100: Added `mode: data.mode || 'composition'` to project initialization - - Ensures all new projects have a mode (defaults to composition) - -6. Modified `ProjectManager.updateProject()`: - - Line 165: Added `...(data.mode !== undefined && { mode: data.mode })` to update logic - - Allows mode to be updated without affecting other fields - -**Result:** All projects now have a mode field that persists in IndexedDB and is included in import/export operations. - ---- - -### 2. UI for Mode Selection ✅ - -**Files Modified:** -- `/src/lib/components/ui/FileBrowser.svelte` -- `/src/lib/stores/projectEditor.svelte.ts` -- `/src/App.svelte` - -**FileBrowser Changes:** - -1. **Imports (Line 7):** - ```typescript - import type { ProjectMode } from '../../project-system/types'; - ``` - -2. **Props Interface (Line 13):** - ```typescript - onMetadataUpdate?: (projectId: string, updates: { - title?: string; - author?: string; - mode?: ProjectMode // NEW - }) => void; - ``` - -3. **State (Line 30):** - ```typescript - let editMode = $state('composition'); - ``` - -4. **Effect Hook (Lines 32-38):** - ```typescript - $effect(() => { - if (selectedProject) { - editTitle = selectedProject.title; - editAuthor = selectedProject.author; - editMode = selectedProject.mode; // NEW: Sync mode from project - } - }); - ``` - -5. **Metadata Change Handler (Lines 103-118):** - ```typescript - function handleMetadataChange() { - if (!selectedProject) return; - - const hasChanges = - editTitle !== selectedProject.title || - editAuthor !== selectedProject.author || - editMode !== selectedProject.mode; // NEW: Include mode in change detection - - if (hasChanges) { - onMetadataUpdate?.(selectedProject.id, { - title: editTitle, - author: editAuthor, - mode: editMode // NEW: Send mode updates - }); - } - } - ``` - -6. **UI Element (Lines 183-193):** - ```svelte -
- - -
- ``` - -7. **CSS (Lines 373-390):** - ```css - .field input, - .field select { - padding: 0.5rem; - background-color: #2a2a2a; - border: 1px solid #3a3a3a; - color: rgba(255, 255, 255, 0.87); - font-size: 0.875rem; - outline: none; - } - - .field select { - cursor: pointer; - } - ``` - -**ProjectEditor Changes (Line 108):** -```typescript -async updateMetadata(updates: { - title?: string; - author?: string; - mode?: import('../project-system/types').ProjectMode // NEW -}): Promise -``` - -**App.svelte Changes (Line 123):** -```typescript -async function handleMetadataUpdate( - projectId: string, - updates: { - title?: string; - author?: string; - mode?: import('./lib/project-system/types').ProjectMode // NEW - } -) -``` - -**Result:** Users can now select project mode in the Files panel metadata editor. Mode changes are immediately persisted. - ---- - -### 3. Block Evaluation Infrastructure ✅ - -**File Created:** -- `/src/lib/editor/block-eval.ts` - -**Purpose:** Provides utilities for extracting code blocks and visual feedback, adapted from flok's cm-eval package. - -**Exports:** - -1. **`flash(view, from, to, timeout)`** - - Visually highlights evaluated code region - - Default timeout: 150ms - - Background color: `#FFCA2880` (yellow with transparency) - -2. **`flashField(style?)`** - - CodeMirror StateField for managing flash decorations - - Returns StateField to be added to editor extensions - - Handles flash effect lifecycle - -3. **`getSelection(state): EvalBlock`** - - Returns currently selected text with positions - - Returns `{ text: '', from: null, to: null }` if no selection - -4. **`getLine(state): EvalBlock`** - - Returns the entire line at cursor position - - Includes line's from/to positions - -5. **`getBlock(state): EvalBlock`** - - Returns paragraph block (text separated by blank lines) - - Searches up and down from cursor until blank lines found - - Core functionality for live coding mode - -6. **`getDocument(state): EvalBlock`** - - Returns entire document text - - Used for composition mode evaluation - -**EvalBlock Interface:** -```typescript -interface EvalBlock { - text: string; // The code to evaluate - from: number | null; // Start position in document - to: number | null; // End position in document -} -``` - -**Implementation Details:** - -- **Block Detection Algorithm:** - 1. Start at cursor line - 2. If line is blank, return empty block - 3. Search backwards until blank line or document start - 4. Search forwards until blank line or document end - 5. Extract text from start to end positions - -- **Flash Effect:** - - Uses CodeMirror StateEffect system - - Creates decoration with inline style - - Automatically clears after timeout - - Non-blocking (doesn't prevent editing) - -**Result:** Complete block evaluation infrastructure ready to integrate with Editor component. - ---- - -## What Needs to Be Done Next - -### Phase 1: Editor Integration with Block Evaluation - -**Goal:** Connect block-eval utilities to the Editor component and add visual feedback. - -**File to Modify:** `/src/lib/components/editor/Editor.svelte` - -**Steps:** - -1. **Import block-eval utilities (add to imports):** - ```typescript - import { - flashField, - flash, - getSelection, - getBlock, - getDocument - } from '../editor/block-eval'; - ``` - -2. **Add flashField to extensions:** - - Find where extensions are created (likely in a `$derived` or similar). It should look something like: - ```typescript - let extensions = $derived([ - // ... existing extensions - ]); - ``` - - Add flashField: - ```typescript - let extensions = $derived([ - // ... existing extensions - flashField(), // NEW: Add flash effect support - ]); - ``` - -3. **Expose block extraction methods:** - - Add these methods to the Editor component (after the component logic, before closing tag): - ```typescript - export function getSelectedText(): string | null { - if (!editorView) return null; - const { text } = getSelection(editorView.state); - return text || null; - } - - export function getCurrentBlock(): string | null { - if (!editorView) return null; - const { text } = getBlock(editorView.state); - return text || null; - } - - export function getFullDocument(): string { - if (!editorView) return ''; - const { text } = getDocument(editorView.state); - return text; - } - - export function evaluateWithFlash(text: string, from: number | null, to: number | null) { - if (editorView && from !== null && to !== null) { - flash(editorView, from, to); - } - } - ``` - -4. **Modify keyboard shortcut for execute:** - - Find the keyboard shortcut setup (search for "Ctrl-Enter" or "Cmd-Enter"). It might look like: - ```typescript - keymap.of([ - { - key: "Ctrl-Enter", - run: () => { - onExecute?.(value); - return true; - } - } - ]) - ``` - - Change it to call a new internal method: - ```typescript - keymap.of([ - { - key: "Ctrl-Enter", - mac: "Cmd-Enter", - run: () => { - handleExecute(); - return true; - } - } - ]) - ``` - -5. **Add internal execute handler:** - ```typescript - function handleExecute() { - if (!editorView) return; - - // Get selection or block - const selection = getSelection(editorView.state); - if (selection.text) { - // Has selection: evaluate it - flash(editorView, selection.from, selection.to); - onExecute?.(selection.text, 'selection'); - } else { - // No selection: evaluate block or document based on mode - // For now, always get block (mode logic will be in App.svelte) - const block = getBlock(editorView.state); - if (block.text) { - flash(editorView, block.from, block.to); - onExecute?.(block.text, 'block'); - } - } - } - ``` - -6. **Update onExecute prop type:** - - Change the prop signature from: - ```typescript - onExecute?: (code: string) => void; - ``` - - To: - ```typescript - onExecute?: (code: string, source: 'selection' | 'block' | 'document') => void; - ``` - -**Expected Result:** -- Cmd/Ctrl+Enter will flash the code being evaluated -- Editor can distinguish between selection, block, and document evaluation -- Parent components can access block extraction methods - ---- - -### Phase 2: Execution Strategy Implementation - -**Goal:** Create strategy pattern for handling composition vs livecoding execution modes. - -**File to Create:** `/src/lib/csound/execution-strategies.ts` - -**Implementation:** - -```typescript -import type { CsoundStore } from './store'; -import type { ProjectMode } from '../project-system/types'; - -export interface ExecutionStrategy { - execute( - csound: CsoundStore, - code: string, - fullContent: string, - source: 'selection' | 'block' | 'document' - ): Promise; -} - -/** - * Composition Mode Strategy - * - Always evaluates full CSD document - * - Uses ephemeral instances (fresh instance each time) - * - Standard workflow: compile → start → play → cleanup - */ -export class CompositionStrategy implements ExecutionStrategy { - async execute( - csound: CsoundStore, - code: string, - fullContent: string, - source: 'selection' | 'block' | 'document' - ): Promise { - // Always evaluate full document in composition mode - await csound.evaluate(fullContent); - } -} - -/** - * Live Coding Mode Strategy - * - Evaluates blocks incrementally - * - Uses persistent instance (maintains state) - * - Supports: score events, channel updates, instrument redefinition - */ -export class LiveCodingStrategy implements ExecutionStrategy { - private isInitialized = false; - private headerCompiled = false; - - async execute( - csound: CsoundStore, - code: string, - fullContent: string, - source: 'selection' | 'block' | 'document' - ): Promise { - // First time: initialize with full document - if (!this.isInitialized) { - await this.initializeFromDocument(csound, fullContent); - this.isInitialized = true; - return; - } - - // Subsequent evaluations: handle blocks - await this.evaluateBlock(csound, code); - } - - private async initializeFromDocument( - csound: CsoundStore, - fullContent: string - ): Promise { - // Parse CSD to extract orchestra and initial score - const { header, instruments, score } = this.parseCSD(fullContent); - - // Compile header + instruments - const fullOrchestra = header + '\n' + instruments; - const compileResult = await csound.compileOrchestra(fullOrchestra); - - if (!compileResult.success) { - throw new Error(compileResult.errorMessage || 'Compilation failed'); - } - - this.headerCompiled = true; - - // Start performance - await csound.startPerformance(); - - // If score has events, send them - if (score.trim()) { - await csound.readScore(score); - } - } - - private async evaluateBlock(csound: CsoundStore, code: string): Promise { - const trimmedCode = code.trim(); - - if (!trimmedCode) return; - - // Detect what kind of code this is - if (this.isScoreEvent(trimmedCode)) { - // Send score event (e.g., "i 1 0 2 0.5") - await csound.sendScoreEvent(trimmedCode); - } - else if (this.isInstrumentDefinition(trimmedCode)) { - // Recompile instrument - await csound.compileOrchestra(trimmedCode); - } - else if (this.isChannelSet(trimmedCode)) { - // Set channel value (e.g., "freq = 440") - await this.handleChannelSet(csound, trimmedCode); - } - else { - // Default: try to compile as orchestra code - await csound.compileOrchestra(trimmedCode); - } - } - - private parseCSD(content: string): { - header: string; - instruments: string; - score: string - } { - // Extract section - const orcMatch = content.match(/([\s\S]*?)<\/CsInstruments>/); - if (!orcMatch) { - return { header: '', instruments: '', score: '' }; - } - - const orchestra = orcMatch[1].trim(); - - // Extract section - const scoMatch = content.match(/([\s\S]*?)<\/CsScore>/); - const score = scoMatch ? scoMatch[1].trim() : ''; - - // Split orchestra into header (sr, ksmps, nchnls, etc.) and instruments - const instrMatch = orchestra.match(/([\s\S]*?)(instr\s+\d+[\s\S]*)/); - - if (instrMatch) { - return { - header: instrMatch[1].trim(), - instruments: instrMatch[2].trim(), - score - }; - } - - // If no instruments found, treat entire orchestra as header - return { - header: orchestra, - instruments: '', - score - }; - } - - private isScoreEvent(code: string): boolean { - // Check for score event syntax: i, f, e, a followed by space/number - return /^[ifea]\s+[\d\-]/.test(code); - } - - private isInstrumentDefinition(code: string): boolean { - // Check for instrument definition - return /^\s*instr\s+/.test(code); - } - - private isChannelSet(code: string): boolean { - // Simple channel set syntax: varname = value - // e.g., "freq = 440" or "cutoff = 2000" - return /^\w+\s*=\s*[\d\.\-]+/.test(code); - } - - private async handleChannelSet(csound: CsoundStore, code: string): Promise { - // Parse: varname = value - const match = code.match(/^(\w+)\s*=\s*([\d\.\-]+)/); - if (!match) return; - - const [, channelName, valueStr] = match; - const value = parseFloat(valueStr); - - await csound.setControlChannel(channelName, value); - } - - /** - * Reset the strategy state (called when switching documents or resetting) - */ - reset(): void { - this.isInitialized = false; - this.headerCompiled = false; - } -} - -/** - * Factory function to create appropriate strategy based on mode - */ -export function createExecutionStrategy(mode: ProjectMode): ExecutionStrategy { - return mode === 'livecoding' - ? new LiveCodingStrategy() - : new CompositionStrategy(); -} -``` - -**Expected Result:** -- Strategy pattern cleanly separates composition and livecoding behaviors -- LiveCodingStrategy maintains state across evaluations -- Supports score events, instrument redefinition, and channel control - ---- - -### Phase 3: Update App.svelte to Use Strategies - -**File to Modify:** `/src/App.svelte` - -**Steps:** - -1. **Import strategy utilities:** - ```typescript - import { createExecutionStrategy, type ExecutionStrategy } from './lib/csound/execution-strategies'; - ``` - -2. **Track current strategy:** - ```typescript - let currentStrategy = $state(null); - let currentMode = $state('composition'); - ``` - -3. **Update strategy when project changes:** - - Add effect to watch for project mode changes: - ```typescript - $effect(() => { - const mode = projectEditor.currentProject?.mode || 'composition'; - - // Only recreate strategy if mode changed - if (mode !== currentMode) { - currentMode = mode; - currentStrategy = createExecutionStrategy(mode); - - // If switching to livecoding, need to reset csound - if (mode === 'livecoding') { - // Reset to ensure clean state - csound.reset().catch(console.error); - } - } - }); - ``` - -4. **Update handleExecute function:** - - Replace existing handleExecute (around line 99): - ```typescript - async function handleExecute(code: string, source: 'selection' | 'block' | 'document') { - try { - if (!currentStrategy) { - currentStrategy = createExecutionStrategy(currentMode); - } - - const fullContent = projectEditor.content; - await currentStrategy.execute(csound, code, fullContent, source); - } catch (error) { - console.error('Execution error:', error); - } - } - ``` - -5. **Update EditorWithLogs onExecute prop:** - - Find where EditorWithLogs is used (around line 274): - ```svelte - - logs={interpreterLogs} - {editorSettings} - /> - ``` - -**Expected Result:** -- App automatically uses correct strategy based on project mode -- Strategy instance persists across evaluations -- Mode switches trigger proper cleanup/reset - ---- - -### Phase 4: Update Csound Store for Mode-Aware Instance Management - -**Goal:** Make Csound store use persistent vs ephemeral instances based on project mode. - -**File to Modify:** `/src/lib/contexts/app-context.ts` - -**Current Code (likely around line 10-15):** -```typescript -const csound = createCsoundStore(); -``` - -**Change to:** -```typescript -const csound = createCsoundStore('ephemeral'); // Default to ephemeral -``` - -**Then in App.svelte, add mode-based reset logic:** - -In the `$effect` that watches mode changes (from Phase 3, Step 3), enhance it: - -```typescript -$effect(() => { - const mode = projectEditor.currentProject?.mode || 'composition'; - - if (mode !== currentMode) { - const oldMode = currentMode; - currentMode = mode; - currentStrategy = createExecutionStrategy(mode); - - // Handle Csound instance mode switching - if (mode === 'livecoding' && oldMode === 'composition') { - // Switching TO livecoding: need persistent instance - // Reset will be handled by first LiveCodingStrategy execution - console.log('Switched to live coding mode'); - } else if (mode === 'composition' && oldMode === 'livecoding') { - // Switching FROM livecoding: stop and cleanup - csound.stop().catch(console.error); - console.log('Switched to composition mode'); - } - } -}); -``` - -**Note:** The actual instance mode (ephemeral/persistent) is now implicitly handled by the strategy: -- **CompositionStrategy**: calls `csound.evaluate()` which uses ephemeral mode (current default) -- **LiveCodingStrategy**: calls `compileOrchestra()` + `startPerformance()` which uses the same instance repeatedly - -The key insight is that **persistence is achieved by NOT calling `evaluate()`** (which destroys/recreates), but instead using the low-level API (`compileOrchestra`, `startPerformance`, `sendScoreEvent`). - -**Expected Result:** -- Composition mode: Each evaluation gets fresh instance -- Live coding mode: Single instance persists across block evaluations -- Switching modes properly cleans up old instances - ---- - -### Phase 5: Testing & Verification - -**Test Plan:** - -#### Test 1: Composition Mode (Baseline) -1. Create new project (defaults to composition mode) -2. Paste this CSD code: - ```csound - - - -odac - - - sr = 48000 - ksmps = 32 - nchnls = 2 - 0dbfs = 1 - - instr 1 - aOut poscil 0.2, 440 - outs aOut, aOut - endin - - - i 1 0 2 - - - ``` -3. Press Cmd/Ctrl+Enter -4. **Expected:** Entire document flashes yellow, sound plays for 2 seconds -5. Modify frequency to 880, press Cmd/Ctrl+Enter again -6. **Expected:** New instance created, new sound plays - -#### Test 2: Live Coding Mode - Initial Setup -1. Open FileBrowser, select the project -2. In metadata, change Mode from "Composition" to "Live Coding" -3. Press Cmd/Ctrl+Enter on the entire document -4. **Expected:** - - Document flashes - - Csound initializes (check logs for "Starting performance...") - - Sound plays if score has events - -#### Test 3: Live Coding Mode - Block Evaluation -1. Clear the `` section (or comment out with semicolons) -2. Ensure document is initialized (press Cmd/Ctrl+Enter on full document) -3. Add a new line at the bottom of the document: - ```csound - i 1 0 2 0.5 - ``` -4. Place cursor on that line, press Cmd/Ctrl+Enter -5. **Expected:** - - Only that line flashes - - Sound plays immediately (instrument 1 triggered) - - Logs show score event sent, NOT full recompilation - -#### Test 4: Live Coding Mode - Channel Control -1. Modify instrument 1 to use a channel: - ```csound - instr 1 - kFreq chnget "freq" - aOut poscil 0.2, kFreq - outs aOut, aOut - endin - ``` -2. Reinitialize (Cmd+Enter on full document) -3. Start a long note: - ```csound - i 1 0 60 - ``` -4. While playing, evaluate this block: - ```csound - freq = 440 - ``` -5. Then evaluate: - ```csound - freq = 880 - ``` -6. **Expected:** - - Frequency changes in real-time while note plays - - No audio interruption - -#### Test 5: Live Coding Mode - Instrument Redefinition -1. While note is playing from Test 4, modify instrument 1: - ```csound - instr 1 - kFreq chnget "freq" - aOut vco2 0.2, kFreq - outs aOut, aOut - endin - ``` -2. Select only the instrument definition, press Cmd+Enter -3. **Expected:** - - Instrument recompiles - - Next triggered note uses new definition - - Currently playing notes might continue with old definition (Csound behavior) - -#### Test 6: Mode Switching -1. In live coding mode with performance running -2. Switch mode to "Composition" in FileBrowser -3. **Expected:** - - Performance stops - - Logs show "Stopped" -4. Press Cmd+Enter -5. **Expected:** - - Full document evaluation (composition mode behavior) - -#### Test 7: Persistence Across Sessions -1. Create project in live coding mode -2. Close browser tab -3. Reopen, load project -4. **Expected:** - - Mode is still "Live Coding" in metadata - - First evaluation initializes correctly - ---- - -## Troubleshooting Guide - -### Issue: "Cannot find module '@flok-editor/session'" - -**Cause:** The block-eval code references types from flok's session package. - -**Solution:** -- Our implementation in `/src/lib/editor/block-eval.ts` is standalone and doesn't need this -- If TypeScript complains, we don't use the `Document` type from flok -- Our editor integration passes callbacks, not Document objects - -### Issue: Flashing doesn't appear - -**Cause:** flashField not added to editor extensions - -**Solution:** -1. Verify `import { flashField } from '../editor/block-eval'` in Editor.svelte -2. Verify `flashField()` is in the extensions array -3. Check browser console for errors - -### Issue: Block evaluation evaluates wrong text - -**Cause:** Block detection algorithm confused by comment syntax - -**Solution:** -- Csound uses `;` for line comments -- Blank line detection: `line.text.trim().length === 0` -- If commented lines interfere, update `getBlock()` to treat `;`-only lines as blank - -### Issue: Live coding mode doesn't persist - -**Cause:** Strategy state lost between evaluations - -**Solution:** -- Verify `currentStrategy` is stored in `$state()`, not recreated each time -- Check that `$effect` only recreates strategy when mode actually changes -- Ensure LiveCodingStrategy instance is reused - -### Issue: Performance doesn't start in live coding mode - -**Cause:** `startPerformance()` not called or called before compilation - -**Solution:** -- Check logs for compilation errors -- Verify `compileOrchestra()` returns `success: true` -- Ensure `startPerformance()` is awaited - -### Issue: Mode changes don't take effect - -**Cause:** Project not reloaded after metadata update - -**Solution:** -- `handleMetadataUpdate()` should call `projectEditor.updateMetadata()` -- This should update `projectEditor.currentProject` -- `$effect` watching `currentProject?.mode` should trigger -- Verify effect dependencies are correct - ---- - -## File Structure Reference - -### New Files Created -``` -/src/lib/editor/block-eval.ts - Block evaluation utilities (✅ COMPLETE) -/src/lib/csound/execution-strategies.ts - Strategy pattern (❌ TODO) -``` - -### Modified Files -``` -/src/lib/project-system/types.ts - Added ProjectMode type (✅ COMPLETE) -/src/lib/project-system/project-manager.ts - Added mode handling (✅ COMPLETE) -/src/lib/components/ui/FileBrowser.svelte - Added mode selector UI (✅ COMPLETE) -/src/lib/stores/projectEditor.svelte.ts - Updated metadata types (✅ COMPLETE) -/src/App.svelte - Updated handlers (✅ PARTIAL - needs strategy integration) -/src/lib/components/editor/Editor.svelte - Needs block eval integration (❌ TODO) -/src/lib/contexts/app-context.ts - Might need mode-aware csound init (❌ TODO) -``` - ---- - -## Key Design Principles to Remember - -1. **No Fallbacks**: If livecoding fails, it fails. Don't silently fall back to composition mode. - -2. **Mode Per Project**: Mode is project metadata, not global state. Different tabs could have different modes. - -3. **Persistent = Reuse Low-Level API**: Persistence isn't a csound setting, it's about calling `compileOrchestra()` + `startPerformance()` instead of `evaluate()`. - -4. **Block = Paragraph**: A block is text separated by blank lines. This is the standard live coding convention. - -5. **Flash for Feedback**: Always flash evaluated code so user knows what executed. - -6. **Strategy Owns State**: LiveCodingStrategy tracks initialization state, not the store or app. - ---- - -## Implementation Order - -Follow this exact order to minimize issues: - -1. ✅ **Phase 1**: Editor integration (visual feedback works first) -2. ✅ **Phase 2**: Create execution strategies (logic isolated and testable) -3. ✅ **Phase 3**: Wire strategies to App.svelte (connect pieces) -4. ✅ **Phase 4**: Verify instance management (make sure persistence works) -5. ✅ **Phase 5**: Test thoroughly (catch edge cases) - ---- - -## Success Criteria - -### Composition Mode -- [✅] Full document evaluation on Cmd+Enter -- [✅] Flash effect shows what was evaluated -- [✅] Fresh instance every time (no state leakage) - -### Live Coding Mode -- [❌] First evaluation initializes from full document -- [❌] Subsequent evaluations process blocks incrementally -- [❌] Score events trigger sounds immediately -- [❌] Channel updates affect running performance -- [❌] Instrument redefinition works -- [❌] Instance persists across evaluations -- [❌] Logs show block evaluations, not full recompilations - -### Both Modes -- [✅] Mode selection UI works -- [✅] Mode persists in database -- [❌] Mode switching cleans up properly -- [❌] Keyboard shortcuts work consistently - ---- - -## Additional Notes - -### Why Ephemeral Default Makes Sense Now - -The original implementation used ephemeral mode by default because Web Audio reconnection after `csound.reset()` was unreliable. However, in live coding mode: - -- We **don't call `reset()`** between evaluations -- We **don't call `evaluate()`** which destroys the instance -- We use **low-level API** (`compileOrchestra`, `sendScoreEvent`) which reuses the instance - -So "persistent mode" is actually achieved by **avoiding the methods that destroy/recreate**. - -### Why We Adapted cm-eval Instead of Using It - -The flok cm-eval package: -- Assumes a `Document` object with an `evaluate()` method -- Is tightly coupled to flok's session architecture -- Uses their specific remote evaluation system - -Our needs: -- Evaluate blocks locally (no remote) -- Different document format (CSD vs raw code) -- Integrate with existing Csound store - -Solution: Extract the core block detection and flash logic, adapt for our architecture. - -### Csound Score Event Syntax Quick Reference - -For testing live coding mode: - -```csound -; Start instrument 1 at time 0, duration 2 seconds, amplitude 0.5 -i 1 0 2 0.5 - -; Start instrument 1 now (time 0), indefinite duration (-1) -i 1 0 -1 0.5 - -; Turn off all instances of instrument 1 -i -1 0 0 - -; Function table: create table 1, size 8192, sine wave -f 1 0 8192 10 1 -``` - ---- - -## Next Session Checklist - -When you resume implementation: - -- [ ] Read this document thoroughly -- [ ] Verify all completed work with `pnpm build` -- [ ] Start with Phase 1 (Editor integration) -- [ ] Test each phase before moving to next -- [ ] Update this document if you deviate from the plan -- [ ] Document any issues found and solutions - ---- - -## Questions to Resolve - -None at this time. The architecture is well-defined and ready for implementation. - ---- - -**Document Version:** 1.0 -**Last Updated:** 2025-01-15 -**Status:** Ready for Phase 1 implementation