Reputation: 583
I wrote this program that uses the macros nota and ping, nota to allow me to define a note easier and ping to compress in only one line of code(the ones starting with ping) what I would do in three lines in the commented section(to send it through the loudspeaker).
The problem is that the two macros appear to not work together and I get the arity mismatch error:
stream-time: arity mismatch; the expected number of arguments does not match the given number expected: 0 given: 2 arguments.: # #
I tried with define and define-syntax and it doesn't work.
#lang racket
(provide (all-defined-out))
(require rsound)
(define-syntax-rule (nota x y)
(define x
(network ()
[sunet <= sine-wave y]
[out = (+ sunet)])))
(define-syntax-rule (ping y)
(
(signal-play y)
(sleep 0.25)
(stop)))
(nota E2 82)
(nota F#2 92)
(nota G2 98)
(nota A2 110)
(ping E2)
(ping F#2)
(ping E2)
(ping G2)
(ping E2)
(ping A2)
;(signal-play E2)
;(sleep 0.25)
;(stop)
;(signal-play F#2)
;(sleep 0.25)
;(stop)
;(signal-play G2)
;(sleep 0.25)
;(stop)
;(signal-play A2)
;(sleep 0.25)
;(stop)
Upvotes: 0
Views: 217
Reputation: 18917
ping
is missing a begin to group the 3 forms:
(define-syntax-rule (ping y)
(begin
(signal-play y)
(sleep 0.25)
(stop)))
then the macro stepper shows that your code is expanded to
(define E2 (network () [sunet <= sine-wave 82] [out = (+ sunet)]))
(define F#2 (network () [sunet <= sine-wave 92] [out = (+ sunet)]))
(define G2 (network () [sunet <= sine-wave 98] [out = (+ sunet)]))
(define A2 (network () [sunet <= sine-wave 110] [out = (+ sunet)]))
(begin (signal-play E2) (sleep 0.25) (stop))
(begin (signal-play F#2) (sleep 0.25) (stop))
(begin (signal-play E2) (sleep 0.25) (stop))
(begin (signal-play G2) (sleep 0.25) (stop))
(begin (signal-play E2) (sleep 0.25) (stop))
(begin (signal-play A2) (sleep 0.25) (stop))))
Upvotes: 3