Commit e80d59d2 authored by Dave Griffiths's avatar Dave Griffiths
Browse files

time fixes

parent 045eefea
......@@ -47,8 +47,8 @@
(map (lambda (l) (apply synth-connect l)) (make-args id operands))
(node id)))
(define (play-now node pan) (synth-play 0 0 (node-id node) pan))
(define (play time node pan) (synth-play (car time) (cadr time) (node-id node) pan))
(define (play-now node pan) (synth-play 0 (node-id node) pan))
(define (play time node pan) (synth-play time (node-id node) pan))
;;---------------------------------------------------------------
;; operators
......
(synth-init)
(define (time-add t secs)
(list (+ (car t) secs) (cadr t)))
(define time (time-add (time-of-day) 20))
(define time (ntp-time-add (ntp-time) 2))
(define (loop time m)
(when (< m 100)
(display time)(newline)
(play time (mul (adsr 0 0.1 0.3 1) (saw (+ 40 (* m 20)))) 0)
(loop (time-add time 1) (+ m 1))))
(when (< m 10)
(display time)(newline)
(play time (mul (adsr 0 0.1 0.3 1) (saw (+ 400 (* m 20)))) 0)
(loop (ntp-time-add time 0.3) (+ m 1))))
(loop time 0)
\ No newline at end of file
......@@ -200,7 +200,8 @@
// _OP_DEF(opexe_6, "db-select-blob", 5, 5, TST_NONE, OP_SELECT_BLOB_DB )
_OP_DEF(opexe_6, "db-status", 1, 1, TST_NONE, OP_STATUS_DB )
_OP_DEF(opexe_6, "time-of-day", 0, 0, TST_NONE, OP_TIME )
_OP_DEF(opexe_6, "ntp-time", 0, 0, TST_NONE, OP_NTP_TIME )
_OP_DEF(opexe_6, "ntp-time", 0, 0, TST_NONE, OP_NTP_TIME )
_OP_DEF(opexe_6, "ntp-time-add", 2, 2, TST_NONE, OP_NTP_TIME_ADD )
_OP_DEF(opexe_6, "date-time", 0, 0, TST_NONE, OP_DATETIME )
_OP_DEF(opexe_6, "id-map-add", 2, 2, TST_NONE, OP_ID_MAP_ADD )
_OP_DEF(opexe_6, "id-map-get", 1, 1, TST_NONE, OP_ID_MAP_GET )
......
......@@ -4491,9 +4491,19 @@ static pointer opexe_6(scheme *sc, enum scheme_opcodes op) {
}
case OP_NTP_TIME: {
Time t;
t.SetToNow();
s_return(sc,mk_real(sc,t.Seconds+t.Fraction/(float)UINT_MAX));
}
t.SetToNow();
s_return(sc,cons(sc,mk_integer(sc,t.Seconds),
cons(sc,mk_integer(sc,t.Fraction),sc->NIL)));
}
case OP_NTP_TIME_ADD: {
Time t(ivalue(car(car(sc->args))),
ivalue(cadr(car(sc->args))));
t+=rvalue(cadr(sc->args));
s_return(sc,cons(sc,mk_integer(sc,t.Seconds),
cons(sc,mk_integer(sc,t.Fraction),sc->NIL)));
}
case OP_DATETIME: {
timeval t;
// stop valgrind complaining
......@@ -4553,7 +4563,7 @@ static pointer opexe_6(scheme *sc, enum scheme_opcodes op) {
case OP_SYNTH_PLY: {
m_audio_graph
->Play(ivalue(car(sc->args)),
ivalue(cadr(sc->args)),
ivalue(cadr(sc->args)),
ivalue(caddr(sc->args)),
rvalue(cadddr(sc->args)));
s_return(sc,sc->F);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment