csound_max
csound_max copied to clipboard
help file csd sample rate does not match default in Max
Hi Iain,
Even though I have csound6 installed on my mac (Catalina), I'm unable to load the csound6 external with errors:
First my csound version:
$ csound --version
0dBFS level = 32768.0
--Csound version 6.16 (double samples) Jul 17 2021
[commit: fb5bdb3681e15f56c216b4e4487b45848aa6b9f4]
libsndfile-1.0.28
end of score. overall amps: 0.0
overall samples out of range: 0
0 errors in performance
Elapsed time at end of performance: real: 0.000s, CPU: 0.000s
Now when I try to open the .maxhelp file:
csound6~ 1.01 - A Max Csound class using the Csound 6.16.2 API
(c) Iain C.T. Duncan, 2022.
Based on work for Pd by Victor Lazzarini, 2005-2007.
csound6_init_csound()
compiling csd: cs-help.csd
full path: /Volumes/$HOME/Documents/Max 8/Packages/Csound6~/help/cs-help.csd
WARNING:
could not open library '/Library/Frameworks/CsoundLib64.framework/Versions/6.0/Resources/Opcodes64/libfluidOpcodes.dylib' (-1)
WARNING: could not open library '/Library/Frameworks/CsoundLib64.framework/Versions/6.0/Resources/Opcodes64/libvirtual.dylib' (-1)
WARNING: could not open library '/Library/Frameworks/CsoundLib64.framework/Versions/6.0/Resources/Opcodes64/librtjack.dylib' (-1
UnifiedCSD: /Volumes/VOLE/Users/sa/Documents/Max 8/Packages/Csound6~/help/cs-help.csd
STARTING FILE
Creating orchestra
closing tag
Creating score
rtaudio: PortAudio module enabled ...
using callback interface
rtmidi: PortMIDI module enabled
instr square uses instrument number 5
instr pulse uses instrument number 6
instr lfo uses instrument number 7
instr make_lfo uses instrument number 8
instr outvalue_instr uses instrument number 9
Elapsed time at end of orchestra compile: real: 0.003s, CPU: 0.003s
sorting score ...
... done
Elapsed time at end of score sort: real: 0.003s, CPU: 0.003s
graphics suppressed, ascii substituted
0dBFS level = 0.9
ftable 1:
ftable 1: 16384 points, scalemax 1.000
____________________
_ '
_ '
_ '
_ '
_ '
_ '
_ '
_ '
_ '
_______________________________________'________________________________________
' _
' _
' _
' _
' _
' _
' _
' _
' _
'_____________________
orch now loaded
audio buffered in 1024 sample-frame blocks
SECTION 1:
initialization complete
When I try to start the external, I get the following error:
csound6~ error: csound sr must match Max
Hi, I should improve that error message so it's more clear. It's telling you that the csound sr setting in your CSD needs to match the sample rate of Max in your audio preferences. If this is indeed already the case, I probably have a bug. Can you try explictly setting sr in the CSD header to whatever sample rate you have Max set to and let me know if that works?
Thanks for your help. It was indeed a mismatch between sampling rates (max had 48000 and the cs-help.csd had 44100).
I don't typically change my sampling rate so I assume that 48000 is Max's default. If it is, then it may be worthwhile having the same setting in the help csd.
In any case, very cool.
Thanks!
Good suggestion. I should also look into whether there is a way to have that sample rate left out and set by default to Max's. I'm glad you got it working!
I also was thinking that Sample rate mismatches or KSMPS (vector size) mistmatches could be automatically handled by the object itself. For example, if ksmps is not an even divisor of Max vector size, it could be automatically set to the same. Or an attribute of the object could be "automatch". It would be super helpful when giving patches to someone else who does not know Csound and only wants to have fun without having to configure everything.
hmm, that's a good point. I will think about that when I get back to this in the fall. I'm taking a wee break between defending my thesis and starting the PhD but future development is planned
Thanks ! if I find sometime I'll try to contribute if you agree with the feature.
I think it should be opt in as it could confuse knowledgeable Csound users if ksmps changes and they don't know why. But it would be nice if one could use an attribute to automatically set sr to sample rate and ksmps to max vector size. perhaps we could have an attribute @ksmps with an option for auto? (I actually have no idea whether the Max SDK makes it easy to find the vector size mind you)
I agree, a @ksmps attribute that could be set to auto (same as max) or any value (override csound's ksmps then), or not set (take csound ksmps then). It could be same for @sr if you agree. I'm pretty sure Max SDK allows to retrieve such information.
I think that would be good, and not affect normal use. If you want I can add you as a contributor so you can make a branch. I would welcome new contributors to this! There is also, in case anyone is interested, more that could be ported from the Lazarinni Pd object from which I copied a lot of this (I simplified it, and did not yet add the midi stuff)
I may start with a fork of your repository and add a branch on my fork, and then PR once it's done. I need to put my head in Max SDK first !
I have the attributes "autoksmps" and "autosr" working here locally. When set to 1, they set Csound ksmps or sr to Max (Sample rate and vector size). As for another feature, I added an attribute allowing to forward outvalue output to max named receive objects. I will try to make it clean soon and submit a PR.
Excellent, I look forward to checking it out, thanks!