Audio¶
Audio entrainment pipeline: adaptive session engine, entrainment verification scoring (EVS), SSGF-based geometry-to-audio mapping, and per-user profile persistence.
Adaptive Engine¶
sc_neurocore.audio.adaptive_engine
¶
AdaptiveSessionReport
dataclass
¶
Summary of a completed adaptive audio session.
Source code in src/sc_neurocore/audio/adaptive_engine.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |
AdaptiveAudioEngine
¶
Closed-loop adaptive audio controller coupling SSGF with EVS.
Parameters¶
ssgf : SSGFEngine The geometry solver producing audio mappings. evs : EVSEngine The entrainment verification scorer. profile : UserProfile, optional User preferences for chronotype-aware adaptation.
Source code in src/sc_neurocore/audio/adaptive_engine.py
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 | |
on_evs_update(snapshot)
¶
Process one EVS update and return adapted audio parameters.
This is the main feedback loop entry point. Call it each time a new EVSSnapshot is available (~every 500 ms).
Returns¶
dict Audio parameters from SSGF, possibly adjusted by adaptation.
Source code in src/sc_neurocore/audio/adaptive_engine.py
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | |
get_session_report()
¶
Generate summary report of the current session.
Source code in src/sc_neurocore/audio/adaptive_engine.py
345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 | |
reset()
¶
Reset session state (does not reset SSGF or EVS).
Source code in src/sc_neurocore/audio/adaptive_engine.py
386 387 388 389 390 391 392 393 394 395 396 | |
EVS Engine¶
sc_neurocore.audio.evs_engine
¶
EVSConfig
dataclass
¶
Tuneable parameters for the EVS engine.
Source code in src/sc_neurocore/audio/evs_engine.py
64 65 66 67 68 69 70 71 | |
EVSSnapshot
dataclass
¶
Single-tick EVS observation.
Source code in src/sc_neurocore/audio/evs_engine.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |
EVSEngine
¶
FFT-based Entrainment Verification Score engine.
Workflow¶
start_baseline()-- begin collecting baseline EEGadd_sample(voltage)-- feed raw EEG samples one at a time- After baseline_duration_s, baseline finalises automatically
set_target(hz)-- set the entrainment target frequencycompute()returnsEVSSnapshotevery update_interval_samples
Source code in src/sc_neurocore/audio/evs_engine.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 | |
start_baseline()
¶
Begin baseline EEG collection.
Source code in src/sc_neurocore/audio/evs_engine.py
148 149 150 151 152 153 154 | |
add_sample(voltage)
¶
Feed one raw EEG voltage sample.
Source code in src/sc_neurocore/audio/evs_engine.py
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | |
set_target(hz)
¶
Set the entrainment target frequency.
Source code in src/sc_neurocore/audio/evs_engine.py
186 187 188 | |
compute()
¶
Compute current EVS snapshot.
Returns None if insufficient data or baseline not done.
Source code in src/sc_neurocore/audio/evs_engine.py
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 | |
reset()
¶
Full reset.
Source code in src/sc_neurocore/audio/evs_engine.py
319 320 321 322 323 324 325 326 327 328 329 | |
SSGF Engine¶
sc_neurocore.audio.ssgf_engine
¶
SSGFConfig
dataclass
¶
All tuneable knobs for SSGFEngine.
Source code in src/sc_neurocore/audio/ssgf_engine.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
SSGFEngine
¶
Lightweight SSGF geometry-coupled Kuramoto solver.
Maintains a latent vector z whose decoded geometry matrix W(t) feeds back into the micro-cycle, steering oscillators toward higher global coherence R. Audio-mapping observables are derived from the resulting phase dynamics and spectral properties of W.
Source code in src/sc_neurocore/audio/ssgf_engine.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 | |
outer_step()
¶
One outer-cycle step: micro-cycle -> spectral -> grad update on z.
Returns the cost after the step.
Source code in src/sc_neurocore/audio/ssgf_engine.py
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | |
get_audio_mapping()
¶
Derive CCW audio parameters from current SSGF state.
Returns¶
dict with keys: binaural_hz -- 0.5-40 Hz (from layer-2 phase velocity) pulse_rate -- isochronic pulse rate (layer-4 coherence) spatial_angle -- 0-360 degrees (layer-7 phase) intensity -- 0-1 (from R_global) fiedler -- algebraic connectivity of W spectral_gap -- lambda_1 / lambda_2 theurgic_mode -- bool, True when R > 0.95
Source code in src/sc_neurocore/audio/ssgf_engine.py
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | |
get_state()
¶
Full engine state snapshot.
Source code in src/sc_neurocore/audio/ssgf_engine.py
281 282 283 284 285 286 287 288 289 290 291 292 293 | |
User Profile¶
sc_neurocore.audio.user_profile
¶
User profile: chronotype and session preferences.
Chronotype
¶
Bases: str, Enum
Sleep chronotype model (after Dr. Michael Breus).
Each chronotype has a preferred entrainment frequency range and optimal session timing.
Source code in src/sc_neurocore/audio/user_profile.py
22 23 24 25 26 27 28 29 30 31 32 | |
UserProfile
dataclass
¶
Per-user preference and adaptation model.
Parameters¶
user_id : str Unique user identifier. chronotype : Chronotype Sleep chronotype. baseline_band_powers : dict Resting-state EEG band powers (populated after first baseline). preferred_cost_weights : dict SSGF cost weights tuned to this user. sensitivity_map : dict Per-band sensitivity multipliers (e.g. {"alpha": 1.2}). session_count : int Total completed sessions. preferred_target_hz : float, optional Explicitly set target frequency (overrides chronotype default).
Source code in src/sc_neurocore/audio/user_profile.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | |
get_best_target_hz()
¶
Return the best entrainment target for this user.
Uses explicit preference if set, otherwise chronotype default.
Source code in src/sc_neurocore/audio/user_profile.py
118 119 120 121 122 123 124 125 | |
update_from_session(avg_evs, peak_evs, best_target_hz=None, band_powers=None)
¶
Update profile after a completed session.
Parameters¶
avg_evs : float Average EVS score over the session. peak_evs : float Peak EVS score. best_target_hz : float, optional If the adaptive engine found a better target, adopt it. band_powers : dict, optional Updated baseline band powers from this session.
Source code in src/sc_neurocore/audio/user_profile.py
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | |