[Csnd] csound API clicks/cracks
Date | 2021-10-01 09:19 |
From | S=?UTF-8?Q?=C3=B8ren?= |
Subject | [Csnd] csound API clicks/cracks |
Perhaps someone can help me troubleshoot the following C# code? I am hearing some random clicks and cracks, not just at the beginning but usually also 1-3 times while the tone is playing. I guess .NET may be not be the best language for realtime processing, but I am actually experiencing similar problems with PureBasic (which is very low-level and C-like), and on other computers. using System; using System.Runtime.InteropServices; class Program { [DllImport(@"csound64.dll")] private static extern IntPtr csoundCreate(); [DllImport(@"csound64.dll")] private static extern long csoundSetOption(IntPtr csound, string option); [DllImport(@"csound64.dll")] private static extern long csoundCompileOrc(IntPtr csound, string option); [DllImport(@"csound64.dll")] private static extern void csoundStart(IntPtr csound); [DllImport(@"csound64.dll")] private static extern void csoundStop(IntPtr csound); [DllImport(@"csound64.dll")] private static extern long csoundPerformKsmps(IntPtr csound); [DllImport(@"csound64.dll")] private static extern long csoundReadScore(IntPtr csound, string option); static void Main(string[] args) { IntPtr csound = csoundCreate(); csoundSetOption(csound, "-odac0"); csoundSetOption(csound, "-b2048"); csoundSetOption(csound, "-B2048"); csoundCompileOrc(csound, @" sr=44100 ksmps=10 nchnls=2 0dbfs=1 ga init 1 instr 1 ga poscil 0.5, 400 outs ga, ga endin "); csoundReadScore(csound, "i 1 0 5"); csoundStart(csound); while (csoundPerformKsmps(csound) == 0) ; csoundStop(csound); } } Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here |
Date | 2021-10-01 10:26 |
From | Victor Lazzarini |
Subject | Re: [Csnd] [EXTERNAL] [Csnd] csound API clicks/cracks |
Might not be related, but why are you using a global variable in the instrument? I presumed you tested this code in your computer just using the csound command (or another frontend) and you are not getting the same problems. It could be related to -b and -B. Try just using -b, you can see if it works then you can try lowering it to -b 128 or something like that. I assume portaudio can use the better drivers, but make sure you are not using the legacy sound libraries (MME) by not selecting that output but something else. What you are describing sounds like dropouts which are probably caused by the buffering not doing the job correctly. The language does not really matter in this case because you are just using it to run the engine, which is a binary library. ======================== Prof. Victor Lazzarini Maynooth University Ireland > On 1 Oct 2021, at 09:19, Søren |
Date | 2021-10-01 11:53 |
From | Rory Walsh |
Subject | Re: [Csnd] [EXTERNAL] [Csnd] csound API clicks/cracks |
You can also try increasing ksmps to something higher than 10, and power of 2 is preferable. On Fri, 1 Oct 2021 at 10:26, Victor Lazzarini <Victor.Lazzarini@mu.ie> wrote: Might not be related, but why are you using a global variable in the instrument? |
Date | 2021-10-01 13:42 |
From | Søren Jakobsen |
Subject | Re: [Csnd] [EXTERNAL] [Csnd] csound API clicks/cracks |
Thanks for the help! If I remove the -B option I can not get good latency without ASIO, but it does indeed seem to help now. I thought .NET might sometimes delay the thread so that csoundPerformKsmps would not be called in time, but I guess there is no problem with that then. The global variable was a 'typo'. On Fri, 1 Oct 2021 at 13:53, Rory Walsh <rorywalsh@ear.ie> wrote:
|