Re: [CM] loading libc_s7.so

2022-04-13 Thread Tito Latini
Yes, it fails after

commit c049689884d733cae58bd3096391cb9e92a2d146
Author: Peter Hutterer 
Date:   Mon Jun 7 15:46:38 2021 +1000

logger: set linebuffering for the log

Set this once during setup so we don't have to remember to call fflush() 
after
each logging operation.


I think `setlinebuf(stderr)' is useless in
https://gitlab.freedesktop.org/pipewire/pipewire/-/blob/master/spa/plugins/support/logger.c#L378
if a logfile is not required.

A possible fix is

- setlinebuf(this->file);
+ if (this->file != stderr)
+ setlinebuf(this->file);

On Tue, Apr 12, 2022 at 12:36:10PM -0700, b...@ccrma.stanford.edu wrote:
> There has been a response to this issue (noticed in July):
> 
> https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/1409#note_1336015
> 
> (I hope I got that right -- issue 1409 at pipewire).
> 
> ___
> Cmdist mailing list
> Cmdist@ccrma.stanford.edu
> https://cm-mail.stanford.edu/mailman/listinfo/cmdist
___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist


Re: [CM] Installation problem version 22 (21.9?)

2021-12-20 Thread Tito Latini
> Motif is still available in Fedora and Debian,
> but I haven't looked at slackware in a very long time.

My distro is slackware 14.2 but motif is also present on
slackware64-current.

--with-gui doesn't work:

./configure --with-gui
[...]
graphics toolkit...: None

but --with-motif is ok:

./configure --with-motif
[...]
graphics toolkit...: Motif
___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist


Re: [CM] Sending code to the REPL from Emacs

2021-08-01 Thread Tito Latini
On Sat, Jul 31, 2021 at 10:52:19PM +, Brad Christensen wrote:
> Any Emacs users out there with working s7 REPL configs?
> 
> I quite like the idea of keeping certain code in an org file and sending code 
> to the REPL.
> [...]

I can share my Babel functions for Snd-Scheme Evaluation.
They are based on ob-lisp.el (GPL).

This message includes two attached files:

  - ob-snd-scheme.el
  - snd-scheme-example.org

Copy ob-snd-scheme.el to a directory in your load-path and update
the alist

  (org-babel-do-load-languages 'org-babel-load-languages
((snd-scheme . t) [...]))

in .emacs file (or require ob-snd-scheme) to enable the language.
See also [[info:org#Languages]]

Note: if the output is a sequence, it is corrupted if the length
is less than print-length.
;;; Babel Functions for Snd-Scheme Evaluation based on ob-lisp.el
;;; (GNU General Public License <https://www.gnu.org/licenses/>).
;;; Tito Latini 2018

;;; Note: if the output is a sequence, it is corrupted if the length
;;; is less than print-length.

(defun org-babel-expand-body:snd-scheme (body params)
  "Expand BODY according to PARAMS, return the expanded body."
  (let* ((vars (org-babel--get-vars params))
 (body (format "(let (%s)\n%s)"
   (mapconcat
 (lambda (var)
   (format "(%S (quote %S))" (car var) (cdr var)))
 vars "\n  ")
   body)))
(if (intersection '("code" "pp") (cdr (assq :result-params params))
  :test #'string=)
(format "(snd-print %s)" body)
body)))

(defun org-babel-execute:snd-scheme (body params)
  "Execute a block of Snd-Scheme code with Babel.
BODY is the contents of the block, as a string.  PARAMS is
a property list containing the parameters of the block."
  (org-babel-reassemble-table
(let ((result (with-temp-buffer
(insert (org-babel-expand-body:snd-scheme body params))
(let* ((str "")
   (comint-output-filter-functions
 (list (lambda (text) (setq str (concat str 
text)
   (proc (get-buffer-process (inf-snd-proc-buffer
  (comint-send-region proc (point-min) (point-max))
  (comint-send-string proc "\n")
  (accept-process-output proc)
  (subseq str 0 (position ?\n str :from-end t))
  (org-babel-result-cond (cdr (assq :result-params params))
result
(condition-case nil
(read (org-babel-snd-scheme-vector-to-list result))
  (error result
(org-babel-pick-name (cdr (assq :colname-names params))
 (cdr (assq :colnames params)))
(org-babel-pick-name (cdr (assq :rowname-names params))
 (cdr (assq :rownames params)

(defun org-babel-snd-scheme-vector-to-list (results)
  (replace-regexp-in-string "#\\(i\\|r\\)?(" "(" results))

(provide 'ob-snd-scheme)
#+name: tab
| 10 |
| 20 |
| 30 |
| 40 |
| 50 |

Start the inferior Snd-Scheme process if necessary:

[[elisp:run-snd-scheme]]

#+name: zoo
#+begin_src snd-scheme :var input=tab n=7
  (map (lambda (x) (list (* n (car x input)
#+end_src

#+RESULTS: zoo
|  70 |
| 140 |
| 210 |
| 280 |
| 350 |

#+name: seq-1
#+begin_src shell :var n=10
  seq $n
#+end_src

#+call: zoo(seq-1,3)

#+RESULTS:
|  3 |
|  6 |
|  9 |
| 12 |
| 15 |
| 18 |
| 21 |
| 24 |
| 27 |
| 30 |

The output is not correct if list length is 40 but ~print-length~ is 32:

#+call: zoo(seq-1(40))

#+RESULTS:
| (7) | (14) | (21) | (28) | (35) | (42) | (49) | (56) | (63) | (70) | (77) | 
(84) | (91) | (98) | (105) | (112) | (119) | (126) | (133) | (140) | (147) | 
(154) | (161) | (168) | (175) | (182) | (189) | (196) | (203) | (210) | (217) | 
(224) | ... |


A possible fix is ~(set! (print-length) 100)~ in Snd.

#+begin_src snd-scheme
  (set! (print-length) 100)
  (new-sound "new.snd" :size 96 :srate 48000)
  (clm-channel (make-oscil 880))
  (map list (channel->float-vector))
#+end_src

#+RESULTS:
|   0.0 |
|0.1149371504928666 |
|   0.22835087011065572 |
|   0.33873792024529137 |
|   0.44463517918492745 |
| 0.544639035015027 |
|0.6374239897486896 |
| 0.721760228098362 |
|0.7965299180241961 |
|0.8607420270039434 |
|0.9135454576426008 |
|0.9542403285162767 |
|0.9822872507286886 |
|0.9973144772244581 |
|0.9991228300988584 |
|0.9876883405951379 |
|0.9631625667976583 |
|0.9258705848099951 |
|0.8763066800438639 |
|0.8151277957285546 |
|0.7431448254773948 |
|0.6613118653236525 |
|0.5707135676844325 |
|0.4725507648690549 |
| 0.368124552684679 |
|   0.25881904510252185 |
|   0.14608302856241281 |

Re: [CM] loading libc_s7.so

2021-07-08 Thread Tito Latini
> I wonder who is messing with stderr -- pipewire?

Probably yes. I can reproduce the problem after the change of alsa
settings for pipewire:

# snd 21.5, alsa-lib-1.2.5.1
./configure --without-gui

# no pipewire
./snd
loading libc_s7.so
<1>

New settings in ~/.asoundrc for pipewire (compiled from git 20210703):

pcm.pipewire { type pipewire }
ctl.pipewire { type pipewire }
pcm.!default pcm.pipewire
ctl.!default pcm.pipewire

# The repl hangs with or without pipewire daemon; the new alsa
# settings seem the problem.
./snd
loading libc_s7.so
Ctrl-c
___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist


Re: [CM] Triggering incudine events with cm-incudine

2021-05-19 Thread Tito Latini
On Tue, May 18, 2021 at 03:48:45PM -0400, Brandon Hale wrote:
> Hello all,
> 
> I am trying to figure out with cm-incudine how to trigger incudine (dsp!)
> functions with common music (process) loops. I figure there is probably a
> way built into cm-incudine to do this. I could always send midi from an
> incudine midi output to an incudine midi input to trigger a (dsp!) function,
> but this feels clunky.

I patched the extension of CM five years ago with:

(defmethod write-event ((obj function) (str incudine-stream) scoretime)
  (declare (ignore str))
  (at (+ (rts-now) scoretime) obj)
  (values))

The side effect is the possibility to play the following example:

(in-package :scratch)

(dsp! girello (freq gain dur)
  (stereo (* (envelope (make-perc .5 .5) 1 dur #'free)
 (sine freq (db->linear gain)

(in-package :cm)

(defun harms (fund low high dur)
  (let ((f (hertz fund)))
(process for i from low to high
 output (lambda () (scratch::girello (* f (/ i low)) -9 dur))
 wait (+ dur .1

(rts)

;; realtime
(sprout (harms 'c3 4 16 .25))

;; write soundfile
(incudine:bounce-to-disk ("/tmp/harms-from-cm.wav" :pad 0)
  (sprout (harms 'c3 4 16 .25)))
___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist


Re: [CM] Receiving OSC in (cm:rts)

2021-04-06 Thread Tito Latini
On Mon, Apr 05, 2021 at 06:49:29PM +0200, Orm Finnendahl wrote:
> Am Montag, den 05. April 2021 um 07:59:35 Uhr (-0700) schrieb Iain Duncan:
> > FWIW, I'm definitely interested in hearing more about CM-incudine on here!
> > :-)
> 
> https://www.youtube.com/watch?v=VCO1uSf5jE4
> 
> Event scheduling and interactive control (visual and acoustic) was
> realized with cm-incudine (using multiple threads from a single CL
> instance to interface with QT, OpenCL, OpenGL and scsynth).

Congrats to you and the other artists. I particularly like the
sonorities and the effects after 10:20.

Masks and restrictions are also part of the whole suggestion but the
hidden scheduler in this case is managed by another anvil.
___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist


Re: [CM] Receiving OSC in (cm:rts)

2021-04-05 Thread Tito Latini
On Mon, Apr 05, 2021 at 10:31:24AM -0400, Brandon Hale wrote:
> I just got around to trying this out, and man, this is awesome! Being able
> to trigger common music events with the incudine responder is excellent.
> 
> For the responders, you would have to create a new responder for each event
> you would want for different osc messages, right?

Yes with MAKE-OSC-RESPONDER. The expansion is

(macroexpand-1 '(make-osc-responder *oscin* "/osc/test" "iii"
 (lambda (a b c)
   (msg warn "~D ~D ~D" a b c
;; (MAKE-RESPONDER *OSCIN*
;; (LAMBDA (#:S582)
;;   (WHEN (INCUDINE.OSC:CHECK-PATTERN #:S582 "/osc/test" "iii")
;; (INCUDINE.OSC:WITH-VALUES (A B C)
;; (#:S582 "iii")
;;   (MSG WARN "~D ~D ~D" A B C)))
;;   (VALUES)))

therefore it is also possible a single responder.

There is a tutorial about OSC in

/path/to/incudine/doc/tutorials/osc_messages.cudo   (lisp file)
/path/to/incudine/doc/html/tutorial_osc.html(html file)
http://incudine.sourceforge.net/tutorial_osc.html   (web)

I could add another example if something is not clear.
___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist


Re: [CM] Confused about subvectors

2021-03-17 Thread Tito Latini
On Tue, Mar 16, 2021 at 10:06:01PM -0700, Iain Duncan wrote:
> Hi folks, not sure if I can't read or what, I'm trying to make subvectors
> and I'm not getting at all what I'm expecting from the docs. I thought from
> the s7 docs that subvector should return a vector given (subvector vector
> start end), or (subvector vector start end dimensions)
> 
> If anyone can shed some light on this, that would be lovely.
> iain
> 
> Here's my repl output from using the s7 repl example
> 
> > (define v (vector 1 2 3 4))
> #(1 2 3 4)
> > v
> #(1 2 3 4)
> > (subvector v 0 2)
> #()
> > (subvector v 0 2 1)
> 
> ;subvector: too many arguments: (#(1 2 3 4) 0 2 1)
> 
> > (subvector v)
> 
> ;subvector: not enough arguments: (#(1 2 3 4))

It works here (tested with Snd 21.2 and s7 9.9):

(define v (vector 1 2 3 4))
; => #(1 2 3 4)

(subvector v 0 2)
; => #(1 2)

(subvector v 0 4 '(2 2))
; => #2d((1 2) (3 4))
___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist


Re: [CM] make-polyshape

2021-02-07 Thread Tito Latini
On Sat, Feb 06, 2021 at 06:51:07PM +, James Hearon wrote:
> [...]
> It rather seems to want the whole function call:
> (set! gen1 (make-polyshape 440.0 :coeffs (partials->polynomial '(1 1
> 
> or
> (set! gen1 (make-polyshape 440.0 :coeffs (partials->polynomial '(1 1 3 2 6 
> 1

Generally, it works with a float-vector, for example

#r(-1.0 -5.0 18.0 8.0 -48.0 0.0 32.0)

or

(float-vector -1.0 -5.0 18.0 8.0 -48.0 0.0 32.0)

The output of partials->polynomial is a float-vector:

(partials->polynomial '(1 1 3 2 6 1))
;; => #r(-1.0 -5.0 18.0 8.0 -48.0 0.0 32.0)
___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist


Re: [CM] Snd/CLM: experimental version of src and src-channel

2020-09-13 Thread Tito Latini
To all the persons: please don't try the patch because that change
requires pre-filtering of the input, therefore it is not a complete
resampler. Good Sunday.
___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist


Re: [CM] Snd/CLM: experimental version of src and src-channel

2020-09-11 Thread Tito Latini
Hey Bill, a copy-and-paste failed in svn. Attached a fix.
___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist


Re: [CM] Snd/CLM: experimental version of src and src-channel

2020-09-11 Thread Tito Latini
On Thu, Sep 10, 2020 at 11:06:01AM -0700, b...@ccrma.stanford.edu wrote:
> Thanks!  I see only a subtle difference -- do you have
> a (hopefully small) test case?  (Am I right that your
> version is more consistent with the sinc_table initialization?
> It's been a long time since I looked at this code).
> I've merged your changes in, but kept the old way under
> a compile-time switch so it's easy to move back and forth.
> I'll update the ccrma versions tomorrow morning.

Currently I have just some examples with sound files and sinusoids, to
check aliasing and amplitude. I think the resampler is correct if the
changed code passes all the tests for the original src and src-channel.
This message for the mailing list is also an informal test for some
user code.

About the consistence with the sinc_table initialization: the weak
point of the original version is the table index with non-integer high
rates:

x = zf * (srp->width_1 - srpx);
sinc_loc = x + srp->sinc4;

It means:

/*
 * Memo: `width' is half length. It originally was the width
 * of half sinc (the right side).
 */
