electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Articles  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links  |  Store
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 
Live streaming at radio.electro-music.com

  host / artist show at your time

poster

Please visit the chat
 Forum index » DIY Hardware and Software » ChucK programming language
ma
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [2 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
sandydo



Joined: Mar 15, 2017
Posts: 1
Location: Berlin

PostPosted: Wed Mar 15, 2017 8:40 am    Post subject: ma Reply with quote  Mark this post and the followings unread

Hello Chuck programmer,

I have a special wish in working with audio files in Chuck and since I'm new to the language I'm not sure how to succeed.

In particular, I want to interpolate two audio files in the way, that when I have two files, e.g. "violin.wav" and "trumpet.wav" both of the same length let's say. Then I want to create or play a third audio file which is a mixture of both, so that the sample starts as "violin.wav" and end as "trumpet.wav" and in between it should be continuously interpolated...

My idea for this is if we had the two buffer as arrays like:
"violin.wav" -> violinArray =[34,3,43,56,23,67,23,67,54,78,23,54]
"trumpet.wav" -> trumpetArray [32,4,65,65,65,34,65,23,6,76,5,4]

Then I want to create something like.
Code:

int N = violinArray.length;
new array mixtureArray[N];
for (i = 0; i< N; i++)
  {
     mixtureArray[i] = i*violinArray[i] + (N -(i+1))*trumpetArray[i];
  }


But the difficulty for me is to get the data of "violin.wav" and "trumpet.wav" as an array or something similar... Is it even possible to view the real data of a sound buffer??

I fancy every commentary or contribution.

Cheers,
Thomas
Back to top
View user's profile Send private message
Antimon



Joined: Jan 18, 2005
Posts: 4089
Location: Sweden
Audio files: 352
G2 patch files: 100

PostPosted: Wed Apr 26, 2017 7:52 am    Post subject: Reply with quote  Mark this post and the followings unread

While I think it's possible to get an audio file into an array (I can see if I can find an old post on the subject if you like), I would just stream the two files and set envelopes over them.

My ChucK is a bit rusty, and I can't compile and check this, so this will probably riddled with syntax errors and wrong function names, but something like this pseudo code:

Code:
SndBuf trumpet (...);
SndBuf violin(...);

trumpet => Envelope trumpetEnvelope => dac;
violin => Envelope violinEnvelope => dac;

0 => trumpetEnvelope.value;
1 => trumpetEnvelope.target;
10::seconds => trumpetEnvelope.time; // assuming each sound lasts for 10 seconds

1 => violinEnvelope.value;
0 => violinEnvelope.target;
10::seconds => violinEnvelope.time; // assuming each sound lasts for 10 seconds

// start the SndBufs


This should make the violin fade into the trumpet. Once they have started you can (if you want to) look at the actual values on each sound using .last():

Code:
now + 10::seconds => time waitUntil;
while (now < waitUntil) {
    <<< "The values are ", trumpet.last(), violin.last() >>>;
    1::samp => now;
}


There are also ways of generating new sound files in ChucK, you should be able to find information about this in the documentation.

Hope that helps in any way :)

_________________
Antimon's Window
@soundcloud @Flattr home - you can't explain music
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [2 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 » ChucK programming language
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
e-m mkii

Please support our site. If you click through and buy from
our affiliate partners, we earn a small commission.


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