byulparan / cl-collider

A SuperCollider client for CommonLisp
Other
218 stars 23 forks source link

sound-in.ar not working #126

Closed Elvis-Budingensis closed 1 year ago

Elvis-Budingensis commented 1 year ago

Hello there, it seems that sound-in.ar isn't getting input at all. I am working on macos 13.2.1 with an M1 chip. I have the recent cl-collider and SBCL 2.3.2 installed. I don't have that problem in Supercollider, so it is cl-collider related.

tentaclius commented 1 year ago

It is very unlikely this has something to do with cl-collider. It is just a front end. If the unit generator has been created and the bus number is correct it should work. Can you show the problematic code snippet?

Elvis-Budingensis commented 1 year ago

Anton,

thank you very much. This is the supposed code:

This is my CL-code:

(defparameter buf (buffer-alloc (* 4 48000) :chanls 1 :bufnum 0))

(defsynth rec-plays ((buffer 0) (rate 1) (start 0) (amp 0.5) (out 0) (loop 1)) (let ((sig (sound-in.ar 0)) (rc (record-buf.ar sig buffer)) (sig1 (play-buf.ar 1 buffer ( rate (buf-rate-scale.ir buffer)) :start-pos ( start (buf-frames.ir buffer)) :loop loop :act :free))) (out.ar out ( amp sig1))))

