electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks
 RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in  Chat RoomChat Room 
 Forum index » DIY Hardware and Software » Csound
Cut-n-Paste F-tables?
Post new topic   Reply to topic
Page 1 of 1 [8 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
jbeuckm



Joined: Nov 30, 2008
Posts: 165
Location: Stockholm
Audio files: 9

PostPosted: Thu Apr 30, 2015 9:59 pm    Post subject: Cut-n-Paste F-tables? Reply with quote  Mark this post and the followings unread

I'm trying to generate a few tables by trimming and offsetting parts of a sine, but I don't see how to do it yet.

Here are the tables:

Posted Image, might have been reduced in size. Click Image to view fullscreen.
Back to top
View user's profile Send private message
blue hell
Site Admin


Joined: Apr 03, 2004
Posts: 24079
Location: The Netherlands, Enschede
Audio files: 278
G2 patch files: 320

PostPosted: Fri May 01, 2015 2:56 am    Post subject: Reply with quote  Mark this post and the followings unread

Untested .. but this would be the idea I guess?


W1 :: y = sin(2.pi.x);

W2 :: y = if x < pi/2
then x - sin(2.pi.x)
else if x < 3.pi/2
then ( pi - x) - sin(2.pi.x)
else 2.pi + x - sin(2.pi.x);

W3 :: y = if x < pi
then sin(2.pi.x)
else 0;

W4 :: y = if x < pi
then W2
else 0;

W5 :: y = if x < pi
then sin(4.pi.x)
else 0;
W6 :: y = if x < pi/4
then x - sin(4.pi.x)
else if x < 3.pi/4
then ( pi/2 - x) - sin(4.pi.x)
else if x < pi
then pi + x - sin(4.pi.x)
else 0;

W7 :: y = if x < pi
then abs( sin(4.pi.x))
else 0;

W8 :: y = if x < pi
then abs( W6)
else 0;


I probably made some mistakes ...

_________________
Jan
also .. could someone please turn down the thermostat a bit.
Posted Image, might have been reduced in size. Click Image to view fullscreen.
Back to top
View user's profile Send private message Visit poster's website
jbeuckm



Joined: Nov 30, 2008
Posts: 165
Location: Stockholm
Audio files: 9

PostPosted: Fri May 01, 2015 5:49 am    Post subject: Reply with quote  Mark this post and the followings unread

That looks like a good pass at the math. What I haven't figured out is how to get these into CSound f-tables.

For instance, the below will generate the correct W5 in f5:


f10 0 8192 10 1
f5 0 8192 18 10 1 0 4095

What about the rest?
Back to top
View user's profile Send private message
jbeuckm



Joined: Nov 30, 2008
Posts: 165
Location: Stockholm
Audio files: 9

PostPosted: Fri May 01, 2015 6:38 am    Post subject: Reply with quote  Mark this post and the followings unread

This looks like a good resource for manual table generation: http://www.csounds.com/journal/issue12/genInstruments.html
Back to top
View user's profile Send private message
blue hell
Site Admin


Joined: Apr 03, 2004
Posts: 24079
Location: The Netherlands, Enschede
Audio files: 278
G2 patch files: 320

PostPosted: Fri May 01, 2015 6:47 am    Post subject: Reply with quote  Mark this post and the followings unread

oh oops .. I had missed the CSound header here .. sorry ... the link seems useful, yes.
_________________
Jan
also .. could someone please turn down the thermostat a bit.
Posted Image, might have been reduced in size. Click Image to view fullscreen.
Back to top
View user's profile Send private message Visit poster's website
jbeuckm



Joined: Nov 30, 2008
Posts: 165
Location: Stockholm
Audio files: 9

PostPosted: Fri May 01, 2015 8:57 am    Post subject: Reply with quote  Mark this post and the followings unread

This works great. Here is an opcode that generates the table for W3:

Code:

opcode GEN_W3, i, 0

    isize = ftlen(1)
    i_index = 0
    i_half_length = isize / 2

    iout_table  ftgen 0, 0, isize, 10, 1

    loop_start:

        iwrite_value = 0

        if (i_index < i_half_length) then
           iwrite_value tab_i i_index, 1
        endif

        tabw_i iwrite_value, i_index, iout_table

    loop_lt i_index, 1, isize, loop_start

    xout iout_table
endop
Back to top
View user's profile Send private message
jbeuckm



Joined: Nov 30, 2008
Posts: 165
Location: Stockholm
Audio files: 9

PostPosted: Fri May 01, 2015 3:20 pm    Post subject: Reply with quote  Mark this post and the followings unread

Here are the rest. I think they are okay but I get a segmentation fault when I try to display W2.

https://github.com/jbeuckm/CSound-TX81Z
Back to top
View user's profile Send private message
Sinusoidal



Joined: Jul 06, 2015
Posts: 3
Location: Chungju, South Korea

PostPosted: Mon Jul 06, 2015 11:24 pm    Post subject: Reply with quote  Mark this post and the followings unread

You could also use GEN 19 to generate DC-offset, phased, partial waveforms and then splice them together with GEN 18.

This makes W2 in Ftable 5

f1 0 8192 -19 0.25 1 0 -1
f2 0 8192 -19 0.25 1 0.25 -1
f3 0 8192 -19 0.25 1 0.5 1
f4 0 8192 -19 0.25 1 0.75 1
f5 0 8192 -18 4 1 0 2047 3 1 2048 4095 2 1 4096 6143 1 1 6143 8191

At least it should. I didn't try it out.

You can also make the rest of the waveforms with GEN 18 using those first four partials.

Edit: Tested it. GEN 19 uses degrees for phase instead of 0-1. So, replace those 0, 0.25, 0.5, 0.75 with 0, 90, 180, 270.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic
Page 1 of 1 [8 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
 Forum index » DIY Hardware and Software » Csound
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Forum with support of Syndicator RSS
Powered by phpBB © 2001, 2005 phpBB Group
Copyright © 2003 through 2009 by electro-music.com - Conditions Of Use