Re: [racket-users] Playing with rsound

2019-12-07 Thread wanderley.guimar...@gmail.com
Thanks!  I will play with clip and assemble.

On Sat, Dec 7, 2019 at 4:39 PM John Clements 
wrote:

> The problem here is that the piano notes are not all the same duration.
> Specifically, your chord  (chord 60 64 67) is a bit longer:
>
> (rs-frames (chord 60 64 67)) -> 161634 frames
> (rs-frames (piano-tone 72)) -> 144000 frames
>
> There are a lot of ways of solving this, including clipping the two sounds
> to the same length and using the `assemble` function. but here’s one simple
> way:
>
>
> (require rsound)
> (require rsound/piano-tones)
> (define (chord . notes)
>   (rs-overlay* (map piano-tone notes)))
> (play (rs-append (rs-overlay (chord 60 64 67)
> (piano-tone 72))
>  (rs-overlay (chord 60 65 69)
> (piano-tone 72))
>  (rs-overlay (chord 62 67 71)
> (piano-tone 74))
>  (rs-overlay (chord 64 67 72)
> (piano-tone 84
>
>
> (that is, put the append on the outside, and the rs-overlays inside it.)
>
> (Also, yes, I made it a little I-IV-V-I instead of the same chord twice.)
>
> John
>
>
>
> > On Dec 7, 2019, at 14:39, wanderley.guimar...@gmail.com wrote:
> >
> > I started to playing around with rsound while reading its
> documentation.  I wrote the following code:
> >
> > #lang racket
> > (require rsound)
> > (require rsound/piano-tones)
> > (define (chord . notes)
> >   (rs-overlay* (map piano-tone notes)))
> > (play (rs-overlay (rs-append (chord 60 64 67)
> >  (chord 60 64 67))
> >   (rs-append (piano-tone 72)
> >  (piano-tone 72
> >
> > and I was expecting to hear `(piano-tone 72)` on the begin of the two
> chords.  The second `(piano-tone 72)` starts few milliseconds after the
> second chord starts.
> >
> > Can you help me understand why this is happening?
> >
> > Thanks,
> > wander
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups "Racket Users" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an email to racket-users+unsubscr...@googlegroups.com.
> > To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/CAAmHZodfci0HM0_b%2BPaEuGBojyJsKwOhDKd-%2Bgi3jJHhaHi7Hg%40mail.gmail.com
> .
>
>
>
> --
Abraço,
Wanderley Guimarães

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAAmHZodtDc_N38Y7Vqb4SncWZ7nxhBF45Dz-KNuUi5u_0cMMSQ%40mail.gmail.com.


Re: [racket-users] Playing with rsound

2019-12-07 Thread 'John Clements' via Racket Users
The problem here is that the piano notes are not all the same duration. 
Specifically, your chord  (chord 60 64 67) is a bit longer:

(rs-frames (chord 60 64 67)) -> 161634 frames
(rs-frames (piano-tone 72)) -> 144000 frames

There are a lot of ways of solving this, including clipping the two sounds to 
the same length and using the `assemble` function. but here’s one simple way:


(require rsound)
(require rsound/piano-tones)
(define (chord . notes)
  (rs-overlay* (map piano-tone notes)))
(play (rs-append (rs-overlay (chord 60 64 67)
(piano-tone 72))
 (rs-overlay (chord 60 65 69)
(piano-tone 72))
 (rs-overlay (chord 62 67 71)
(piano-tone 74))
 (rs-overlay (chord 64 67 72)
(piano-tone 84


(that is, put the append on the outside, and the rs-overlays inside it.)

(Also, yes, I made it a little I-IV-V-I instead of the same chord twice.)

John



> On Dec 7, 2019, at 14:39, wanderley.guimar...@gmail.com wrote:
> 
> I started to playing around with rsound while reading its documentation.  I 
> wrote the following code:
> 
> #lang racket
> (require rsound)
> (require rsound/piano-tones)
> (define (chord . notes)
>   (rs-overlay* (map piano-tone notes)))
> (play (rs-overlay (rs-append (chord 60 64 67)
>  (chord 60 64 67))
>   (rs-append (piano-tone 72)
>  (piano-tone 72
> 
> and I was expecting to hear `(piano-tone 72)` on the begin of the two chords. 
>  The second `(piano-tone 72)` starts few milliseconds after the second chord 
> starts.
> 
> Can you help me understand why this is happening?
> 
> Thanks,
> wander
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/CAAmHZodfci0HM0_b%2BPaEuGBojyJsKwOhDKd-%2Bgi3jJHhaHi7Hg%40mail.gmail.com.



-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/30767f0b-2fd3-480f-a350-9b4f32305498%40mtasv.net.


[racket-users] Playing with rsound

2019-12-07 Thread wanderley.guimar...@gmail.com
I started to playing around with rsound while reading its documentation.  I
wrote the following code:

#lang racket
(require rsound)
(require rsound/piano-tones)
(define (chord . notes)
  (rs-overlay* (map piano-tone notes)))
(play (rs-overlay (rs-append (chord 60 64 67)
 (chord 60 64 67))
  (rs-append (piano-tone 72)
 (piano-tone 72

and I was expecting to hear `(piano-tone 72)` on the begin of the two
chords.  The second `(piano-tone 72)` starts few milliseconds after the
second chord starts.

Can you help me understand why this is happening?

Thanks,
wander

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAAmHZodfci0HM0_b%2BPaEuGBojyJsKwOhDKd-%2Bgi3jJHhaHi7Hg%40mail.gmail.com.


Re: [racket-users] Scribble output without navigation

2019-12-07 Thread 'Reuben Thomas' via Racket Users
On Fri, 6 Dec 2019 at 15:43, Matthew Flatt  wrote:

> Do 'no-toc and 'no-sidebar style properties on the main part help? Or
> does that still leave navigation elements that you want removed?
>

That's a great improvement, thanks, although it still leaves the "tocset"
div, now empty.

What I couldn't work out was how to apply the style properties to the main
part without using @title, which adds a title I don't want to LaTeX output.
Would I need to use "make-part" to get a part without outputting anything?

-- 
https://rrt.sc3d.org

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAOnWdog1a24_dPKus_DAe_nn_rRZ5O1_9P_iMjAwWYRVW3C7aQ%40mail.gmail.com.


[racket-users] futures-sort update

2019-12-07 Thread Dominik Pantůček
Hello Racketeers,

I am continuing my work on cleaning up our private source code and
publishing it as a part of my futures-sort[1] package. Current state of
the package is:

- configurable parallelism depth
- in-place parallel merge-sort of both vector and fxvector
- parallel merge-sort with results going to a freshly allocated vector
- support for calling a custom progress reporting function for all variants

The only missing piece to put this on par with vector-sort is probably
the support for start and end indices and the #:key argument (which we
are internally using). I am not entirely sure if key-caching is feasible
though.

Apart from that and some documentation improvements (mainly for the
progress reporting feature), it is basically complete. In the future I'd
like to investigate possible speedups by providing optimized code paths
for "small" ranges starting with 3 element ranges.

I would appreciate any suggestions and/or feature requests.

Btw, this is production code we are using to speed up tome tasks both on
Linux and Windows.

If you want to benchmark it, beware: it is necessary to first sort some
large dummy vector to ensure that JIT kicks in (1000 elements is enough
with 7.5 on my i7 running Linux).

Also I am curious about what is necessary to get the package to a higher
ring. There will be no backwards-incompatible changes from now.

Any suggestions are - of course - welcome.


Cheers,
Dominik


[1] https://pkgs.racket-lang.org/package/futures-sort

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/eeb76294-4057-3226-9cab-a4e9c62afa03%40trustica.cz.


Re: [racket-users] How to use dates (especially gregor) with Typed Racket?

2019-12-07 Thread Ben Greenman
On 12/7/19, Marc Kaufmann  wrote:
> Thanks Ben and Jon, that did the trick.
>
> I realized when following the code that the structure wasn't exported - but
>
> I didn't know how to work around that. I now also checked the
> documentation, and the only thing I found on opaque types is
> https://docs.racket-lang.org/ts-reference/special-forms.html?q=opaque#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._require%2Ftyped%29%29.
>
> What it says about opaque types is:
>
> "Opaque types must be required lexically before they are used."

The docs says a little more --- there are 4 sentences that come right
before this one.

I think those sentences would be better off with:
1. a link to `make-predicate`
2. and English words at the start & end of each sentence

Let me know if you have other suggestions

> followed by an example that is even now non-trivial for me to parse and
> figure out. (I started going down the rabbit hole when the `->` was not
> used in the first position of the definition, nor written as `. -> .` Turns
> out types can be defined via infix notation, which is nice but unexpected.)

The docs for -> show the infix notation.

Is the example still difficult to figure out? We could replace it, but
I'm not sure what could be better

(if want to stop using infix notation here, then the other uses on the
same page need to change too)

>
> So there are two questions:
>
> 1. What does #:opaque do?
> 2. How could I have found that out by searching - or essentially the way to
>
> do it was "Email the list". If the latter, that's fine, the email list is
> very helpful and it would be good to add some additional explanation of
> opaque types to the documentation of `require-typed`, and possibly even to
> the typed racket reference. Probably the part talking about typed-racket
> untyped racket interaction.
>
> Let me try answering my first question: #:opaque defines a new type via a
> predicate function -- here `time?` -- that is being imported (can I use it
> without require-typed? I guess there would be no point, but I haven't
> thought this through). This is not based on the usual type constructors
> using other types, but based on whether a thing returns `#true` when passed
> to the predicate, in my case `time?`. I assume this means that the type is
> verified via contracts, so if I do this a lot I should expect some run-time
> performance hits (if I call this function a bunch, which isn't an issue in
> my case).

Right, a `Time` is any value that `time?` says yes to.

About performance: in type-checked code, you can expect to pay for
every call to `time?` and nothing else. The run-time hit should be the
same as using cond/if with any simple predicate.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAFUu9R6Qqa%3DHpkgrU4-_uEsoY3kgSW0dP3OfrAJn1T%2BndVbOpQ%40mail.gmail.com.


Re: [racket-users] Scribble output without navigation

2019-12-07 Thread 'Reuben Thomas' via Racket Users
On Fri, 6 Dec 2019 at 15:32, Sam Tobin-Hochstadt 
wrote:

> Is there a reason that not showing it is a problem, relative to not
> having it in the HTML? The CSS approach is quite easy.
>

I'm trying to generate XHTML for inclusion in web sites (as the main page
contents) and ePUB files, so it's just extra complexity and potential for
something to go wrong. If it were only the first case I was interested in,
the CSS solution might be fine.

-- 
https://rrt.sc3d.org

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAOnWdojmsNXMZvJWMpLs-z5dVT1mOrGKGN-BM5%3DhU%3D9FyUSemQ%40mail.gmail.com.


Re: [racket-users] How to use dates (especially gregor) with Typed Racket?

2019-12-07 Thread Marc Kaufmann
I meant `require/typed` obviously, not `require-typed`.

On Saturday, December 7, 2019 at 11:17:00 AM UTC+1, Marc Kaufmann wrote:
>
> Thanks Ben and Jon, that did the trick. 
>
> I realized when following the code that the structure wasn't exported - 
> but I didn't know how to work around that. I now also checked the 
> documentation, and the only thing I found on opaque types is 
> https://docs.racket-lang.org/ts-reference/special-forms.html?q=opaque#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._require%2Ftyped%29%29.
>  
> What it says about opaque types is:
>
> "Opaque types must be required lexically before they are used."
>
> followed by an example that is even now non-trivial for me to parse and 
> figure out. (I started going down the rabbit hole when the `->` was not 
> used in the first position of the definition, nor written as `. -> .` Turns 
> out types can be defined via infix notation, which is nice but unexpected.)
>
> So there are two questions: 
>
> 1. What does #:opaque do?
> 2. How could I have found that out by searching - or essentially the way 
> to do it was "Email the list". If the latter, that's fine, the email list 
> is very helpful and it would be good to add some additional explanation of 
> opaque types to the documentation of `require-typed`, and possibly even to 
> the typed racket reference. Probably the part talking about typed-racket 
> untyped racket interaction.
>
> Let me try answering my first question: #:opaque defines a new type via a 
> predicate function -- here `time?` -- that is being imported (can I use it 
> without require-typed? I guess there would be no point, but I haven't 
> thought this through). This is not based on the usual type constructors 
> using other types, but based on whether a thing returns `#true` when passed 
> to the predicate, in my case `time?`. I assume this means that the type is 
> verified via contracts, so if I do this a lot I should expect some run-time 
> performance hits (if I call this function a bunch, which isn't an issue in 
> my case).
>
> Cheers,
> Marc
>
> On Wednesday, December 4, 2019 at 6:26:47 PM UTC+1, Jon Zeppieri wrote:
>>
>> On Tue, Dec 3, 2019 at 8:55 PM Ben Greenman  
>> wrote: 
>> > 
>> > The error is because gregor/time doesn't export a struct. But 
>> > nevermind that, because you're probably best off with an opaque type: 
>> > 
>> > ``` 
>> > #lang typed/racket 
>> > 
>> > (require/typed gregor/time 
>> >   [#:opaque Time time?] 
>> >   [time (->* [Integer] [Integer Integer Integer] Time)] 
>> >   [time->iso8601 (-> Time String)]) 
>> > 
>> > (require/typed gregor 
>> >   [current-time (->* [] [#:tz String] Time)]) 
>> > 
>> > (time->iso8601 (current-time)) 
>> > ;; "21:04:25.687808105" 
>> > ``` 
>>
>> Also, most operations on the date/time data structures are generic, 
>> which makes it a bit more complicated to use with typed racket. The 
>> generic predicates, like `time-provider?`, should probably map to 
>> union types, like so (though people like Ben, who are more savvy about 
>> typed racket, might have other ideas): 
>>
>> ``` 
>> #lang typed/racket 
>>
>> (require/typed gregor/time 
>>[#:opaque Time time?] 
>>[time (->* [Integer] [Integer Integer Integer] Time)] 
>>[time->iso8601 (-> Time String)]) 
>>
>> (require/typed gregor 
>>[#:opaque Datetime datetime?] 
>>[datetime (->* [Integer] [Integer Integer Integer 
>> Integer Integer Integer] Datetime)]) 
>>
>> (define-type Time-Provider (U Time Datetime)) 
>>
>> (require/typed gregor 
>>[current-time (->* [] [#:tz String] Time)] 
>>[->hours (-> Time-Provider Integer)]) 
>>
>> (time->iso8601 (current-time)) 
>> (->hours (current-time)) 
>> ``` 
>>
>> Also, if you want to be more specific with your types: 
>> ``` 
>> #lang typed/racket #:with-refinements 
>>
>> (define-type Hour (Refine [n : Integer] (and (>= n 0) (< n 24 
>> (define-type Minute (Refine [n : Integer] (and (>= n 0) (< n 60 
>> (define-type Second (Refine [n : Integer] (and (>= n 0) (< n 60 
>> (define-type Nanosecond (Refine [n : Integer] (and (>= n 0) (< n 
>> 10 
>>
>> (require/typed 
>>  gregor/time 
>>  [#:opaque Time time?] 
>>  [time (->* [Hour] [Minute Second Nanosecond] Time)]) 
>> ``` 
>> ... though this might make the proof obligations too onerous, 
>> depending on how you're using the library. 
>>
>> - Jon 
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/10a47274-6a9c-4cc6-b554-05a286531f9f%40googlegroups.com.


Re: [racket-users] How to use dates (especially gregor) with Typed Racket?

2019-12-07 Thread Marc Kaufmann
Thanks Ben and Jon, that did the trick. 

I realized when following the code that the structure wasn't exported - but 
I didn't know how to work around that. I now also checked the 
documentation, and the only thing I found on opaque types is 
https://docs.racket-lang.org/ts-reference/special-forms.html?q=opaque#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._require%2Ftyped%29%29.
 
What it says about opaque types is:

"Opaque types must be required lexically before they are used."

followed by an example that is even now non-trivial for me to parse and 
figure out. (I started going down the rabbit hole when the `->` was not 
used in the first position of the definition, nor written as `. -> .` Turns 
out types can be defined via infix notation, which is nice but unexpected.)

So there are two questions: 

1. What does #:opaque do?
2. How could I have found that out by searching - or essentially the way to 
do it was "Email the list". If the latter, that's fine, the email list is 
very helpful and it would be good to add some additional explanation of 
opaque types to the documentation of `require-typed`, and possibly even to 
the typed racket reference. Probably the part talking about typed-racket 
untyped racket interaction.

Let me try answering my first question: #:opaque defines a new type via a 
predicate function -- here `time?` -- that is being imported (can I use it 
without require-typed? I guess there would be no point, but I haven't 
thought this through). This is not based on the usual type constructors 
using other types, but based on whether a thing returns `#true` when passed 
to the predicate, in my case `time?`. I assume this means that the type is 
verified via contracts, so if I do this a lot I should expect some run-time 
performance hits (if I call this function a bunch, which isn't an issue in 
my case).

Cheers,
Marc

On Wednesday, December 4, 2019 at 6:26:47 PM UTC+1, Jon Zeppieri wrote:
>
> On Tue, Dec 3, 2019 at 8:55 PM Ben Greenman  > wrote: 
> > 
> > The error is because gregor/time doesn't export a struct. But 
> > nevermind that, because you're probably best off with an opaque type: 
> > 
> > ``` 
> > #lang typed/racket 
> > 
> > (require/typed gregor/time 
> >   [#:opaque Time time?] 
> >   [time (->* [Integer] [Integer Integer Integer] Time)] 
> >   [time->iso8601 (-> Time String)]) 
> > 
> > (require/typed gregor 
> >   [current-time (->* [] [#:tz String] Time)]) 
> > 
> > (time->iso8601 (current-time)) 
> > ;; "21:04:25.687808105" 
> > ``` 
>
> Also, most operations on the date/time data structures are generic, 
> which makes it a bit more complicated to use with typed racket. The 
> generic predicates, like `time-provider?`, should probably map to 
> union types, like so (though people like Ben, who are more savvy about 
> typed racket, might have other ideas): 
>
> ``` 
> #lang typed/racket 
>
> (require/typed gregor/time 
>[#:opaque Time time?] 
>[time (->* [Integer] [Integer Integer Integer] Time)] 
>[time->iso8601 (-> Time String)]) 
>
> (require/typed gregor 
>[#:opaque Datetime datetime?] 
>[datetime (->* [Integer] [Integer Integer Integer 
> Integer Integer Integer] Datetime)]) 
>
> (define-type Time-Provider (U Time Datetime)) 
>
> (require/typed gregor 
>[current-time (->* [] [#:tz String] Time)] 
>[->hours (-> Time-Provider Integer)]) 
>
> (time->iso8601 (current-time)) 
> (->hours (current-time)) 
> ``` 
>
> Also, if you want to be more specific with your types: 
> ``` 
> #lang typed/racket #:with-refinements 
>
> (define-type Hour (Refine [n : Integer] (and (>= n 0) (< n 24 
> (define-type Minute (Refine [n : Integer] (and (>= n 0) (< n 60 
> (define-type Second (Refine [n : Integer] (and (>= n 0) (< n 60 
> (define-type Nanosecond (Refine [n : Integer] (and (>= n 0) (< n 
> 10 
>
> (require/typed 
>  gregor/time 
>  [#:opaque Time time?] 
>  [time (->* [Hour] [Minute Second Nanosecond] Time)]) 
> ``` 
> ... though this might make the proof obligations too onerous, 
> depending on how you're using the library. 
>
> - Jon 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/41fc9b03-81e0-4062-b7da-253d7348ce29%40googlegroups.com.


Re: [racket-users] Day 7 Advent of Code - continuations?

2019-12-07 Thread wanderley.guimar...@gmail.com
I solved the problem without continuations but I will study them and
rewrite my solution to use them. It might be helpful in future problems.

On Fri, Dec 6, 2019 at 11:58 PM Daniel Prager 
wrote:

> Does anyone have a continuation-based solution to AoC day 7?
>
> https://adventofcode.com/2019/day/7
>
> I don't normally use continuations, and I solved today's puzzles without
> them, but part 2 looks to me like it might have yielded ;-) a more elegant
> solution.
>
> Dan
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/CAFKxZVUHTL3ommwabYEBsYq3WgpDHkgF21HhqaigR-pFXL%2B2iw%40mail.gmail.com
> 
> .
>
-- 
Abraço,
Wanderley Guimarães

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAAmHZoePwLgSoA5OPLDJoEhid9fVFpQ011BLs%2BHKUM1NO8wq9A%40mail.gmail.com.