L = SRC_SINC_DENSITY;
x = L * (1 - width - frac(rate)) / rate;
table_index = x + L * width + padding;

==> k = padding + L * (1 - frac(rate))
table_index = L * width * (1 - 1/rate) + k;

If the non-integer rate >1 is near 1, the first table index is low
and the interpolated sinc is windowed (the approximation depends on rate),
otherwise...

   limL * width * (1 - 1/rate) = L * width [= main_lobe_peak]
rate -> inf

...the sinc is truncated with high values of rate.

The first index in the new version is

L * (1 - frac(rate)) + padding;

The range is [padding; L + padding].

Padding is necessary with the original version.
Note: the sinc() begins at the index 0 of the table but the window
starts at index `padding'.

The window is interpolated, but I think it is possible to remove the
interpolation for low values of `width'; however that's a minor
optimization without considerable enhancements. Kaiser window with
adjustable parameter makes the difference.
___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist


[CM] Snd/CLM: experimental version of src and src-channel

2020-09-10 Thread Tito Latini
Hi,

the attached short patch changes mus_src() and mus_src_to_buffer()
in snd/clm.c. Probably it is compatible with clm-5/clm.c (no tested).

It seems good with constant rates or envelopes. The aliasing is
remarkably reduced and the amplitude of the resampled sound is very good.