(synth 'rec-plays)

(play (sound-in.ar 0))

(synth 'rec-plays)

Thanks, Daniel

Am 16.03.2023 um 20:11 schrieb Anton Erdman @.***>:

It is very unlikely this has something to do with cl-collider. It is just a front end. If the unit generator has been created and the bus number is correct it should work. Can you show the problematic code snippet?

— Reply to this email directly, view it on GitHub https://github.com/byulparan/cl-collider/issues/126#issuecomment-1472601311, or unsubscribe https://github.com/notifications/unsubscribe-auth/AONO7SELTOP3WXMZPFOQQO3W4NQU7ANCNFSM6AAAAAAV5REB3Q. You are receiving this because you authored the thread.

tentaclius commented 1 year ago

In my case your code does not produce any sound if grouped in one synth, however if I separate the recorder and player, it works as I would expect:

(defsynth rec-record ((buffer 0))
  (record-buf.ar (sound-in.ar 0) buffer))

(synth 'rec-record :buffer *buf*)

(defsynth rec-play ((buffer 0) (rate 1) (start 0) (amp 0.5) (out 0) (loop 1))
  (out.ar out (* amp (play-buf.ar 1 buffer (* rate (buf-rate-scale.ir buffer))
                                  :start-pos (* start (buf-frames.ir buffer))
                                  :loop loop
                                  :act :free))))

(synth 'rec-play :amp 2 :buffer *buf*)

But if I understand correctly, in your case even simpler examples, like (play (sound-in.ar 0)) doesn't work, is that correct?

I assume you already checked, but still, just to be sure... the system does produce sound, right, e.g. (play (pan2.ar (saw.ar)))?

Maybe it is worth checking other input bus numbers. If I remember correctly sound-in.ar is just a helper for in.ar, perhaps on your hardware it didn't get the correct bus offset. Can you try different bus numbers with (play (in.ar <n> 2)), where <n> is somewhere between 0 and 16 (8 in my case)?

Elvis-Budingensis commented 1 year ago

Hi,

on my system you code doesn’t work, too. I can do anything with cl-collider, but recording. The MacBook mic is number 5 in my case. I tried all numbers from 0 to 16, too.

Number of Devices: 8 0 : "LG ULTRAFINE" 1 : "Mikrofon von „iPhon" 2 : "BlackHole 16ch" 3 : "BlackHole 2ch" 4 : "BlackHole 64ch" 5 : "MacBook Pro-Mikrofon" 6 : "MacBook Pro-Lautsprecher" 7 : "ZoomAudioD"

"MacBook Pro-Mikrofon" Input Device Streams: 1 0 channels 1

"MacBook Pro-Lautsprecher" Output Device Streams: 1 0 channels 2

SC_AudioDriver: sample rate = 48000.000000, driver's block size = 512 SuperCollider 3 server ready. PublishPortToRendezvous 0 637

All the best, Daniel

Am 17.03.2023 um 11:55 schrieb Anton Erdman @.***>:

(defsynth rec-record ((buffer 0)) (record-buf.ar http://record-buf.ar/ (sound-in.ar http://sound-in.ar/ 0) buffer))

(synth 'rec-record :buffer buf)

(defsynth rec-play ((buffer 0) (rate 1) (start 0) (amp 0.5) (out 0) (loop 1)) (out.ar http://out.ar/ out ( amp (play-buf.ar http://play-buf.ar/ 1 buffer ( rate (buf-rate-scale.ir http://buf-rate-scale.ir/ buffer)) :start-pos (* start (buf-frames.ir http://buf-frames.ir/ buffer)) :loop loop :act :free))))

(synth 'rec-play :amp 2 :buffer buf)

byulparan commented 1 year ago

Set your system input to Macbook Mic and bootup server. doesn't works?

(play
 (pan2.ar (sound-in.ar 0)))

if not... run this test code. how about it?

(add-reply-responder
 "/test-hardware"
 (lambda (node id in out)
   (declare (ignore node id))
   (format t "num-of-input: ~d / num-of-output: ~d~%" in out)))

(play
 (send-reply.kr 1 "/test-hardware" (list (num-input-buses.ir) (num-output-buses.ir)) ))

currently I don't have M1 Mac, next week I will test it on m1 mac.

Elvis-Budingensis commented 1 year ago

Thanks. No it doesn’t work, I think it could be M1-related.

All the best, Daniel

Am 17.03.2023 um 12:28 schrieb SungminPark @.***>:

Set your system input to Macbook Mic and bootup server. doesn't works?

(play (pan2.ar (sound-in.ar 0))) currently I don't have M1 Mac, next week I will test it on m1 mac.

— Reply to this email directly, view it on GitHub https://github.com/byulparan/cl-collider/issues/126#issuecomment-1473692607, or unsubscribe https://github.com/notifications/unsubscribe-auth/AONO7SFYDRR3AIRO4IHPMW3W4RDEPANCNFSM6AAAAAAV5REB3Q. You are receiving this because you authored the thread.

Elvis-Budingensis commented 1 year ago

Also tested on my Intel-Mac using 13.2.1 (22D68). Wouldn’t work either!

Am 17.03.2023 um 11:55 schrieb Anton Erdman @.***>:

In my case your code does not produce any sound if grouped in one synth, however if I separate the recorder and player, it works as I would expect:

(defsynth rec-record ((buffer 0)) (record-buf.ar (sound-in.ar 0) buffer))

(synth 'rec-record :buffer buf)

(defsynth rec-play ((buffer 0) (rate 1) (start 0) (amp 0.5) (out 0) (loop 1)) (out.ar out ( amp (play-buf.ar 1 buffer ( rate (buf-rate-scale.ir buffer)) :start-pos (* start (buf-frames.ir buffer)) :loop loop :act :free))))

(synth 'rec-play :amp 2 :buffer buf) But if I understand correctly, in your case even simpler examples, like (play (sound-in.ar 0)) doesn't work, is that correct?

I assume you already checked, but still, just to be sure... the system does produce sound, right, e.g. (play (pan2.ar (saw.ar)))?

Maybe it is worth checking other input bus numbers. If I remember correctly sound-in.ar is just a helper for in.ar, perhaps on your hardware it didn't get the correct bus offset. Can you try different bus numbers with (play (in.ar 2)), where is somewhere between 0 and 16 (8 in my case)?

— Reply to this email directly, view it on GitHub https://github.com/byulparan/cl-collider/issues/126#issuecomment-1473654121, or unsubscribe https://github.com/notifications/unsubscribe-auth/AONO7SBNVMIMPFZ7MMYGLW3W4Q7JFANCNFSM6AAAAAAV5REB3Q. You are receiving this because you authored the thread.

Elvis-Budingensis commented 1 year ago

Also tested on my Intel-Mac using 13.2.1 (22D68). Wouldn’t work either!

Am 17.03.2023 um 12:28 schrieb SungminPark @.***>:

Set your system input to Macbook Mic and bootup server. doesn't works?

(play (pan2.ar (sound-in.ar 0))) currently I don't have M1 Mac, next week I will test it on m1 mac.

— Reply to this email directly, view it on GitHub https://github.com/byulparan/cl-collider/issues/126#issuecomment-1473692607, or unsubscribe https://github.com/notifications/unsubscribe-auth/AONO7SFYDRR3AIRO4IHPMW3W4RDEPANCNFSM6AAAAAAV5REB3Q. You are receiving this because you authored the thread.

ntrocado commented 1 year ago

try this:

(in-package :sc-user)

(play (let ((inputs (alexandria:iota 8))) ; for 8 input buses
    (poll.kr (impulse.kr 1)
         (amplitude.ar (sound-in.ar inputs))
         inputs)))

is there any non-zero value showing up?

Elvis-Budingensis commented 1 year ago

Hi,

unfortunately not:

Number of Devices: 8 0 : "LG ULTRAFINE" 1 : "Mikrofon von „iPhon" 2 : "BlackHole 16ch" 3 : "BlackHole 2ch" 4 : "BlackHole 64ch" 5 : "MacBook Pro-Mikrofon" 6 : "MacBook Pro-Lautsprecher" 7 : "ZoomAudioD"

"MacBook Pro-Mikrofon" Input Device Streams: 1 0 channels 1

"MacBook Pro-Lautsprecher" Output Device Streams: 1 0 channels 2

SC_AudioDriver: sample rate = 48000.000000, driver's block size = 512 SuperCollider 3 server ready.

0: 0 1: 0 2: 0 3: 0 4: 0 5: 0 6: 0 7: 0 0: 0 1: 0 2: 0 3: 0 4: 0 5: 0 6: 0 7: 0 0: 0

etc.

All the best, Daniel

Am 17.03.2023 um 21:41 schrieb Nuno Trocado @.***>:

(in-package :sc-user)

(play (let ((inputs (alexandria:iota 8))) ; for 8 input buses (poll.kr http://poll.kr/ (impulse.kr http://impulse.kr/ 1) (amplitude.ar http://amplitude.ar/ (sound-in.ar http://sound-in.ar/ inputs)) inputs)))

byulparan commented 1 year ago

hmm. I test in M1 mac, It's work well and All works in my machine(Intel Mac, M1 Mac, Window, Linux..)

; SLIME 2.28To load "cl-collider":
  Load 1 ASDF system:
    cl-collider
; Loading "cl-collider"
.................
Found 0 LADSPA plugins
Number of Devices: 5
   0 : "byulparan's iPhone SE2 마"
   1 : "외장 "
   2 : "외장 "
   3 : "MacBook Air 마"
   4 : "MacBook Air 스"

"MacBook Air 마" Input Device
   Streams: 1
      0  channels 1

"외장 " Output Device
   Streams: 1
      0  channels 2

SC_AudioDriver: sample rate = 44100.000000, driver's block size = 512
SuperCollider 3 server ready.
PublishPortToRendezvous 0 24800
(ql:quickload '(:cl-collider))
(in-package :sc-user)
(named-readtables:in-readtable :sc)

(setf *s* (make-external-server "localhost" :port 57440))
(server-boot *s*)

(play
 (pan2.ar (sound-in.ar 0)))
byulparan commented 1 year ago

cl-collider is just front-end of scsynth. run scsynth on external process and communication it via OSC. so I don't know what's problem.

Please test.

  1. run scsynth in Terminal: /Application/SuperCollider.app/Contents/Resources/scsynth -u 57140
  2. cl-collider run and just-connect it.
    
    (ql:quickload '(:cl-collider))
    (in-package :sc-user)
    (named-readtables:in-readtable :sc)

(setf s (make-external-server "localhost" :port 57140 :just-connect-p t)) (server-boot s)

(play (pan2.ar (sound-in.ar 0)))

Elvis-Budingensis commented 1 year ago

That worked! Thank you!

I don’t know, why it only works like this, as it perfectly worked in Supercollider.

All the best, Daniel

Am 19.03.2023 um 12:16 schrieb SungminPark @.***>:

cl-collider is just front-end of scsynth. run scsynth on external process and communication it via OSC. so I don't know what's problem.

Please test.

run scsynth in Terminal: /Application/SuperCollider.app/Contents/Resources/scsynth -u 57140 cl-collider run and just-connect it. (ql:quickload '(:cl-collider)) (in-package :sc-user) (named-readtables:in-readtable :sc)

(setf s (make-external-server "localhost" :port 57140 :just-connect-p t)) (server-boot s)

(play (pan2.ar (sound-in.ar 0))) — Reply to this email directly, view it on GitHub https://github.com/byulparan/cl-collider/issues/126#issuecomment-1475215037, or unsubscribe https://github.com/notifications/unsubscribe-auth/AONO7SGCBXABONVGU5VRSMLW43TJ5ANCNFSM6AAAAAAV5REB3Q. You are receiving this because you authored the thread.

Elvis-Budingensis commented 1 year ago

Could be true. Thanks for your help, I really appreciate it!Am 19.03.2023 um 15:13 schrieb SungminPark @.***>: Ah.... It's maybe securiy problem on macOS. defaulty

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

byulparan commented 1 year ago

Ah!! It's seems security problem on macOS. Only authorized apps are allowed microphone and camera inputs in macOS. defaultly Emacs.app can't allow access Mic / Camera.

I always add permission to Emacs manually. This process is not simple. I edit Emacs.app/Contents/Info.plist and re code signing. One of the problems with MacOS is that users can't easily add this permission.

check it this thread. https://scsynth.org/t/emacs-scsynth-and-microphone-permissions/3253/10

Elvis-Budingensis commented 1 year ago

Thanks, Apple is making macOS useless step by step…

Am 19.03.2023 um 15:25 schrieb SungminPark @.***>:

Ah!! It's seems security problem on macOS. Only authorized apps are allowed microphone and camera inputs in macOS. defaultly Emacs.app can't allow access Mic / Camera.

I always add permission to Emacs manually. This process is not simple. I edit Emacs.app/Contents/Info.plist and re code signing. One of the problems with MacOS is that users can't easily add this permission.

check it this thread. https://scsynth.org/t/emacs-scsynth-and-microphone-permissions/3253/10

— Reply to this email directly, view it on GitHub https://github.com/byulparan/cl-collider/issues/126#issuecomment-1475275871, or unsubscribe https://github.com/notifications/unsubscribe-auth/AONO7SDXT52DNKX56L4CHE3W44JMNANCNFSM6AAAAAAV5REB3Q. You are receiving this because you authored the thread.