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 
 Forum index » DIY Hardware and Software » ChucK programming language
WvOut direct to disk or to buffer?
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [10 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
Gear Addict



Joined: Aug 14, 2007
Posts: 6
Location: Chicago/L.A.
Audio files: 1

PostPosted: Mon Nov 16, 2009 3:11 am    Post subject: WvOut direct to disk or to buffer? Reply with quote  Mark this post and the followings unread

Worked on an audio/sensor recording application in Chuck a while back, and had to unfortunately abort using it because there seemed to be a known issue where randomly, samples would drop/be lost while recording (trying to record synchronous audio + sensor data to .wav files).

Recently, I was playing around with Minim in Processing and experienced similar issues when recording directly to disk, although, it seemed to work fine when instead, I specified to record the stream to a buffer, and then write to a file at the end.

Am I wrong in assuming Chuck writes directly to disk? Perhaps we could solve this problem by allowing the option to write to a buffer instead?

Thoughts appreciated!

Jordan

_________________
Jordan H
Gear Addict Clothing

Unique vintage/analog/modular synth shirts and accessories
Back to top
View user's profile Send private message
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 7678
Location: The Hague, NL
G2 patch files: 3

PostPosted: Mon Nov 16, 2009 3:55 am    Post subject: Reply with quote  Mark this post and the followings unread

Hi, Jordan, Welcome on board!


What "known issue" do you mean? I have to say I wasn't aware of one.

_________________
Kassen
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Gear Addict



Joined: Aug 14, 2007
Posts: 6
Location: Chicago/L.A.
Audio files: 1

PostPosted: Mon Nov 16, 2009 4:08 am    Post subject: Reply with quote  Mark this post and the followings unread

Ohh, just in regards to dropping / losing samples... do you experience this also?

Best regards,
Jordan

Edit: I attached a sound file of what I experience (converted to a mp3 to make the file smaller). The code is pretty much identical to rec-auto.ck (http://chuck.cs.princeton.edu/doc/examples/basic/rec-auto.ck) only im using adc instead of dac => Gain g => WvOut w => blackhole; to mimic how I was using WvOut in my larger recording program. For this, I simply played a song in quicktime, set my computer output to soundflower, and set soundflower as my input in ChucK.

You can hear the samples dropping almost immediately, at about 20 seconds, its pretty good until 49 seconds, then it starts dropping again. My buffer was set to 2048, but I experience this at any other buffer size as well.

I guess my question was in regards to how Chuck handles the incoming data, if it writes it directly to disk or if it records the stream to a buffer, and then writes it to disk at the end as I experienced a similar issue in Minim/Java when recording directly to disk, but no issue when recording to a buffer.

Anyway, would be great to know if you experience this also!

Cheers,
J


test.mp3
 Description:

Download
 Filename:  test.mp3
 Filesize:  635.87 KB
 Downloaded:  163 Time(s)


_________________
Jordan H
Gear Addict Clothing

Unique vintage/analog/modular synth shirts and accessories
Back to top
View user's profile Send private message
Inventor
Stream Operator


Joined: Oct 13, 2007
Posts: 5978
Location: San Antonio, Tx, USA
Audio files: 258

PostPosted: Mon Nov 16, 2009 7:46 am    Post subject: Reply with quote  Mark this post and the followings unread

I get this also, but only when recording from the adc. ChucK is strongly timed, meaning that even if your operating system idles it and the audio stutters, it will properly record every single sample just as soon as it gets the CPU again. However, for the case of adc, ChucK cannot listen while your computer denies it CPU. Or at least that's how I imagine it to be. Try shutting down other applications while recording, that may at least help.

It's also well known that ChucK is a real CPU hog, so that may contribute to the problem.

Les

_________________
"Let's make noise for peace." - Kijjaz
Back to top
View user's profile Send private message Send e-mail
Gear Addict



Joined: Aug 14, 2007
Posts: 6
Location: Chicago/L.A.
Audio files: 1

PostPosted: Mon Nov 16, 2009 9:21 am    Post subject: Reply with quote  Mark this post and the followings unread

Thanks for the reply Les. I did a quick test (with all unnecessary applications closed) viewing Activity Monitor while doing the WvOut from adc. While admittedly the tests were not the most "scientific," I logged the time I saw spikes in the writing to disk display. These seemed to correspond with the areas in the outputted file with problems, and when checking other displays in activity monitor (CPU, Memory...etc), there were no signs of spikes or bottlenecks (lots of free memory, I have 4gb and CPU was running super low).

This made me remember that in my original encounter with this issue, I was actually listening to the output while recording from ADC through headphones, which is how I noticed it to begin with. I also had Chuck creating/sounding a metronome, while recording audio+sensor information from people playing an instrument and the metronome would suddenly hiccup and the audio jitter..

It's possible it could be a cpu thing, however, viewing activity monitor, I didn't notice any real hard cpu usage... just the corresponding spikes in hard-drive Data written / sec under Disk Activity. Also, according to Activity Monitor, looking at CPU statistics, %User = 13%-14% while recording, and %system = 4%-5%, with around 80% idle.

hm...
Back to top
View user's profile Send private message
Blue Hell
Site Admin


Joined: Apr 03, 2004
Posts: 20681
Location: The Netherlands, Enschede
Audio files: 156
G2 patch files: 318

PostPosted: Mon Nov 16, 2009 9:55 am    Post subject: Reply with quote  Mark this post and the followings unread

Windows Vista I assume?

I've seen situations where audio buffers of 5 s are not large enough to give proper audio operation under Vista.

_________________
Jan
Back to top
View user's profile Send private message Visit poster's website
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 7678
Location: The Hague, NL
G2 patch files: 3

PostPosted: Mon Nov 16, 2009 11:40 am    Post subject: Reply with quote  Mark this post and the followings unread

Blue Hell wrote:
Windows Vista I assume?


Soundflower is a Mac program for routing audio, more or less like Jack, I think.

I don't think this is a WvOut issue, I think it's a OS scheduling issue. As Les pointed out; WvOut should not give dropouts in saved files for generated sounds, ever. Audio playback may stutter but the stream to HD should be fine.

Of course there may still be issues with ADC (the one source of sound in ChucK that gives non-ChucK-generated realtime sound) when either the soundsource can't generate samples quickly enough or when ChucK can't keep up with processing them. One possible cure would be fidgeting with the relative priorities of ChucK, Quicktime and Soundflower.

_________________
Kassen
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Blue Hell
Site Admin


Joined: Apr 03, 2004
Posts: 20681
Location: The Netherlands, Enschede
Audio files: 156
G2 patch files: 318

PostPosted: Mon Nov 16, 2009 12:14 pm    Post subject: Reply with quote  Mark this post and the followings unread

Kassen wrote:
Soundflower is a Mac program for routing audio


Ah, yes it is, had missed that remark.

_________________
Jan
Back to top
View user's profile Send private message Visit poster's website
Gear Addict



Joined: Aug 14, 2007
Posts: 6
Location: Chicago/L.A.
Audio files: 1

PostPosted: Mon Nov 16, 2009 3:18 pm    Post subject: Reply with quote  Mark this post and the followings unread

It is very interesting that WvOut doesn't seem to exhibit these behaviors when dealing with ChucK generated sound, and only with ADC input.

As a note, when SoundFlowering audio from quicktime into chuck/adc, and listening to the playback of the sound through quicktime, I don't hear any issues while recording, just when listening to the exported file, however, when I listened to the output of chuck (a chuck generated metronome) as it recorded (in my past experiments) I could hear the issues in real-time (metronome would, skip, stop, restart..etc).

Perhaps this is a scheduling / priorities thing as you suggested. Is there any way for me to play around with that?

Kassen wrote:
Blue Hell wrote:
Windows Vista I assume?


Soundflower is a Mac program for routing audio, more or less like Jack, I think.

I don't think this is a WvOut issue, I think it's a OS scheduling issue. As Les pointed out; WvOut should not give dropouts in saved files for generated sounds, ever. Audio playback may stutter but the stream to HD should be fine.

Of course there may still be issues with ADC (the one source of sound in ChucK that gives non-ChucK-generated realtime sound) when either the soundsource can't generate samples quickly enough or when ChucK can't keep up with processing them. One possible cure would be fidgeting with the relative priorities of ChucK, Quicktime and Soundflower.
Back to top
View user's profile Send private message
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 7678
Location: The Hague, NL
G2 patch files: 3

PostPosted: Mon Nov 16, 2009 4:12 pm    Post subject: Reply with quote  Mark this post and the followings unread

Gear Addict wrote:
It is very interesting that WvOut doesn't seem to exhibit these behaviors when dealing with ChucK generated sound, and only with ADC input.


Well, it's not that remarkable. ChucK simply calculates all samples in order. If you simply refuse to calculate sample n+1 before you wrote n to disk you can be sure the file gets written. There are -of course- downsides to this; cpu spikes may take longer to recover from than they would in systems that try to catch up.

I'm not sure what's going wrong here, maybe the samples in question never arrive. It may indicate a error in the way ChucK talks to Soundflower. Did you verify Quicktime, ChucK, the soundcard and Soundflower all run at the same bitrate? I'm not sure those numbers *could* be off, but that could cause issues.


Quote:
As a note, when SoundFlowering audio from quicktime into chuck/adc, and listening to the playback of the sound through quicktime, I don't hear any issues while recording, just when listening to the exported file, however, when I listened to the output of chuck (a chuck generated metronome) as it recorded (in my past experiments) I could hear the issues in real-time (metronome would, skip, stop, restart..etc).


Quite odd. Something as simple as a metronome shouldn't cause that sort of thing. I'm at a loss here. Are these clicks periodic or more random? Does high cpu usage correlate to more clicks/glitches/dropouts? Does this happen with all files played in quicktime or just some?

Quote:
Perhaps this is a scheduling / priorities thing as you suggested. Is there any way for me to play around with that?


I'd imagine so; you would need to adjust the process priority. I'm not sure how to do that on a Mac, I can never find the more serous settings on OSX, but I'm sure some of our friends here can.

_________________
Kassen
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [10 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