Csound Csound-dev Csound-tekno Search About

[Csnd] Hex Beats

Date2017-10-20 17:26
FromSteven Yi
Subject[Csnd] Hex Beats
Attachmentslive0.csd  
Hi All,

I thought I'd mention a blog post I wrote about using Hexadecimal values to notate beat patterns:

http://kunstmusik.com/2017/10/20/hex-beats/

The UDO for the hex pattern is pretty simple:

opcode hexbeat, i, Si
    Spat, ibeat xin

    ;; prepend 0x so that strol interpets as hex
    ibeatPat = strtol(strcat("0x", Spat))
    ;; 4 bits/beats per hex value
    ipatlen = strlen(Spat) * 4
    ;; ensure index is within pattern length
    indx = (ibeat % ipatlen)

    ;; bit shift/mask to check if onset or not
    xout (ibeatPat >> (ipatlen - indx - 1)) & 1

endop

and it works by taking hex strings like "f0f0" and treating it as binary like "1111000011110000" and then using that to determine if a note should fire or not.  

The blog post has further information and an example CSD.  (I've attached the CSD here as well). 


Cheers!
steven

 
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2017-10-20 20:28
FromRory Walsh
SubjectRe: [Csnd] Hex Beats
Generation hex. Cool. 

On 20 Oct 2017 5:26 p.m., "Steven Yi" <stevenyi@gmail.com> wrote:
Hi All,

I thought I'd mention a blog post I wrote about using Hexadecimal values to notate beat patterns:

http://kunstmusik.com/2017/10/20/hex-beats/

The UDO for the hex pattern is pretty simple:

opcode hexbeat, i, Si
    Spat, ibeat xin

    ;; prepend 0x so that strol interpets as hex
    ibeatPat = strtol(strcat("0x", Spat))
    ;; 4 bits/beats per hex value
    ipatlen = strlen(Spat) * 4
    ;; ensure index is within pattern length
    indx = (ibeat % ipatlen)

    ;; bit shift/mask to check if onset or not
    xout (ibeatPat >> (ipatlen - indx - 1)) & 1

endop

and it works by taking hex strings like "f0f0" and treating it as binary like "1111000011110000" and then using that to determine if a note should fire or not.  

The blog post has further information and an example CSD.  (I've attached the CSD here as well). 


Cheers!
steven

 
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2017-10-20 22:22
FromGuillermo Senna
SubjectRe: [Csnd] Hex Beats
I was planning on writing my own UDO for that, but what the hex... I'll
just use Steven's.


On 20/10/17 16:28, Rory Walsh wrote:
> Generation hex. Cool.
>
> On 20 Oct 2017 5:26 p.m., "Steven Yi"  wrote:
>
>> Hi All,
>>
>> I thought I'd mention a blog post I wrote about using Hexadecimal values
>> to notate beat patterns:
>>
>> http://kunstmusik.com/2017/10/20/hex-beats/
>>
>> The UDO for the hex pattern is pretty simple:
>>
>> opcode hexbeat, i, Si
>>     Spat, ibeat xin
>>
>>     ;; prepend 0x so that strol interpets as hex
>>     ibeatPat = strtol(strcat("0x", Spat))
>>     ;; 4 bits/beats per hex value
>>     ipatlen = strlen(Spat) * 4
>>     ;; ensure index is within pattern length
>>     indx = (ibeat % ipatlen)
>>
>>     ;; bit shift/mask to check if onset or not
>>     xout (ibeatPat >> (ipatlen - indx - 1)) & 1
>>
>> endop
>>
>> and it works by taking hex strings like "f0f0" and treating it as binary
>> like "1111000011110000" and then using that to determine if a note should
>> fire or not.
>>
>> The blog post has further information and an example CSD.  (I've attached
>> the CSD here as well).
>>
>>
>> Cheers!
>> steven
>>
>>
>> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/
>> cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/
>> csound/issues Discussions of bugs and features can be posted here
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>         https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here
>

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2017-10-20 22:56
FromRory Walsh
SubjectRe: [Csnd] Hex Beats
Well played Sir 😊

On 20 Oct 2017 10:23 p.m., "Guillermo Senna" <gsenna@gmail.com> wrote:
I was planning on writing my own UDO for that, but what the hex... I'll
just use Steven's.


On 20/10/17 16:28, Rory Walsh wrote:
> Generation hex. Cool.
>
> On 20 Oct 2017 5:26 p.m., "Steven Yi" <stevenyi@gmail.com> wrote:
>
>> Hi All,
>>
>> I thought I'd mention a blog post I wrote about using Hexadecimal values
>> to notate beat patterns:
>>
>> http://kunstmusik.com/2017/10/20/hex-beats/
>>
>> The UDO for the hex pattern is pretty simple:
>>
>> opcode hexbeat, i, Si
>>     Spat, ibeat xin
>>
>>     ;; prepend 0x so that strol interpets as hex
>>     ibeatPat = strtol(strcat("0x", Spat))
>>     ;; 4 bits/beats per hex value
>>     ipatlen = strlen(Spat) * 4
>>     ;; ensure index is within pattern length
>>     indx = (ibeat % ipatlen)
>>
>>     ;; bit shift/mask to check if onset or not
>>     xout (ibeatPat >> (ipatlen - indx - 1)) & 1
>>
>> endop
>>
>> and it works by taking hex strings like "f0f0" and treating it as binary
>> like "1111000011110000" and then using that to determine if a note should
>> fire or not.
>>
>> The blog post has further information and an example CSD.  (I've attached
>> the CSD here as well).
>>
>>
>> Cheers!
>> steven
>>
>>
>> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/
>> cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/
>> csound/issues Discussions of bugs and features can be posted here
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>         https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here
>

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2017-10-21 06:34
FromSteven Yi
SubjectRe: [Csnd] Hex Beats
BTW: I made a fix to the code.  Turns out notating more than 8 beats would be problematic due to floating point and mantissa and MYFLT size and things.  I rewrote the code to only require converting one hex value and indexing within the 4 bits of that:

opcode hexbeat, i, Si
  Spat, ibeat xin

  ;; 4 bits/beats per hex value
  ipatlen = strlen(Spat) * 4
  ;; get beat within pattern length
  ibeat = ibeat % ipatlen
  ;; figure which hex value to use from string
  ipatidx = int(ibeat / 4)
  ;; figure out which bit from hex to use
  ibitidx = ibeat % 4 
  
  ;; convert individual hex from string to decimal/binary
  ibeatPat = strtol(strcat("0x", strsub(Spat, ipatidx, ipatidx + 1))) 

  ;; bit shift/mask to check onset from hex's bits
  xout (ibeatPat >> (3 - ibitidx)) & 1 

endop
I have some plans now to develop the work into a basic library for live coding. The idea is that one could start a new CSD, #include the livecode.orc file, then have things setup where one would have things like hexbeat(), set_tempo() already defined, and a number of skeleton performance instruments already pre-defined that one could then just re-define and get going.  The plan is to write an introductory guide to live coding with Csound using this library. 

The live web version is currently hosted at:


and the source code is at:



Some notes:

1. I plan to make the Web Version setup and ready to live code within the browser. Everyone is welcome to take the project and reuse the code to make your own web Csound editor/runner with your own Csound library/startup code. 

2. If you load the page, you can select the entire text and press ctrl-e to evaluate the code. if you select text and press ctrl-e, it will evaluate the selection. (Try modifying the hexbeat strings to something like "f0f0", or "f

3. The livecode.orc will be usable for livecoding in other editor/contexts (i.e., Vim and Desktop Csound).  See how live0.csd is now in the github project for ideas.

4. The project has the start of a Codemirror Mode for Csound code, based on Codemirror's Ruby mode.  I'll plan to contribute any further changes to that mode within this repository.

Thanks!
steven




On Fri, Oct 20, 2017 at 5:56 PM, Rory Walsh <rorywalsh@ear.ie> wrote:
Well played Sir 😊

On 20 Oct 2017 10:23 p.m., "Guillermo Senna" <gsenna@gmail.com> wrote:
I was planning on writing my own UDO for that, but what the hex... I'll
just use Steven's.


On 20/10/17 16:28, Rory Walsh wrote:
> Generation hex. Cool.
>
> On 20 Oct 2017 5:26 p.m., "Steven Yi" <stevenyi@gmail.com> wrote:
>
>> Hi All,
>>
>> I thought I'd mention a blog post I wrote about using Hexadecimal values
>> to notate beat patterns:
>>
>> http://kunstmusik.com/2017/10/20/hex-beats/
>>
>> The UDO for the hex pattern is pretty simple:
>>
>> opcode hexbeat, i, Si
>>     Spat, ibeat xin
>>
>>     ;; prepend 0x so that strol interpets as hex
>>     ibeatPat = strtol(strcat("0x", Spat))
>>     ;; 4 bits/beats per hex value
>>     ipatlen = strlen(Spat) * 4
>>     ;; ensure index is within pattern length
>>     indx = (ibeat % ipatlen)
>>
>>     ;; bit shift/mask to check if onset or not
>>     xout (ibeatPat >> (ipatlen - indx - 1)) & 1
>>
>> endop
>>
>> and it works by taking hex strings like "f0f0" and treating it as binary
>> like "1111000011110000" and then using that to determine if a note should
>> fire or not.
>>
>> The blog post has further information and an example CSD.  (I've attached
>> the CSD here as well).
>>
>>
>> Cheers!
>> steven
>>
>>
>> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/
>> cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/
>> csound/issues Discussions of bugs and features can be posted here
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>         https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here
>

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2017-10-23 13:46
FromHlöðver Sigurðsson
SubjectRe: [Csnd] Hex Beats
hehe I like! Very nice

On 21 October 2017 at 07:34, Steven Yi <stevenyi@gmail.com> wrote:
BTW: I made a fix to the code.  Turns out notating more than 8 beats would be problematic due to floating point and mantissa and MYFLT size and things.  I rewrote the code to only require converting one hex value and indexing within the 4 bits of that:

opcode hexbeat, i, Si
  Spat, ibeat xin

  ;; 4 bits/beats per hex value
  ipatlen = strlen(Spat) * 4
  ;; get beat within pattern length
  ibeat = ibeat % ipatlen
  ;; figure which hex value to use from string
  ipatidx = int(ibeat / 4)
  ;; figure out which bit from hex to use
  ibitidx = ibeat % 4 
  
  ;; convert individual hex from string to decimal/binary
  ibeatPat = strtol(strcat("0x", strsub(Spat, ipatidx, ipatidx + 1))) 

  ;; bit shift/mask to check onset from hex's bits
  xout (ibeatPat >> (3 - ibitidx)) & 1 

endop
I have some plans now to develop the work into a basic library for live coding. The idea is that one could start a new CSD, #include the livecode.orc file, then have things setup where one would have things like hexbeat(), set_tempo() already defined, and a number of skeleton performance instruments already pre-defined that one could then just re-define and get going.  The plan is to write an introductory guide to live coding with Csound using this library. 

The live web version is currently hosted at:


and the source code is at:



Some notes:

1. I plan to make the Web Version setup and ready to live code within the browser. Everyone is welcome to take the project and reuse the code to make your own web Csound editor/runner with your own Csound library/startup code. 

2. If you load the page, you can select the entire text and press ctrl-e to evaluate the code. if you select text and press ctrl-e, it will evaluate the selection. (Try modifying the hexbeat strings to something like "f0f0", or "f

3. The livecode.orc will be usable for livecoding in other editor/contexts (i.e., Vim and Desktop Csound).  See how live0.csd is now in the github project for ideas.

4. The project has the start of a Codemirror Mode for Csound code, based on Codemirror's Ruby mode.  I'll plan to contribute any further changes to that mode within this repository.

Thanks!
steven




On Fri, Oct 20, 2017 at 5:56 PM, Rory Walsh <rorywalsh@ear.ie> wrote:
Well played Sir 😊

On 20 Oct 2017 10:23 p.m., "Guillermo Senna" <gsenna@gmail.com> wrote:
I was planning on writing my own UDO for that, but what the hex... I'll
just use Steven's.


On 20/10/17 16:28, Rory Walsh wrote:
> Generation hex. Cool.
>
> On 20 Oct 2017 5:26 p.m., "Steven Yi" <stevenyi@gmail.com> wrote:
>
>> Hi All,
>>
>> I thought I'd mention a blog post I wrote about using Hexadecimal values
>> to notate beat patterns:
>>
>> http://kunstmusik.com/2017/10/20/hex-beats/
>>
>> The UDO for the hex pattern is pretty simple:
>>
>> opcode hexbeat, i, Si
>>     Spat, ibeat xin
>>
>>     ;; prepend 0x so that strol interpets as hex
>>     ibeatPat = strtol(strcat("0x", Spat))
>>     ;; 4 bits/beats per hex value
>>     ipatlen = strlen(Spat) * 4
>>     ;; ensure index is within pattern length
>>     indx = (ibeat % ipatlen)
>>
>>     ;; bit shift/mask to check if onset or not
>>     xout (ibeatPat >> (ipatlen - indx - 1)) & 1
>>
>> endop
>>
>> and it works by taking hex strings like "f0f0" and treating it as binary
>> like "1111000011110000" and then using that to determine if a note should
>> fire or not.
>>
>> The blog post has further information and an example CSD.  (I've attached
>> the CSD here as well).
>>
>>
>> Cheers!
>> steven
>>
>>
>> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/
>> cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/
>> csound/issues Discussions of bugs and features can be posted here
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>         https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here
>

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here