The conversion is performed through the convolution between the input,
upsampled by rate, and the polyphase filters obtained from the windowed
sinc table. The delay between the polyphase filters is not one sample,
but it depends on the rate. For example, if rate is 1.9, the phase shift
is pi/5:

2 pi (1 - frac(1.9)) = 2 pi 0.1 = pi/5

therefore the index of the first coefficient for the next polyphase
filter is

SINC-TABLE-DENSITY * 0.1 = 2000 * 0.1 = 200

In practice, sinc_loc (the table index) and sinc_incr are reduced to

sinc_loc = SRC_SINC_DENSITY * (1 - srpx) + 4;
sinc_incr = SRC_SINC_DENSITY;

The increment sinc_incr is the consequence of the polyphase filtering:
a coefficient after (SRC_SINC_DENSITY - 1) zeroes.

I'm getting also better results with a Kaiser window (not a surprise).
It is possible to apply that window if a window parameter, for example
window-beta, is set for make-src (not in patch), otherwise the default
remains the Hanning window. Kaiser window is not particularly
interesting with the current implementation (but we increase the table
length), because a compressed interpoled sinc for non-integer rates >1
doesn't start where the window begins, so the sinc is often truncated).
On the contrary, the index of a polyphase filter is always near the
left side (less than SRC_SINC_DENSITY in the upsampled FIR).

