[Csnd] fout writing to file in realtime?
Date | 2013-01-12 02:12 |
From | Andrew Ikenberry |
Subject | [Csnd] fout writing to file in realtime? |
Hello All, I am currently using the csound API and trying to write to file using fout but it is taking a long amount of time to complete the processing. I am generating a score event from inside the orchestra and it only writes as much of the file as I tell specify in seconds for the event. It appears to be outputting to file in real time. I am not an expert on this opcode so I am not sure if this is the default behavior. If so, is there another way/opcode to use to write to file offline? I tried setting the default output to write to file and used the opcode out instead of fout but the file system in iOS is strange and I could not retrieve the file after csound finished.
Here's the code: ; READ FROM AUDIO FILE ichnls filenchnls gSFile if (ichnls == 2) then giChnls = 2 ainL, ainR diskin2 gSFile, 1.0, 0.0, 1.0 else giChnls = 1 ainL diskin2 gSFile, 1.0, 0.0, 1.0 ainR = ainL endif aoutL fold ainL, 10 aoutR fold ainR, 10 printf_i "Creating new bit crushed audio file%s\n", 1, "." if (giChnls == 2) then
; WRITE STEREO AUDIO FILE
fout "out.wav", 4, aoutL, aoutR
else ; WRITE MONO AUDIO FILE
fout "out.wav", 4, aoutL
endif
event_i "e", 0, giLength, 0 endin
-Andrew
|
Date | 2013-01-12 08:28 |
From | Marco Oros |
Subject | Re: [Csnd] fout writing to file in realtime? |
Dňa 12. 1. 2013 3:12 Andrew Ikenberry wrote / napísal(a): > Hello All, > > I am currently using the csound API and trying to write to file using > fout but it is taking a long amount of time to complete the > processing. I am generating a score event from inside the orchestra > and it only writes as much of the file as I tell specify in seconds > for the event. It appears to be outputting to file in real time. I am > not an expert on this opcode so I am not sure if this is the default > behavior. If so, is there another way/opcode to use to write to file > offline? I tried setting the default output to write to file and used > the opcode out instead of fout but the file system in iOS is strange > and I could not retrieve the file after csound finished. > Here's the code: > > ; READ FROM AUDIO FILE > > > ichnls filenchnls gSFile > > if (ichnls == 2) then > > giChnls = 2 > > ainL, ainR diskin2 gSFile, 1.0, 0.0, 1.0 > > else > > giChnls = 1 > > ainL diskin2 gSFile, 1.0, 0.0, 1.0 > > ainR = ainL > > endif > > > aoutL fold ainL, 10 > > aoutR fold ainR, 10 > > > printf_i "Creating new bit crushed audio file%s\n", 1, "." > > > if (giChnls == 2) then > > ; WRITE STEREO AUDIO FILE > > fout "out.wav", 4, aoutL, aoutR > > else > > > ; WRITE MONO AUDIO FILE > > fout "out.wav", 4, aoutL > > > endif > > event_i "e", 0, giLength, 0 > > endin > > > -Andrew Hi! I am Marco and I try this file, but your file countains an error of pvoc file. And also, You must also upload Your audio to the message or this pvoc file. Because it doesn't working, I think to Your file. Marco Oros. |
Date | 2013-01-12 08:29 |
From | Marco Oros |
Subject | Re: [Csnd] fout writing to file in realtime? |
Dňa 12. 1. 2013 3:12 Andrew Ikenberry wrote / napísal(a): > Hello All, > > I am currently using the csound API and trying to write to file using > fout but it is taking a long amount of time to complete the > processing. I am generating a score event from inside the orchestra > and it only writes as much of the file as I tell specify in seconds > for the event. It appears to be outputting to file in real time. I am > not an expert on this opcode so I am not sure if this is the default > behavior. If so, is there another way/opcode to use to write to file > offline? I tried setting the default output to write to file and used > the opcode out instead of fout but the file system in iOS is strange > and I could not retrieve the file after csound finished. > Here's the code: > > ; READ FROM AUDIO FILE > > > ichnls filenchnls gSFile > > if (ichnls == 2) then > > giChnls = 2 > > ainL, ainR diskin2 gSFile, 1.0, 0.0, 1.0 > > else > > giChnls = 1 > > ainL diskin2 gSFile, 1.0, 0.0, 1.0 > > ainR = ainL > > endif > > > aoutL fold ainL, 10 > > aoutR fold ainR, 10 > > > printf_i "Creating new bit crushed audio file%s\n", 1, "." > > > if (giChnls == 2) then > > ; WRITE STEREO AUDIO FILE > > fout "out.wav", 4, aoutL, aoutR > > else > > > ; WRITE MONO AUDIO FILE > > fout "out.wav", 4, aoutL > > > endif > > event_i "e", 0, giLength, 0 > > endin > > > -AndrewOh, I am sorry, I made a misstake. |
Date | 2013-01-12 17:07 |
From | Andrew Ikenberry |
Subject | Re: [Csnd] fout writing to file in realtime? |
Sorry I just realized I didn't include all of the code here it is: <CsoundSynthesizer> <CsOptions> -o dac ; WRITE SOUND TO THE HOST AUDIO OUTPUT -+rtmidi=null ; DISABLE THE USE OF ANY REALTIME MIDI PLUGIN -+rtaudio=null ; DISABLE THE USE OF ANY REALTIME AUDIO PLUGIN -d ; SUPPRESS ALL DISPLAYS -+msg_color=0 ; DISABLE MESSAGE ATTRIBUTES --expression-opt ; ENABLE EXPRESSION OPTIMIZATIONS -m0 ; PRINT RAW AMPLITUDES </CsOptions> <CsInstruments> sr = 44100 ksmps = 1 nchnls = 2 0dbfs = 1 gSFile = "foo" giStretch = 0 giLength = 0 giChnls = 0 instr 1
gSFile = p4 ;printf_i "Bit Crushing Audio File\n", 1 ; REDEFINE p3
giLength filelen gSFile ; READ FROM AUDIO FILE ichnls filenchnls gSFile if (ichnls == 2) then giChnls = 2 ainL, ainR diskin2 gSFile, 1.0, 0.0, 1.0 else giChnls = 1 ainL diskin2 gSFile, 1.0, 0.0, 1.0 ainR = ainL endif aoutL fold ainL, 10 aoutR fold ainR, 10 printf_i "Creating new bit crushed audio file%s\n", 1, "." if (giChnls == 2) then
; WRITE STEREO AUDIO FILE
fout "out.wav", 4, aoutL, aoutR
else ; WRITE MONO AUDIO FILE
fout "out.wav", 4, aoutL
endif
event_i "e", 0, giLength, 0 endin
</CsInstruments> <CsScore> </CsScore> </CsoundSynthesizer> -Andrew On Sat, Jan 12, 2013 at 3:29 AM, Marco Oros <marco.oros93@gmail.com> wrote:
|
Date | 2013-01-12 17:25 |
From | Steven Yi |
Subject | Re: [Csnd] fout writing to file in realtime? |
Hi Andrew, I think the issue may not be anything with the opcode, just that you are using -o dac to run in realtime. If you want to run faster than realtime, I think can using -n and no -o dac. (Haven't tried that myself but I assume should work.) steven On Sat, Jan 12, 2013 at 5:07 PM, Andrew Ikenberry |
Date | 2013-01-12 18:30 |
From | Andrew Ikenberry |
Subject | Re: [Csnd] fout writing to file in realtime? |
Hi Steven, Thanks for the response. -n did not affect the performance time. -Andrew On Sat, Jan 12, 2013 at 12:25 PM, Steven Yi <stevenyi@gmail.com> wrote: Hi Andrew, |
Date | 2013-01-12 18:32 |
From | Steven Yi |
Subject | Re: [Csnd] fout writing to file in realtime? |
Could you try "-o test.wav" as a test? That should render to disk for the main audio output and run faster than realtime (or, at least, as fast as your processor can go) On Sat, Jan 12, 2013 at 6:30 PM, Andrew Ikenberry |
Date | 2013-01-12 18:38 |
From | Andrew Ikenberry |
Subject | Re: [Csnd] fout writing to file in realtime? |
Iv'e tried that and it performs as expected but it puts the file in a different location than when using fout. The csd is being run on iOS so I am not sure where the file is being put but when I use -o out.wav I can't find it later even though that's the same name that fout is using for the file. On Sat, Jan 12, 2013 at 1:32 PM, Steven Yi <stevenyi@gmail.com> wrote: Could you try "-o test.wav" as a test? That should render to disk for |
Date | 2013-01-12 19:40 |
From | Steven Yi |
Subject | Re: [Csnd] fout writing to file in realtime? |
Hi Andrew, Could you clarify, when you say "as expected" when running with -o out.wav that it is running faster than realtime? One thing I thought of is that maybe using -n is the right thing, but since on iOS, if you're running with CsoundObj, it may still be in realtime as the setup for CoreAudio is happening somewhat outside of Csound itself. It should be possible to add a separate method to CsoundObj for rendering to disk. If you're comfortable with Obj-C, then you could take a look at modifying runCsound() to try that. Otherwise, perhaps add a request on SourceForge and one of us can take a look, or maybe someone else who has some time to spare at the moment could assist here. Thanks! steven On Sat, Jan 12, 2013 at 6:38 PM, Andrew Ikenberry |
Date | 2013-01-12 20:39 |
From | Andrew Ikenberry |
Subject | Re: [Csnd] fout writing to file in realtime? |
Hi Steven, Yes "as expected" meaning it is faster than realtime. Thanks for that response I will start working on that. I think I should be able to handle it. I will write back with the results. Thanks for your help!!!!!!!
Andrew
On Sat, Jan 12, 2013 at 2:40 PM, Steven Yi <stevenyi@gmail.com> wrote: Hi Andrew, |
Date | 2013-01-12 22:27 |
From | Steven Yi |
Subject | Re: [Csnd] fout writing to file in realtime? |
Good luck! Hopefully that gets you somewhere; if not, I'll probably have more time in a few days to assist more closely. All best, steven On Sat, Jan 12, 2013 at 8:39 PM, Andrew Ikenberry |
Date | 2013-01-20 23:10 |
From | Andrew Ikenberry |
Subject | Re: [Csnd] fout writing to file in realtime? |
Steven, I have been working on this over the past few days. I am a little over my head when it comes to modifying runCsound() but I think that I can solve the problem a much easier way. When I use fout it writes the file fine it just processes in realtime. When I use -o "out.wav" it runs much faster but writes the file in a different location. I am wondering what the difference is between where fout writes to file and where -o writes to file. After looking at the manual it seems that the SFDIR environment variable tells -o where to write to file. I also found the method csoundSetGlobalEnv(const char *name, const char *value); which seems like it would set the variable. I am trying to get csound to write to the current directory so I want to set SFDIR to NULL. My question would be how to specify the first parameter which is of type const char*. Hopefully my line of reasoning is correct here. If I am mistaken about this solution it would be great to get some advice on what to do in runCsound() to get offline processing to happen. Thanks!
Best, Andrew
On Sat, Jan 12, 2013 at 5:27 PM, Steven Yi <stevenyi@gmail.com> wrote: Good luck! Hopefully that gets you somewhere; if not, I'll probably |
Date | 2013-01-21 12:47 |
From | Steven Yi |
Subject | Re: [Csnd] fout writing to file in realtime? |
Hi Andrew, I'm thinking a couple things: * With an app, you know it's file sandbox as to where you'd want things to be written to * I think it'd be best est to avoid fout and use csound's standard -o output, using one CSD per batch-processing process. I think this will make things clearer. * When running with the standard output, specify a fully qualified output file name, using "locationInSandbox" + "someFileName". I'll see if I can put together a small test project now that renders Dr. B's Trapped into the Sandbox. Thanks! steven On Sun, Jan 20, 2013 at 11:10 PM, Andrew Ikenberry |
Date | 2013-01-21 16:05 |
From | Steven Yi |
Subject | Re: [Csnd] fout writing to file in realtime? |
Hi Andrew, It took me longer than expected, but I got something working. Try this: http://www.kunstmusik.com/TrappedGenerator.zip There's just a single button that when you press, it should run trapped and render it into the Documents folder for the app. I imagine after that, you could grab the file through connecting with iTunes? Anyways, the key things here: * I modified CsoundObj to add a startRenderToDisk. It takes a CSD path and an outputfile path. * the runCsoundToDisk method was a bit tricky to figure out. Turns out the code for csoundSetHostAudioIO means csound won't write its output to disk either, assuming the host will handle anything. Makes sense but I didn't pick up on that and took a long while to sort out. * the code that creates the path is in ViewController.m: NSString *csdPath = [[NSBundle mainBundle] pathForResource:@"trapped" ofType:@"csd"]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *localFilePath = [documentsDirectory stringByAppendingPathComponent:@"trapped.wav"]; NSLog(@"OUTPUT: %@", localFilePath); [self.csound startCsoundToDisk:csdPath outputFile:localFilePath]; The path stuff above basically gets the Documents directory for the app, then appends "trapped.wav" to it, then calls csound. I don't have a device at the moment to test (nor an Apple Dev account either...), so I tested in the simulator and it generated the file to the Documents folder. Give that a go and let me know if you have further issues. Thanks! steven On Mon, Jan 21, 2013 at 12:47 PM, Steven Yi |
Date | 2013-01-21 17:33 |
From | "Dr. Richard Boulanger" |
Subject | Re: [Csnd] fout writing to file in realtime? |
Thanks Steven. This is awesome. Looking forward to checking it out on our devices. Thanks so much for these additions to the SDK! Sent from my iPhone. On Jan 21, 2013, at 11:05 AM, Steven Yi |
Date | 2013-01-21 17:35 |
From | Steven Yi |
Subject | Re: [Csnd] fout writing to file in realtime? |
Justt happy to have gotten through it. :) I'm going to add this to the SDK later this week (probably Wednesday). Thanks! steven On Mon, Jan 21, 2013 at 5:33 PM, Dr. Richard Boulanger |
Date | 2013-01-21 17:48 |
From | "Dr. Richard Boulanger" |
Subject | Re: [Csnd] fout writing to file in realtime? |
Steven (and Victor) It was going to be a surprise, but when I fly to Maynooth on Thursday, I will be bringing along, and leaving with you, an iPad3 with Retina display. It is fully loaded, with hundreds of music apps, and Apple Developer Provisioned, under Boulanger Labs, so that you and Victor can share this to test your code with the latest OS. It will also include the Beta versions of csSpectral and Csound Touch which will (hopefully) blow your minds.. They are so powerful and cool. See you soon. Dr. B. PS. I will have my Nexus7 along to show you some of the Boulanger Labs work with Csound for Android too! Sent from my iPhone. On Jan 21, 2013, at 12:35 PM, Steven Yi |
Date | 2013-01-21 18:33 |
From | Andrew Ikenberry |
Subject | Re: [Csnd] fout writing to file in realtime? |
Steven, Thank you so much! That worked perfectly. Having your xcode project helped immensely. Thanks a million!!! Best, Andrew
On Mon, Jan 21, 2013 at 12:48 PM, Dr. Richard Boulanger <rboulanger@berklee.edu> wrote: Steven (and Victor) It was going to be a surprise, but when I fly to Maynooth on Thursday, I will be bringing along, and leaving with you, an iPad3 with Retina display. |
Date | 2013-01-21 18:41 |
From | Steven Yi |
Subject | Re: [Csnd] fout writing to file in realtime? |
Fantastic, glad that's working for you! All best, steven On Mon, Jan 21, 2013 at 6:33 PM, Andrew Ikenberry |
Date | 2013-01-22 10:01 |
From | Victor Lazzarini |
Subject | Re: [Csnd] fout writing to file in realtime? |
Great, we're looking forward to your visit. Victor On 21 Jan 2013, at 17:48, Dr. Richard Boulanger wrote: > Steven (and Victor) It was going to be a surprise, but when I fly to Maynooth on Thursday, I will be bringing along, and leaving with you, an iPad3 with Retina display. > > It is fully loaded, with hundreds of music apps, and Apple Developer Provisioned, under Boulanger Labs, so that you and Victor can share this to test your code with the latest OS. > > It will also include the Beta versions of csSpectral and Csound Touch which will (hopefully) blow your minds.. They are so powerful and cool. > > See you soon. > > Dr. B. > > PS. I will have my Nexus7 along to show you some of the Boulanger Labs work with Csound for Android too! > > Sent from my iPhone. > > On Jan 21, 2013, at 12:35 PM, Steven Yi |
Date | 2013-01-22 10:14 |
From | Richard Dobson |
Subject | Re: [Csnd] fout writing to file in realtime? |
On 21/01/2013 17:48, Dr. Richard Boulanger wrote: > Steven (and Victor) It was going to be a surprise, but when I fly to > Maynooth on Thursday, I will be bringing along, and leaving with you, > an iPad3 with Retina display. ... > It will also include the Beta versions of csSpectral and Csound Touch > which will (hopefully) blow your minds.. They are so powerful and > cool. > I hope csSpectral et al. will be able to run on a humble iPad2. I am still paying for mine, and would be disappointed if it was obsolete already! Richard Dobson |
Date | 2013-01-22 10:40 |
From | Steven Yi |
Subject | Re: [Csnd] fout writing to file in realtime? |
+1 looking forward to seeing all the latest, especially on Android! :) On Tue, Jan 22, 2013 at 10:01 AM, Victor Lazzarini |
Date | 2013-01-22 14:44 |
From | Richard Boulanger |
Subject | Re: [Csnd] fout writing to file in realtime? |
Richard, It runs on the iPad2. Wait until you see/hear "all" that is has "running" in it! 20FX instruments; PLUS 11SS (StreamingSpectral) instruments; PLUS 10OLP (OffLineProcessing) instruments; plus some fantastic 3D spectral displays and other goodies - like a nice Audio Editor and extended Import and Export capabilities. -------------------------------- Dr. Richard Boulanger ----------------------------------- On Jan 22, 2013, at 5:14 AM, Richard Dobson <richarddobson@blueyonder.co.uk> wrote: On 21/01/2013 17:48, Dr. Richard Boulanger wrote:Steven (and Victor) It was going to be a surprise, but when I fly to... |
Date | 2013-01-22 14:57 |
From | Anders Genell |
Subject | Re: [Csnd] fout writing to file in realtime? |
Jeez, Dr B! You are dangling these goodies just in front of our eyes - I can't bare it much longer! ...got... ...to... ...synthesize... ...on... ...my... ....iPad! Excuse me while I run off to take an ice cold shower. Regards, /Anderd
|
Date | 2013-01-22 15:05 |
From | Richard Boulanger |
Subject | Re: [Csnd] fout writing to file in realtime? |
Anderd, We are working now on MIDI learn... on some additional "displays".... on some extra input and output processing.... tweeking the instruments... polishing the interface.... but we are getting very close now to submitting csSpectral to Apple for approval. It's a very special app for sure. I have a great time of students and alumni working on it here at Berklee. They are awesome and the soul in this machine. You will get to know them all when we release the app. -dB -------------------------------- Dr. Richard Boulanger ----------------------------------- On Jan 22, 2013, at 9:57 AM, Anders Genell <anders.genell@gmail.com> wrote:
|