Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Ebmtranceboy
    @Ebmtranceboy
    @pelagisk you can get what you want by
    snare = at (hp 1000 10) . at (chorus 0.1 0.2 0.1) $ mul (adsr 0.01 0.4 0 0) pink
    Axel
    @pelagisk
    @Ebmtranceboy very clear, thanks!
    Ebmtranceboy
    @Ebmtranceboy
    Furthermore Sig2 type is just an alias of (Sig,Sig).
    Axel
    @pelagisk
    ah so I just fmap fst for mono?
    Anton Kholomiov
    @anton-k
    There is a function
    toMono :: Sig2 -> Sig
    fromMono :: Sig -> Sig2
    Axel
    @pelagisk
    better, thanks
    Axel
    @pelagisk

    what is the best way to combine scores and playback of samples? My current approach is:

    clap :: D -> SE Sig2
    clap _ = runSam bpm $ wav1 "clap.wav"
    
    mkpattern :: [Int] -> Sco D
    mkpattern lst = mel $ map (\i -> if i == 0 then rest 1 else temp (double 1.0)) lst
    
    clapp :: Sco (Mix Sig2)
    clapp = sco clap $ mkpattern [0,0,1,0,0,0,1,1]
    
    -- then run `dac $ mix clapp`

    but I would ideally like to work with samples like with Csound.Sam like I can do with scores? Maybe there is a good way scores and samples are separated in this way?

    Ebmtranceboy
    @Ebmtranceboy
    maybe you can try pat' ?
    dac $ loop $ mel [lim 8 $ pat' [1, 0.5, 0.25, 0.1] [1] (wav1 "../sample/kick1.wav"), rest 8]
    Axel
    @pelagisk

    the problem is that pat' has signature

    pat'  :: [Csound.Typed.Types.Prim.D]  -> [Csound.Typed.Types.Prim.D] -> Sam -> Sam

    and that I want it to work with type Scosomehow

    Ebmtranceboy
    @Ebmtranceboy
    He will confirm but Anton is not very pleased with Sco as it is atm. Maybe schedu le some events ?
    Anton Kholomiov
    @anton-k
    @pelagisk In theory you can render Scores to signal (mix . sco) and then pack it to sample (toSam | limSam)
    Though I guess that the function like scaling wouldn't work across the rendered scores..
    Anton Kholomiov
    @anton-k
    Actually in your example you can read the sample with plain function like:
    readSnd :: String -> (Sig, Sig)
    
    clap :: D -> SE Sig2
    clap _ = return $ readSnd "clap.wav"
    or there are some wariants that rescale with bpm

    like this one:

    loopRam, readRam :: Fidelity -> TempoSig -> PitchSig -> String -> Sig2

    though they expose a bit more params than wav1

    Axel
    @pelagisk
    That is slightly better, thanks!
    Vladislav Sabanov
    @willbasky
    Hi all!
    i try the library.
    And there are some quistions.

    dac $ testDrone $ cpspch 4.02 works. There is sound.
    ticks doesn`t work, no sound. And no error:

    dac $ nticks [3,2,3] 135
    0dBFS level = 32768.0
    --Csound version 6.10 (double samples) 2018-01-27 
    [commit: none]
    libsndfile-1.0.28
    UnifiedCSD:  tmp.csd
    STARTING FILE
    Creating options
    Creating orchestra
    closing tag
    Creating score
    rtaudio: ALSA module enabled
    rtmidi: ALSA Raw MIDI module enabled
    
    csound command: Segmentation fault
    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.253s, CPU: 0.002s

    What should i do to hear sound from ticks?

    ticks or nticks doesn`t matter. And some other functions behave like that.
    Vladislav Sabanov
    @willbasky
    And where has library Csound.Patch moved?
    Vladislav Sabanov
    @willbasky
    there is no sound here also:
    dac $ repeatSnd 3 $ leg 1 2 0 0 * osc 220
    0dBFS level = 32768.0
    --Csound version 6.10 (double samples) 2018-01-27 
    [commit: none]
    libsndfile-1.0.28
    UnifiedCSD:  tmp.csd
    STARTING FILE
    Creating options
    Creating orchestra
    closing tag
    Creating score
    rtaudio: ALSA module enabled
    rtmidi: ALSA Raw MIDI module enabled
    
    csound command: Segmentation fault
    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.252s, CPU: 0.002s
    Anton Kholomiov
    @anton-k

    Hi, Vladislav! Sorry for late reply I was away in the mountains, no computers available.

    I've tried nticks and it works for me. I guess that problem is with version of Csound compiler that you use.
    The code indicates: csound command: Segmentation fault

    I'm using:

    --Csound version 6.10 (double samples) Dec 18 2017
    [commit: 63b19f63a8d41005747f5d41fef3d82f23bf1d3c]

    right now and all your code snippets work with it

    If you compile Csound from sources it's better to compile from master branch,
    not develop

    The module Csound.Patch is a part of the library csound-catalog
    so if we install only csound-expression this module is not available for us.

    I guess you can try to update cabal source list and install csound-catalog:

    cabal update
    cabal install csound-catalog
    O'Brien
    @Frequent-Clicker
    Hi Anton, would you still recommend the learning resources you linked to from your GitHub for a complete beginner? thanks!
    Anton Kholomiov
    @anton-k
    Hi! What resources do you mean?
    O'Brien
    @Frequent-Clicker
    In your readme file it contained links labeled things like "introduction" I assumed these were helping resources?
    csound knowledge is not mandatory but it often help, there are many parallels
    fbous
    @fbous

    Hi Anton! Thanks for the awesome library. It is exactly what I was looking for for my new project. (I'm reading osc-data generated from cell-phone sensors to drive synthesizers and produce different sounds.) I particularly appreciate the tutorial, which really is a good introduction and shows how simple it is to generate complex sound with just a few lines.

    I was wondering, is there a way to use external audio sources (in particular microphones)? I've seen something in Csound.Options about PulseAudio, Jack, adc etc., but it is not clear to me how this can be used to actually get a Sig type for further processing. Idealy I am looking for something like

    getInp :: SE Sig
    effect :: Sig -> SE Sig
    
    main = dac $ getInp >>= effect

    where getInp provides the microphone input and effect is the function that I want to apply to the microphone input.
    Currently I'm running the whole thing on a Debian with Pulse Audio, but Jack is an option.

    Anton Kholomiov
    @anton-k
    You can use it like this:
    main = dac effect
    dac also accepts functions SigN -> SigM or SigN -> SE SigM. It will pass all needed flags to read the input. Be sure to match the number of inputs of your card. For example if you have 2x2 card. You should pass to dac Sig2 -> SE Sig2 and use only channel that you want.
    fbous
    @fbous

    Simple and yet so powerful! It worked almost instantly. Thanks for the quick reply.

    It's worth mentioning (for anyone else reading this) that the input may have to be scaled down by a lot (like 2 ** 8). For me the code

    main = dac $ ((\mic -> mic) :: Sig2 -> Sig2)

    generated only noise, while

    main = dac $ ((\mic -> mul (2 ** (-8)) mic) :: Sig2 -> Sig2)

    successfully created a loop back.

    Anton Kholomiov
    @anton-k
    Good to know! Scaling factor is often controled with the input gain. Maybe huge one like this stems from digits format mismatch. Like your card is sending in +-32k and Csound expcts it to be [-1, 1]
    Paul Chiusano
    @pchiusano
    Hi @anton-k I am trying to pick up csound again (I gave a talk at Boston Haskell a few years ago on it - https://gist.github.com/pchiusano/25c6a595d5ad7b0888f0) but having some trouble with basic setup, maybe you can help - dac $ osc 440 gives me the following -
    λ> dac $ osc 440
    0dBFS level = 32768.0
    --Csound version 6.15 (double samples) Oct 23 2020
    [commit: 18c2c7897425f462b9a7743cee157cb410c88198]
    libsndfile-1.0.30
    UnifiedCSD:  tmp.csd
    STARTING FILE
    Creating options
    Creating orchestra
    closing tag
    Creating score
    rtaudio: PortAudio module enabled ...
    using callback interface
    rtmidi: PortMIDI module enabled
    Elapsed time at end of orchestra compile: real: 0.002s, CPU: 0.002s
    sorting score ...
        ... done
    Elapsed time at end of score sort: real: 0.002s, CPU: 0.002s
    displays suppressed
    0dBFS level = 1.0
    orch now loaded
    audio buffered in 1024 sample-frame blocks
    reading 2048-byte blks of shorts from adc (RAW)
    PortAudio V19.6.0-devel, revision 396fe4b6699ae929d3a685b3ef8a7e97396139a4
       0: adc0 (MacBook Air Microphone [Core Audio])
    PortAudio: selected input device 'MacBook Air Microphone'
       0: dac0 (MacBook Air Speakers [Core Audio])
    PortAudio: selected output device 'MacBook Air Speakers'
     *** PortAudio: error: -9998: Invalid number of channels
    closing device
    Failed to initialise real time audio output
    inactive allocs returned to freespace
    end of score.           overall amps:  0.00000
           overall samples out of range:        0
    1 errors in performance
    Elapsed time at end of performance: real: 0.021s, CPU: 0.009s
    closing device
    λ>
    I'm not sure what's causing the PortAudio Invalid number of channels error, any ideas?
    Anton Kholomiov
    @anton-k

    Hi, Paul (@pchiusano)! Nice to hear from you again!

    I don't have this issue. But I suspect that something can be wrong with PortAudio expectation of number of channels. Maybe it expects strictly stereo with your settings?

    Can you try out to convert to stereo to feed both channels:

    dac $ fromMono $ osc 440

    Both examples work for me.

    Paul Chiusano
    @pchiusano
    @anton-k same issue with dac $ fromMono $ osc 440
    Here's full output -
    λ> dac $ fromMono $ osc 440
    0dBFS level = 32768.0
    --Csound version 6.15 (double samples) Oct 23 2020
    [commit: 18c2c7897425f462b9a7743cee157cb410c88198]
    libsndfile-1.0.30
    UnifiedCSD:  tmp.csd
    STARTING FILE
    Creating options
    Creating orchestra
    closing tag
    Creating score
    rtaudio: PortAudio module enabled ...
    using callback interface
    rtmidi: PortMIDI module enabled
    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
    displays suppressed
    0dBFS level = 1.0
    orch now loaded
    audio buffered in 1024 sample-frame blocks
    reading 4096-byte blks of shorts from adc (RAW)
    PortAudio V19.6.0-devel, revision 396fe4b6699ae929d3a685b3ef8a7e97396139a4
       0: adc0 (MacBook Air Microphone [Core Audio])
    PortAudio: selected input device 'MacBook Air Microphone'
       0: dac0 (MacBook Air Speakers [Core Audio])
    PortAudio: selected output device 'MacBook Air Speakers'
     *** PortAudio: error: -9998: Invalid number of channels
    closing device
    Failed to initialise real time audio output
    inactive allocs returned to freespace
    end of score.           overall amps:  0.00000  0.00000
           overall samples out of range:        0        0
    1 errors in performance
    Elapsed time at end of performance: real: 0.027s, CPU: 0.013s
    closing device
    Paul Chiusano
    @pchiusano
    If I remove the --input=adc from the generated tmp.csd file, it works
    <CsOptions>
    
    --nodisplays --output=dac --input=adc
    
    </CsOptions>
    Paul Chiusano
    @pchiusano

    It looks like my microphone is only 1 channel input but the generated file is requesting two channels? If I change the invocation of csound to csound -+rtaudio="CoreAudio" --nchnls_i=1 tmp.csd then it works. Without the --nchnls_i=1 I get:

    1: MacBook Air Microphone (1 channels)
     *** CoreAudio: Device has not enough inputs (1, requested 2)

    It also doesn't work without the -+rtaudio="CoreAudio".

    @anton-k Now that I have something working, is there some way I can get csound-expression to supply different options to csound when I call dac ?
    ah, dacBy seems like it will work
    Anton Kholomiov
    @anton-k

    Ok, I glad that it wokrs now.
    Also there is helpful function if you want to redefine the global options once and forall

    https://hackage.haskell.org/package/csound-expression-5.3.3/docs/Csound-IO.html#v:saveUserOptions

    saveUserOptions :: Options -> IO ()
    it saves the options in the current directory and in the user's home it can behave like global .rc fro csound compiler so that you don't need to repeat same specs in the dacBy
    Paul Chiusano
    @pchiusano
    cool
    Anton Kholomiov
    @anton-k
    @pchiusano Hi, I've updated CE so that it does not include -adc flag if user does not want to use inputs.
    with it it should run without the need for specific flags in your case.
    Paul Chiusano
    @pchiusano
    Thanks @anton-k will try it out