What do you think?
--- snd/clm.c~  2020-09-10 16:06:48.774551471 +0200
+++ snd/clm.c   2020-09-10 16:05:39.163555210 +0200
@@ -13298,8 +13298,8 @@
 mus_float_t mus_src(mus_any *srptr, mus_float_t sr_change, mus_float_t 
(*input)(void *arg, int direction))
 {
   sr *srp = (sr *)srptr;
-  mus_float_t sum, zf, srx, factor;
-  int lim, loc, xi;
+  mus_float_t sum, srx;
+  int lim, loc;
   bool int_ok;
   mus_float_t *data, *sinc_table;
 
@@ -13351,9 +13351,10 @@
   if (srx < 0.0) srx = -srx;
   if (srx > 1.0) 
 {
-  factor = 1.0 / srx;
+  mus_float_t zf;
+  int xi;
   /* this is not exact since we're sampling the sinc and so on, but it's 
close over a wide range */
-  zf = factor * (mus_float_t)SRC_SINC_DENSITY; 
+  zf = SRC_SINC_DENSITY / srx;
   xi = (int)(zf + 0.5);
 
   /* (let ((e (make-env '(0 1 1 1.1) :length 11))) (src-channel e))
@@ -13363,20 +13364,16 @@
 }
   else 
 {
-  factor = 1.0;
-  zf = (mus_float_t)SRC_SINC_DENSITY;
-  xi = SRC_SINC_DENSITY;
   int_ok = true;
 }
 
   sum = 0.0;
   if (int_ok)
 {
-  int sinc_loc, sinc_incr, last, last10, xs;
+  int sinc_loc, sinc_incr, last, last10;
   
-  xs = (int)(zf * (srp->width_1 - srp->x));
-  sinc_loc = xs + srp->sinc4;
-  sinc_incr = xi;
+  sinc_loc = SRC_SINC_DENSITY - (int)(SRC_SINC_DENSITY * srp->x) + 4;
+  sinc_incr = SRC_SINC_DENSITY;
   last = loc + lim;
   last10 = last - 10;
 
@@ -13398,12 +13395,11 @@
 }
   else
 {
-  mus_float_t sinc_loc, sinc_incr, x;
+  mus_float_t sinc_loc, sinc_incr;
   int last, last10;
 
-  x = zf * (srp->width_1 - srp->x);
-  sinc_loc = x + srp->sinc4;
-  sinc_incr = zf;
+  sinc_loc = SRC_SINC_DENSITY * (1 - srp->x) + 4;
+  sinc_incr = SRC_SINC_DENSITY;
   last = loc + lim;
 
   last10 = last - 10;
@@ -13426,7 +13422,7 @@
 }
 
   srp->x += srx;
-  return(sum * factor);
+  return(sum);
 }
 
 
@@ -13435,8 +13431,8 @@
   /* sr_change = 0.0
*/
   sr *srp = (sr *)srptr;
-  mus_float_t x, zf, srx, factor, sincx, srpx;
-  int lim, i, xi, xs, dir = 1;
+  mus_float_t srx, sincx, srpx;
+  int lim, i, dir = 1;
   bool int_ok;
   mus_long_t k;
   mus_float_t *data, *sinc_table;
@@ -13454,17 +13450,15 @@
 }
   if (srx > 1.0) 
 {
-  factor = 1.0 / srx;
+  mus_float_t zf;
+  int xi;
   /* this is not exact since we're sampling the sinc and so on, but it's 
close over a wide range */
-  zf = factor * sincx;
-  xi = (int)zf;
+  zf = sincx / srx;
+  xi = (int)(zf + 0.5);
   if (fabs((xi - zf) * lim) > 2.0) int_ok = false; else int_ok = true;
 }
   else 
 {
-  factor = 1.0;
-  zf = sincx;
-  xi = SRC_SINC_DENSITY;
   int_ok = true;
 }
 
@@ -13502,10 +13496,9 @@
   if (int_ok)
{
  int sinc_loc, sinc_incr, last, last10;
- 
- xs = (int)(zf * (srp->width_1 - srpx));
- sinc_loc = xs + srp->sinc4;
- sinc_incr = xi;
+
+ sinc_loc = SRC_SINC_DENSITY - (int)(SRC_SINC_DENSITY * srpx) + 4;
+ sinc_incr = SRC_SINC_DENSITY;
  last = loc + lim;
  last10 = last - 10;
  
@@ -13529,10 +13522,9 @@
{
  mus_float_t sinc_loc, sinc_incr;
  int last, last10;
- 
- x = zf * 

Re: [CM] How to send udp bundles from Grace on Linux?

2020-03-06 Thread Tito Latini
I forgot... it works with or without daemon-mode here.
Tested with a recent version.
___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist



Re: [CM] How to send udp bundles from Grace on Linux?

2020-03-06 Thread Tito Latini
On Fri, Mar 06, 2020 at 02:31:25PM -0800, Forrest Curo wrote:
> Tito:
> Csound simply runs & ends from your command line. Just runs out of score
> events & stops.
> 
> It prefers:
> csound -odac -+rtaudio=null *--daemon* -L "score"  --orc test.orc
> 
> I know that  -L is supposed to imply running in '--daemon' mode but maybe
> not when using an .orc file?
> 
> No problem, thanks!

I have never used that flag but canonic-mode works:

nohup csound -odac -+rtaudio=null -L score --orc test.orc &

jobs
[1]+  Running  nohup csound -odac -+rtaudio=null -L score --orc test.orc &

# game over
kill %
___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist



Re: [CM] How to send udp bundles from Grace on Linux?

2020-03-06 Thread Tito Latini
On Thu, Mar 05, 2020 at 06:05:04PM -0800, Forrest Curo wrote:
> Grace is sending valid osc messages.
> 
> If these were going to Supercollider, that's how they'd be handled.
> 
> Received by the csound udp server, valid osc is not valid realtime score
> events.
> 
> Since JUCE is largely a C++ compiler... I should be able to
> #include and add code to either write csound score lines to a
> fifo, or call bash's 'nc' to udp them to another computer. (?)
> 
> Those approaches wouldn't be graceful, but they are ways I could
> (eventually) do it for myself.

You could use the csound command line option `-L' with a named pipe.
The following example works with s7:

Csound orchestra test.orc:

instr 1
  print p1, p2, p3, p4, p5
endin

>From shell:

mkfifo score
csound -L score -odac -+rtaudio=null --orc test.orc

>From s7:

(define score (open-output-file "/path/to/score"))

(define* (csound-test (instr 1) (dur 1.0) (freq 440) (amp 0) (port score))
  (format port "i ~D 0 ~F ~F ~F~%" instr dur freq amp)
  (flush-output-port port))

(csound-test 1 1.5 1234 -6)
(csound-test :dur 3.2)
(csound-test :amp -3 :freq 660)

;; Remember to close the port.
(close-output-port score)
___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist



Re: [CM] where is the snd 19.9 tarball?

2019-11-29 Thread Tito Latini
On Thu, Nov 28, 2019 at 10:29:48PM -0500, David O'Toole wrote:
> https://ccrma.stanford.edu/software/snd/snd-19.9.tar.gz
> 
> this link is 404 for me.

ftp works:

ftp://ccrma-ftp.stanford.edu/pub/Lisp/snd-19.9.tar.gz
___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist



Re: [CM] snd-19.9

2019-11-28 Thread Tito Latini
On Thu, Nov 28, 2019 at 03:06:17AM -0800, b...@ccrma.stanford.edu wrote:
> I tried Snd in ubuntu 19.04, gtk 3.24.8, and the listener is ok;
> also Fedora 31, gtk 3.24.12.  What does this report?
> 
> ./snd --version
> 
> This reminds me I need to upgrade to ubuntu 19.10.

Perhaps it is a problem with left-arrow for start-of-line and
right-arrow for end-of-line. This change should be ok with emacs
key bindings (they generally are `left-char' for left-arrow and
`right-char' for right-arrow):

--- snd-svn/glistener.c~2019-11-28 14:40:22.420965329 +0100
+++ snd-svn/glistener.c 2019-11-28 14:54:50.721918686 +0100
@@ -1491,17 +1491,17 @@
   G_TYPE_INT, -1,
   G_TYPE_BOOLEAN, false);
 
-  /* right-arrow end of line */
+  /* right-arrow forward char */
   gtk_binding_entry_remove(set, GDK_KEY_Right, (GdkModifierType)0);
   gtk_binding_entry_add_signal(set, GDK_KEY_Right, (GdkModifierType)0, 
"move_cursor", 3,
-  G_TYPE_ENUM, GTK_MOVEMENT_DISPLAY_LINE_ENDS,
+  G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS,
   G_TYPE_INT, 1,
   G_TYPE_BOOLEAN, false);
 
-  /* left-arrow start of line */
+  /* left-arrow back char */
   gtk_binding_entry_remove(set, GDK_KEY_Left, (GdkModifierType)0);
   gtk_binding_entry_add_signal(set, GDK_KEY_Left, (GdkModifierType)0, 
"move_cursor", 3,
-  G_TYPE_ENUM, GTK_MOVEMENT_DISPLAY_LINE_ENDS,
+  G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS,
   G_TYPE_INT, -1,
   G_TYPE_BOOLEAN, false);
___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist



Re: [CM] duplicating each N samples of an audio file

2019-08-26 Thread Tito Latini
On Sun, Aug 25, 2019 at 06:03:17PM -0400, David O'Toole wrote:
> Hello there! I'm trying to duplicate each N samples of an audio file so
> that ABCD becomes AABBCCDD and so on. I have modified one of the examples
> to produce the following code below, but it doesn't work. It makes a
> properly-sized blank audio file, but only the first block is written.
> Indeed, putting in a print statement shows that the loop is only run once.
> But NUM-BLOCKS turns out to be 51 which is what I expected. Forgive me if
> this is a simple Scheme error, as I am more familiar with Common Lisp and
> Elisp than I am with Scheme. Or I may be misunderstanding something about
> Snd itself. I would greatly appreciate any help you can offer. Thank you.
> ---_David
> 
> (when (= 0 (length (sounds)))
>   (open-sound "/home/dto/Desktop/beatloop.wav"))
> 
> (define echo-mosaic
>   (lambda* (block-len snd chn)
> (let* ((len (framples snd chn))
>   (num-blocks (floor (/ len (srate snd) block-len)))
>   (new (new-sound #f :size (* 2 len
>   (if (> num-blocks 1)
>  (let ((actual-block-len (ceiling (/ len num-blocks
>(do ((n 0 (+ n 1)))
> ((= n num-blocks))
>  (let ((beg (* n actual-block-len)))
> (let ((reg (make-region beg (+ beg actual-block-len) chn)))
>  (mix-region reg (* 2 beg) new chn)
>  (mix-region reg (+ (* 2 beg) actual-block-len) new chn)
>  (forget-region reg
>new)
> 
> (echo-mosaic 0.25 0 0)

There is a trivial error; it is correct:

  (let ((reg (make-region beg (+ beg actual-block-len -1) snd chn))) ...)

The result of your echo-mosaic is a new empty sound file with pending mixes.
Perhaps you want save-sound after loop:

  (do ((n 0 (+ n 1)))
- ((= n num-blocks))
+ ((= n num-blocks) (save-sound new))

possibly with a filename for new-sound.
___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist



Re: [CM] Snd 17.8

2017-10-17 Thread Tito Latini
> test that I forgot.  Thanks again -- now I'm wondering if
> mkinstalldirs is needed anymore -- back in the old days, makefiles
> would create system directories -- seems like a bad idea now.
> makefile.in currently uses that script if you include --install,
> but that stuff is 20 years old.

Perhaps the `install' command from coreutils could replace mkinstalldirs.

I generally use `make install' with DESTDIR to create a local
Slackware package but I can change that script/habit without problems:

# from root
mkdir slack
make DESTDIR=$PWD/slack install
gzip -9 slack/usr/share/man/man1/snd.1
mkdir -p slack/usr/share/doc/snd
cp -r *.html pix slack/usr/share/doc/snd
cp -r HISTORY.Snd NEWS README.Snd sndins tools slack/usr/share/snd
cd slack
makepkg -l y -c n ../snd-17.8-x86_64-1.txz
upgradepkg ../snd-17.8-x86_64-1.txz
___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist



Re: [CM] Snd 17.8

2017-10-17 Thread Tito Latini
Thanks.

Some files are missing from svn:

sh> LANG=en_US diff -urq snd-svn snd-17 |grep Only|grep -v snd-svn
Only in snd-17: clm.html
Only in snd-17: config.rpath
Only in snd-17: dlocsig.html
Only in snd-17: expr.scm
Only in snd-17: freeverb-readme.txt
Only in snd-17: freeverb.html
Only in snd-17: mkinstalldirs
Only in snd-17/pix: newbuttons.png
Only in snd-17/tools: tall.scm
___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist



Re: [CM] asdf and clm on sbcl

2017-02-16 Thread Tito Latini
On Thu, Feb 16, 2017 at 12:02:34AM +0100, Ralf Mattes wrote:
> [...]
> > but it avoids an error with (load "clm.asd"). i
> 
>  But that's exactly how you should not use an asdf file.
>  Loading the file will unconditionally execute the code in that file
>  while (asdf:load-system ...) will not, once the system is loaded. That
>  makes quite a difference, esp. when asdf files contain substantial
>  amounts of code (CM, hintm hint ;-)

`(load "clm.asd")' is a simple registration of the wrapper to all.lisp:

  (APPLY 'ASDF/PARSE-DEFSYSTEM:REGISTER-SYSTEM-DEFINITION '"clm"
 '(:DESCRIPTION "Common Lisp Music" :VERSION "5" :AUTHOR ...))

therefore, if some scripts used LOAD with the old asd file, they
continue to work after the recent changes (probably only with asdf-3).

CLM is a fantastic tool without lisp-dependences and it works with a
simple ROCK-AND-ROLL function:

sh> mkdir /path/to/clm-5/build

;; ~/.sbclrc
(export 'rock-and-roll "CL-USER")

(defvar clm-bin-directory "/path/to/clm-5/build/")

(defun cl-user:rock-and-roll ()
  (unless (find-package "CLM") 
(load "/path/to/clm-5/all.lisp")
(provide "CLM"))
  (setf *package* (find-package "CLM")))

(pushnew (lambda (name)
   (when (string-equal (string name) "clm")
 (cl-user:rock-and-roll)))
 *module-provider-functions*)


sh> sbcl
(member :asdf *features*)  ; => NIL
(rock-and-roll); with conditional compilation!
;; or the alternative `(require :clm)'

# A quiet garage (no sputtering)
sh> ls /path/to/clm-5/build
audio.o   defaults.fasl  headers.o run.fasl
clm-package.fasl  defins.faslinitmus.fasl  sndlib2clm.fasl
clm.o env.fasl   io.o  sndplay
clm1.fasl export.fasllibclm.so sound.fasl
cmus.offi.fasl   mus.fasl  sound.o


> I wouldn't advise to use sbcl's current extension to require to load
> asdf systems. You're relying on the order of 
> sb-impl::*module-provider-functions*
> (but I have to confess that 'require does give cozzy nostalgic feelings
> ...)

I like REQUIRE, that's not a nostalgic utility, it works with or
without the optional asdf and SB-EXT:*MODULE-PROVIDER-FUNCTIONS* is
not an internal symbol.

sh> sbcl
*module-provider-functions*
;; => (SB-IMPL::MODULE-PROVIDE-CONTRIB)

(require :asdf)
*module-provider-functions*
;; => (ASDF/OPERATE:MODULE-PROVIDE-ASDF SB-IMPL::MODULE-PROVIDE-CONTRIB)

where ASDF/OPERATE:MODULE-PROVIDE-ASDF uses ASDF/OPERATE:REQUIRE-SYSTEM,
a version of ASDF/OPERATE:LOAD-SYSTEM that skips trying to update
systems that are already loaded.
___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist



Re: [CM] asdf and clm on sbcl

2017-02-15 Thread Tito Latini
On Wed, Feb 15, 2017 at 01:09:57PM -0500, Juan Reyes wrote:
[...]
> (require :asdf)
> (in-package :asdf-user)
> (asdf:defsystem "clm"
[...]

I think `(require :asdf)' within an asd file is not good style
(imagine 'require python' within a py file).

The missing line is just `(in-package :asdf-user)'.

It works with the posted .sbclrc example (I use a similar init file on
a sound machine without quicklisp):

sh> sbcl
(require :clm)
___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist



Re: [CM] asdf and clm on sbcl

2017-02-15 Thread Tito Latini
On Wed, Feb 15, 2017 at 12:20:03PM -0500, Juan Reyes wrote:
> 
> Hi,
> 
> As pointed out back in December, ASDF system definition file for CLM
> doesn't seem to work.
> 
> On SBCL (1.3.5) if I type,
> 
>  (require :asdf)
> 
>  (load "clm.asd")
> 
> I get,
> "There is no class named COMMON-LISP-USER::COMPILE-OP."
> 
> On SBCL, besides (require :asdf), do we need to load or get other ASDF
> features in order to get 'compile-op' working ?.
> 
> Of course, if I go back to Rick's previous definition I get ASDF working
> on SBCL again.

I forgot

(in-package :asdf-user)

at the beginning of clm.asd.

An example of ${HOME}/.sbclrc file:

(require :asdf)

(dolist (l (list '*default-pathname-defaults* #p"/path/to/clm/"))
  (pushnew l asdf:*central-registry* :test #'equal))
___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist



Re: [CM] quicklisp clm

2016-12-14 Thread Tito Latini
On Tue, Dec 13, 2016 at 08:40:06PM -0600, Juan Cristobal Cerrillo wrote:
> 
> > On Dec 10, 2016, at 7:22 AM, b...@ccrma.stanford.edu wrote:
> > 
> > ok -- that's fine by me, but I am no longer interested
> > in the CL part of that package.  I haven't worked on it
> > in about 20 years, and no longer have the time or
> > energy to provide support -- users of it are on their own.
> > Good luck.
> > 
> 
> Thank you for your reply Bill.
> 
> ¿Is anyone else is interested in collaborating on achieving a quicklisp 
> loadable cl-clm?
> All that is required is separating the different parts of all.lisp so that it 
> is loadable with asdf:load-system.
> I???ve managed to test my ???port??? successfully in ccl, sbcl and lispworks 
> on osx.
> (though I would gladly accept any suggestions/advice that would make it 
> clearer/better)
> 
> Once this is achieved, the changes could be easily incorporated into the 
> official distribution (and then available through quicklisp).
> 
> I think it would be wonderful if clm was installable through quicklisp, not 
> least for historical reasons!

If a minimalist approach is good for you, it is quicklispable :)

(asdf:defsystem "clm"
  :description "Common Lisp Music"
  :version "3"
  :author "William Schottstaedt "
  :licence "LLGPL"
  :perform (compile-op (o c)
 (load (system-relative-pathname "clm" "all.lisp"
___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist



Re: [CM] Snd 16.9

2016-10-24 Thread Tito Latini
Thanks to you.

> checked: FC 25, gtk 3.21.6 3.22.0|1, sbcl 1.3.10
>   in gtk 3.22.0, the basic display mechanism changed again(!) so
>   (at least today) the window-manager close decoration is messed up,
>   and I probably missed other troubles -- please let me know
>   as you encounter them.

With gtk+3-3.18.9, if I resize the window, the PANE_BOX (with the buttons
[ ]unite [ ]sync etc) is over the SND_PANE.

The child is added with gtk_paned_add1() and it is equivalent to

gtk_paned_pack1(paned, child, false, true)

If we set the argument "shrink" to "false", that problem seems fixed:

--- snd-16/snd-gsnd.c~  2016-10-24 15:23:54.123610733 +0200
+++ snd-16/snd-gsnd.c   2016-10-24 15:24:15.375343563 +0200
@@ -1587,7 +1587,7 @@
}
 
   PANE_BOX(sp) = gtk_vbox_new(false, 0);
-  gtk_paned_add1(GTK_PANED(SND_PANE(sp)), PANE_BOX(sp));
+  gtk_paned_pack1(GTK_PANED(SND_PANE(sp)), PANE_BOX(sp), false, false);
   gtk_widget_show(PANE_BOX(sp));
 
   NAME_HBOX(sp) = gtk_hbox_new(false, 0);
___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist



Re: [CM] clm delay offset for tap?

2016-09-28 Thread Tito Latini
On Wed, Sep 28, 2016 at 11:45:11AM +0200, ander...@notam02.no wrote:
> Hi Bill, others.
> 
> I'm confused about (positive) offset argument to tap.
> 
> Negative offsets yields perhaps expected results, but positive offsets
> starts pulling values from what seems an odd offset into the line.
> 
> (set! (*s7* 'print-length) 20)
> 
> (define d1 (make-delay 10))
> 
> (do ((i 0 (+ 1 i)))
> ((= i 10))
>   (delay d1 i))
> 
> (mus-data d1)
> => (float-vector 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0)
> 
> (tap d1)
> => 0.0
> (tap d1 1)
> => 5.0
> (tap d1 -1)
> => 1.0
> 
> (map (lambda (i) (tap d1 i)) '(0 1 2 3 4 5 6 7 8 9))
> => (0.0 5.0 4.0 3.0 2.0 1.0 0.0 9.0 8.0 7.0)
> 
> (map (lambda (i) (tap d1 i)) '(-0 -1 -2 -3 -4 -5 -6 -7 -8 -9))
> => (0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0)

That's a bug with the modulus operator in c

(int)-1 % (unsigned int)10=> 5

(int)-1 % (int)10 => -1

The follow patch seems ok:

diff -ur snd-16~/clm.c snd-16/clm.c
--- snd-16~/clm.c   2016-09-28 15:21:57.567364000 +0200
+++ snd-16/clm.c2016-09-28 15:22:15.075143897 +0200
@@ -4382,7 +4382,7 @@
   int taploc;
   if (gen->size == 0) return(gen->line[0]);
   if ((int)loc == 0) return(gen->line[gen->loc]);
-  taploc = (int)(gen->loc - (int)loc) % gen->size;
+  taploc = (int)(gen->loc - (int)loc) % (int)gen->size;
   if (taploc < 0) taploc += gen->size;
   return(gen->line[taploc]);
 }

___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist



Re: [CM] snd-nogui - graph->ps in batch file?

2016-06-01 Thread Tito Latini
On Wed, Jun 01, 2016 at 10:45:35AM -0700, b...@ccrma.stanford.edu wrote:
> I think in the gtk script case, the gtk event
> queue is not being completely drained, so
> this code at least gets a squished graph:
> 
> (open-sound "oboe.snd")
> (set! (show-full-duration) #t)
> (set! (transform-graph?) #t)
> (set! (time-graph?) #f)
> 
> (do ((i 0 (+ i 1)))
> ((or (= i 1)
>(= (gtk_events_pending) 0)))
>   (gtk_main_iteration))
> 
> (set! (transform-graph-type) graph-as-sonogram)
> (set! (fft-log-frequency) #t)
> (update-transform-graph)
> (graph->ps "hi.eps")
> 
> (exit)
> 
> 
> This seems like several different bugs -- hooboy.

Hey Bill, gtk_widget_get_allocated_width() and gtk_widget_get_allocated_height()
return 1 in batch mode and display_channel_data_with_size() is bypassed.

The follow minimal patch is a possible fix.

The values for width and height are copied from a printf in `snd_motif -b ...'.
Largest values, slowest processing.


diff -ur snd-16~/snd-chn.c snd-16/snd-chn.c
--- snd-16~/snd-chn.c   2016-06-01 19:37:39.322878464 +0200
+++ snd-16/snd-chn.c2016-06-01 19:37:45.044806529 +0200
@@ -4378,6 +4378,15 @@
 {
   width = widget_width(channel_graph(cp));
   height = widget_height(channel_graph(cp));
+
+#if USE_GTK
+  if (ss->batch_mode)
+{
+  width = 583;
+  height = 374;
+}
+#endif
   if ((height > 5) && (width > 5))
display_channel_data_with_size(cp, width, height, 0, just_fft, 
just_lisp, just_time, use_incoming_cr);
 }
___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist



Re: [CM] snd-nogui - graph->ps in batch file?

2016-06-01 Thread Tito Latini
I forgot to say that I'm using snd compiled with motif.

snd_motif -b prior_script.scm  ; OK
snd_gtk -b prior_script.scm; FAIL
snd_nogui prior_script.scm ; FAIL
___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist



Re: [CM] snd-nogui - graph->ps in batch file?

2016-06-01 Thread Tito Latini
me:

> bla bla bla update-transform-graph before graph->ps bla bla [...]

show-full-duration #t is also useful
___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist



Re: [CM] snd-nogui - graph->ps in batch file?

2016-06-01 Thread Tito Latini
On Wed, Jun 01, 2016 at 10:27:01AM +0200, ander...@notam02.no wrote:
> Hi.
> 
> Sparked by a question on linux-audio-users just now, i wanted to check
> if i could create sonograms and similar by scripting Snd (which could be
> very useful), but the .eps-file Snd leaves is empty.
> 
> Evaluating the same list of calls step by step works fine.
> 
> Putting in some (sleep 3) calls along the route didn't help either.
> 
> Is this achievable?
> 
> Here's what i'm trying:
> 
> (open-sound "mono-10s.wav")
> (set! (transform-graph?) #t)
> (set! (time-graph?) #f)
> (set! (transform-graph-type) graph-as-sonogram)
> (set! (fft-log-frequency) #t)
> (graph->ps "mono-10s-sonogram.eps")
> (exit)

you have success with update-transform-graph before graph->ps

(open-sound "mono-10s.wav")
(set! (transform-graph?) #t)
(set! (time-graph?) #f)
(set! (transform-graph-type) graph-as-sonogram)
(set! (fft-log-frequency) #t)
(update-transform-graph)
(graph->ps "mono-10s-sonogram.eps")
(exit)
___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist



Re: [CM] cm2/cm.asd -> ASDF-3 ?

2016-03-29 Thread Tito Latini
On Tue, Mar 29, 2016 at 10:16:39AM +0200, anders wrote:
> In a thread some years ago about CM2's build-system -
> http://thread.gmane.org/gmane.lisp.ccrma.general/4120/focus=4148 - some
> woes about cm2/cm.asd lagging behind, not being compatible with ASDF-3
> came across.
> 
> Has anyone seen a ASDF-3 compatible cm2/cm.asd?

Sometimes I use the attached simplified cm.asd (without "pm" and "rt"
to work with my cl tool).
;;; **
;;; Copyright (C) 2005 Heinrich Taube, 
;;;
;;; This program is free software; you can redistribute it and/or
;;; modify it under the terms of the Lisp Lesser Gnu Public License.
;;; See http://www.cliki.net/LLGPL for the text of this agreement.
;;; **

(in-package :cl-user)

(defvar *cm-directory* 
  (namestring
   (truename (make-pathname :name nil :type nil
:defaults *load-truename*

#-(or allegro clisp cmu lispworks openmcl sbcl ecl)
(error "Sorry, Common Music does not run in this Lisp.")

(defpackage :common-music-system (:use :cl :asdf))
(in-package :common-music-system)

(defun cm-directory ( subs)
  (namestring
   (make-pathname :name nil :type nil
  :directory (append (pathname-directory 
cl-user::*cm-directory*)
 subs)
  :defaults cl-user::*cm-directory*)))

(defmethod perform :after ((op load-op) cm)
  ;; add cm feature before loading other systems...
  (pushnew :cm *features*)
  ;; load site init file if it exists
  (load (merge-pathnames "cminit.lisp" (cm-directory "etc"))
:if-does-not-exist nil)
  ;; load user init file if it exists
  (load (merge-pathnames ".cminit.lisp" (user-homedir-pathname))
:if-does-not-exist nil))

;;;
;;; system definition
;;;

(defsystem :cm
:description "Common Music"
:version "2.12.0"
:author "Rick Taube "
:licence "LLGPL"
:components
((:module "src"
  :serial t
  :components ((:file "pkg")
   (:file #+allegro "acl"
  #+clisp "clisp"
  #+cmu "cmu"
  #+ecl "ecl"
  #+lispworks "lispworks"
  #+(and mcl (not openmcl)) "mcl"
  #+openmcl "openmcl"
  #+sbcl "sbcl")
   (:file "iter")
   (:file "level1")
   (:file "clos")
   (:file "scheme")
   (:file "utils")
   (:file "mop")
   (:file "objects")
   (:file "data")
   (:file "scales")
   (:file "spectral")
   (:file "patterns")
   (:file "io")
   (:file "scheduler")
   (:file "gnuplot")
   (:file "plt")
   (:file "sco")
   (:file "clm")
   (:file "midi1")
   (:file "midi2")
   (:file "midi3")
   (:file "cmn")
   (:file "fomus")
   (:file "sc")
   (:file "pm")
   (:file "rt")
   (:file "parse")

;;;
;;; main functions
;;;

(in-package :cl-user)

(defun use-system (sys  directory bin-directory
   (verbose t) warnings symbols)
  (declare (ignore directory bin-directory warnings symbols))
  (asdf:load-system sys :verbose verbose))

(defun cm ( systems)
  (flet ((cmcall (fn  args)
   (apply (find-symbol (string fn) :cm) args))
 (cmvar (var)
   (symbol-value (find-symbol (string var) :cm
(setf *package* (find-package :cm))
(setf *readtable* (cmvar :*cm-readtable*))
;; add slime readtable mapping...
(let ((swank-pkg (find-package :swank)))
  (when swank-pkg
(let ((sym (intern (symbol-name :*readtable-alist*) swank-pkg)))
  (setf (symbol-value sym)
(cons (cons (symbol-name :cm) (cmvar :*cm-readtable*))
  (symbol-value sym))
(let (#-sbcl (*trace-output* nil))
  (dolist (s systems) (use-system s :verbose nil)))
(cmcall :cm-logo)))

(export '(cm use-system) :cl-user)
___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist


[CM] Fix sdif-import

2015-06-29 Thread Tito Latini
Hello,

sdif-import fails, at least on GNU/Linux x86_64 with SDIF-3.11.4.
I have attached a patch to fix the bug. The logic to increment
bytesread follows the code of the tool `sdifextract':

  SdifFReadGeneralHeader(in);
  SdifFReadAllASCIIChunks(in);
  loop frames:
  SdifFReadFrameHeader(in);
  loop matrices:
  bytesread = SdifFReadMatrixHeader(in);
  loop rows:
  bytesread += SdifFReadOneRow(in);
  SdifFReadPadding(in, SdifFPaddingCalculate(in-Stream, bytesread));
  eof = SdifFGetSignature(in, bytesread) == eEof;
diff -ur commonmusic-code-2159-trunk~/src/CmSupport.cpp 
commonmusic-code-2159-trunk/src/CmSupport.cpp
--- commonmusic-code-2159-trunk~/src/CmSupport.cpp  2015-06-29 
12:04:03.677358890 +0200
+++ commonmusic-code-2159-trunk/src/CmSupport.cpp   2015-06-29 
12:07:10.470010588 +0200
@@ -2211,7 +2211,7 @@
 
   while (!endoffile  SdifFLastError(sdiffile) == NULL)
   {
-bytesread += SdifFReadFrameHeader(sdiffile);
+SdifFReadFrameHeader(sdiffile);
 // optionally skip frames that dont match what we want
 if (sigmatch==eEmptySignature || SdifFCurrSignature(sdiffile) == sigmatch)
 {
@@ -2228,7 +2228,7 @@
 
   for (int m = 0; m  numarrays; m++)
   {
-bytesread += SdifFReadMatrixHeader(sdiffile);
+bytesread = SdifFReadMatrixHeader(sdiffile);
 SdifSignature arraysig  = SdifFCurrMatrixSignature (sdiffile);
 SdifInt4 numrows = SdifFCurrNbRow (sdiffile);
 SdifInt4 numcols = SdifFCurrNbCol (sdiffile);
@@ -2265,6 +2265,7 @@
 // add this matrix to end of frame
 s7_set_cdr(ftail, s7_cons(st-scheme, mhead, st-schemeNil));
 ftail=s7_cdr(ftail);
+SdifFReadPadding(sdiffile, SdifFPaddingCalculate(sdiffile-Stream, 
bytesread));
   }
   // add this frame to end of results
   if (rhead == st-schemeNil)
___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist


Re: [CM] GRACE problems

2015-06-25 Thread Tito Latini
On Thu, Jun 25, 2015 at 11:42:45AM -0400, Dave Phillips wrote:
 Greetings,
 
 I built the latest SVN update, have a problem with the audio device 
 selection :
 
 Error when trying to open audio device!
 
 Could not open audio device jack: Invalid argument (-22)
 
 I also received similar errors when I selected any other device listed, 
 including the default ALSA device. As far as I can tell, nothing else is 
 using JACK.
 
 I'm also having trouble with the SDIF support. I specify
 
   premake4 --with-sdif=/usr
 
 and premake reports no problem, which it shouldn't because sdif.h is 
 located at /usr/include. Make doesn't report a problem, but it doesn't 
 build an SDIF-enabled GRACE. I had no issues with the FOMUS and oscpack 
 support, and they are indicated in the GRACE window.
 
 Any suggestions ?

The fix for JACK is

sed 's/jack/with-jack/' -i premake4.lua   # line 257

premake4 clean
premake4 --with-jack --with-sdif=/usr

About SDIF:

ls /usr/{include/,lib64/lib}sdif*
/usr/include/sdif.h  /usr/lib64/libsdif-3.11.4.so  /usr/lib64/libsdif.la
/usr/include/sdif_version.h  /usr/lib64/libsdif.a  /usr/lib64/libsdif.so

grep SDIF Grace.make
[...] -DJUCE_JACK=1 [...] -DWITH_SDIF [...]

and libsdif is linked with the binary Grace after the compilation.
Perhaps (premake4.lua:362):

libdirs({sdif .. lib})

fails on your system. You could try to replace lib with lib64.

(JACK audio tested in [Audio]-[Audio Settings...]-[Test])
___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist



Re: [CM] snd arithmetics - odd numbers - locale thing?

2015-06-19 Thread Tito Latini
It works with LC_NUMERIC C if Snd is compiled `--without-gui':

   LC_NUMERIC=fr_FR ./snd_nogui
   0.1
   ; = 0.1

   LC_NUMERIC=fr_FR ./snd# motif or gtk
   0.1
   ; = 0,1.0

The attached patch is a possible solution for Motif and Gtk.
diff -ur snd-15~/snd-gmain.c snd-15/snd-gmain.c
--- snd-15~/snd-gmain.c 2015-06-19 22:22:34.662386069 +0200
+++ snd-15/snd-gmain.c  2015-06-19 22:22:49.254202626 +0200
@@ -423,6 +423,10 @@
   shell = gtk_window_new(GTK_WINDOW_TOPLEVEL);
   sg_make_resizable(shell);
 
+#ifndef _MSC_VER
+  setlocale(LC_NUMERIC, C);
+#endif
+
   auto_open_files = argc-1;
   if (argc  1) auto_open_file_names = (char **)(argv + 1);
   ss-startup_title = mus_strdup(snd);
diff -ur snd-15~/snd-motif.c snd-15/snd-motif.c
--- snd-15~/snd-motif.c 2015-06-19 22:22:34.672385944 +0200
+++ snd-15/snd-motif.c  2015-06-19 22:22:49.258202575 +0200
@@ -30662,6 +30662,10 @@
  NULL);
 #endif
 
+#ifndef _MSC_VER
+  setlocale(LC_NUMERIC, C);
+#endif
+
   /* if user has *keyboardFocusPolicy: Pointer in .Xdefaults, it can screw up 
Snd's attempt to
* keep the channel graphics window as the active widget in case of keyboard 
input.  So,
* we try to force Snd's focus policy to be XmEXPLICIT
___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist


Re: [CM] cannot save files from Grace?

2015-05-25 Thread Tito Latini
On Mon, May 25, 2015 at 11:04:27AM +0200, Stefaan Himpe wrote:
 Hello list,
 
 I'm hitting an annoying problem while experimenting with grace
 freshly compiled from cm-3.9.0 using premake4.4beta5
 
 Whenever I try to save a file from grace, it bails out with an error.
 (link to screenshot further in the mail).
 
 Since grace is the only program on my computer that behaves like
 this I assume it's a problem with grace somehow (despite the error pointing
 to something samba? Not sure why samba would be even used as I do not
 have anything related to microsoft windows on this computer.)
 
 I'm running grace under kde on arch linux, kernel:
 
  Linux name 4.0.4-2-ARCH #1 SMP PREEMPT Fri May 22 03:05:23 UTC 2015 x86_64
 GNU/Linux
 
 A screenshot of the error can be found here:
 
 http://i.imgur.com/ApchGhm.png
 
 My workaround is to copy/paste everything to a different editor for now
 but as you can imagine this is not a lot of fun :)
 Any ideas how to go about making this work?

The standard error of kdialog is not redirected because the flag in

if (child.start (args, ChildProcess::wantStdOut))

is ignored (juce_gui_basics/native/juce_linux_FileChooser.cpp).

It means that the filename is all the kdialog output (stdout + stderr).
Probably you are using old JUCE's code with a bug in

juce/modules/juce_core/native/juce/posix/SharedCode.h

You can update JUCE or change the lines (the second `if' is your problem):

if ((streamFlags | wantStdOut) != 0)
[...]
if ((streamFlags | wantStdErr) != 0)

with

if ((streamFlags  wantStdOut) != 0)
[...]
if ((streamFlags  wantStdErr) != 0)

___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
http://ccrma-mail.stanford.edu/mailman/listinfo/cmdist



[CM] Snd: no tracking-cursor if one sound is stopped

2015-04-03 Thread Tito Latini
I have another patch to fix a graphic problem when two or more sounds
are playing and with-tracking-cursor is not #f (or we start to play
the sounds with [Ctrl][Play]).

Example:

- (set! *with-tracking-cursor* #t)

- open and play two sounds

- stop one sound

  (the cursor of the other sound is motionless)
diff -ur snd-15~/snd-dac.c snd-15/snd-dac.c
--- snd-15~/snd-dac.c   2015-04-03 13:56:30.423019828 +0200
+++ snd-15/snd-dac.c2015-04-03 13:56:40.722890341 +0200
@@ -611,6 +611,16 @@
 }
 
 
+static bool something_is_playing(void)
+{
+  int i;
+  if (play_list)
+for (i = 0; i  dac_max_sounds; i++)
+  if (play_list[i]) return(true);
+  return(false);
+}
+
+
 static void reflect_play_stop(snd_info *sp) 
 {
 #if (!USE_NO_GUI)
@@ -620,7 +630,8 @@
 #if (!USE_NO_GUI)
   view_files_unplay();
 #endif
-  ss-tracking = false;
+  if (!(something_is_playing()))
+ss-tracking = false;
 }
 
 
@@ -902,16 +913,6 @@
 }
 
 
-static bool something_is_playing(void)
-{
-  int i;
-  if (play_list)
-for (i = 0; i  dac_max_sounds; i++)
-  if (play_list[i]) return(true);
-  return(false);
-}
-
-
 /*  play (add to play-list) 
 */
 
 static int find_slot_to_play(void)
___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
http://ccrma-mail.stanford.edu/mailman/listinfo/cmdist


[CM] Snd: region's peak_envs not updated after editing

2015-03-27 Thread Tito Latini
Hello, you can see this bug with the follow steps:

  - make a region, no too short otherwise `peak_env_usable' returns
false and the waveform is correct

  - edit the created region

  - from Regions view, move the slider to right. During the sliding,
when `peak_env_usable' returns true in snd-chn.c:1797, it starts
to display the old waveform.

The attached patch is a possible solution.
diff -ur snd-15~/snd-region.c snd-15/snd-region.c
--- snd-15~/snd-region.c2015-03-27 19:33:23.042250004 +0100
+++ snd-15/snd-region.c 2015-03-27 19:33:29.200172589 +0100
@@ -1246,9 +1246,13 @@
 
   for (i = 0; i  sp-nchans; i++)
 {
+  chan_info *cp;
   mus_float_t val;
   val = channel_maxamp(sp-chans[i], AT_CURRENT_EDIT_POSITION);
   if (val  r-maxamp) r-maxamp = val;
+
+  if ((cp = sp-chans[i]))
+r-peak_envs[i] = copy_peak_env_info(cp-edits[0]-peak_env, false);
 }
 
   /* make new region temp file */
___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
http://ccrma-mail.stanford.edu/mailman/listinfo/cmdist


Re: [CM] Snd: region's peak_envs not updated after editing

2015-03-27 Thread Tito Latini
ops, just noticed that the patch is incomplete: probably the memory of
the old r-peak_envs is to free (AFK at moment).

___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
http://ccrma-mail.stanford.edu/mailman/listinfo/cmdist



[CM] s7 (current) doesn't compile with GNU multiprecision arithmetic

2015-03-20 Thread Tito Latini
Hi, attached a patch to fix a recent typo.

(please pardon me if it is not correct to report/fix recent changes)
diff -ur snd-15~/s7.c snd-15/s7.c
--- snd-15~/s7.c2015-03-18 22:57:54.0 +0100
+++ snd-15/s7.c 2015-03-20 11:25:37.816183045 +0100
@@ -17380,7 +17380,7 @@
s7_pointer x;
 
NEW_CELL(sc, x, T_BIG_REAL);
-   add_bigreal(x);
+   add_bigreal(sc, x);
mpfr_init(big_real(x));
mpc_real(big_real(x), big_complex(p), GMP_RNDN);
 
@@ -17426,7 +17426,7 @@
   {
s7_pointer x;
NEW_CELL(sc, x, T_BIG_REAL);
-   add_bigreal(x);
+   add_bigreal(sc, x);
mpfr_init(big_real(x));
mpc_imag(big_real(x), big_complex(p), GMP_RNDN);
 
___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
http://ccrma-mail.stanford.edu/mailman/listinfo/cmdist


Re: [CM] s7 (current) doesn't compile with GNU multiprecision arithmetic

2015-03-20 Thread Tito Latini
 (And please don't hesitate to report bugs in the current tarballs!)

Ok, thanks to you!

___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
http://ccrma-mail.stanford.edu/mailman/listinfo/cmdist



Re: [CM] slime printing

2014-04-24 Thread Tito Latini
Saluton,

On Wed, Apr 23, 2014 at 07:45:56PM +, James Hearon wrote:
 I was hoping to get some advice on printing from emacs-slime.  I'm trying to 
 print output to a visible area of the emacs editor when the code is compiled 
 and runs, such as in with-sound below.
 
 I'm using f20, sbcl, emacs-slime, and clm but having a devil of a time 
 getting any contrib to load and run with my .emacs file which might support 
 more repl such as to the echo area etc.  I'm wondering what approach you 
 folks might use to print to std out?  Are you using a contrib package or 
 other editor and print .el utility files?
 
 I've tried things like (print ), and (format t ...) and (message ...), and 
 those evaluate the expression to the echo area but they don't work when I 
 compile and run and it is beeping.  Or am I totally off base, and lisp 
 doesn't do that very well at all?

hopefully I am not misunderstanding your intention, you could use the
*inferior-lisp* buffer associated with the lisp process:

  (format swank:*log-output* After all the jacks are in their boxes~%)

  ;; idem but sbcl specific
  (format sb-sys:*stderr* and the clowns have all gone to bed~%)

  (format sb-sys:*stdout* ~Ahe traffic lights, they turn blue tomorrow~%
  (eq swank:*log-output* sb-sys:*stderr*))

  (let ((*standard-output* swank:*log-output*))
(with-sound ...))

  etc..

Perhaps it is enough, otherwise it is also possible to change the
process-filter (from emacs), for example

  ;; current process-filter
  (process-filter (get-buffer-process *inferior-lisp*))
  ; = comint-output-filter

  ;; And the wind screams Mary
  (set-process-filter (get-buffer-process *inferior-lisp*)
  (lambda (process string)
...
... something with the string ...
...
(comint-output-filter process string)))

  ;; Uh will the wind ever remember the names it has blow in the past? 
  (set-process-filter (get-buffer-process *inferior-lisp*)
  #'comint-output-filter)


Tito Latini

___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
http://ccrma-mail.stanford.edu/mailman/listinfo/cmdist


[CM] explicit linking to dynamic loader for s7

2014-02-20 Thread Tito Latini
Hello,

my linux distro is slackware-14.1 (patched to fix a regression in
glibc-2.17) with gcc-4.8.2.

Grace r2141 compiled with success after

diff -ur cm~/premake4.lua cm/premake4.lua
--- cm~/premake4.lua2014-02-19 16:03:18.0 +0100
+++ cm/premake4.lua 2014-02-20 10:13:54.085701439 +0100
@@ -150,7 +150,7 @@
configuration(macosx)
linkoptions({-framework CoreAudio, -framework CoreFoundation, 
-framework CoreMidi})
configuration(linux)
-   links({asound})   
+   links({asound, dl})   
configuration(windows)
links({winmm})
linkoptions({/nodefaultlib:libcmt.lib}) -- stop libcmt.lib from 
complaining

tito

___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
http://ccrma-mail.stanford.edu/mailman/listinfo/cmdist


[CM] Snd Motif crash without a default for listener-font

2014-02-19 Thread Tito Latini
Hi,

the follow sequence is good:

(set! (listener-font) 9x15)
(load-from-path snd-motif.scm)

but it fails:

;(set! (listener-font) 9x15)
(load-from-path snd-motif.scm)

a boolean/string qui pro quo:

diff -ur snd-14~/snd-motif.scm snd-14/snd-motif.scm
--- snd-14~/snd-motif.scm   2014-02-19 12:29:54.0 +0100
+++ snd-14/snd-motif.scm2014-02-19 17:34:01.529931252 +0100
@@ -1322,7 +1322,10 @@
   ;; graphics stuff (fonts etc)
   (let*  ((gv (XGCValues))
  (shell ((main-widgets) 1))
- (button-fontstruct (XLoadQueryFont (XtDisplay shell) (or 
(listener-font) 9x15
+ (button-fontstruct (XLoadQueryFont (XtDisplay shell)
+ (if (string=? (listener-font) )
+ 9x15
+ (listener-font)
 (set! (.foreground gv) *data-color*)
 (set! (.background gv) *basic-color*)
 (if (and button-fontstruct (.fid button-fontstruct))


tito

___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
http://ccrma-mail.stanford.edu/mailman/listinfo/cmdist