problems loading multiple samples

View: New views
3 Messages — Rating Filter:   Alert me  

problems loading multiple samples

by Neil Cosgrove :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Hi,

I am trying to write a simple Sample Pool to load in multiple samples and play them. (See below).

I'm using     CocoaDialog.getPaths
and then     Buffer.read
to get them in.

this works fine when you are loading 1 sample at a time but when you select say 10 or more at the same time and try to load them supercollider crashs. It also crashes when you try and play them.

Am I doing something wrong?

ndc


SamplePool {

    var server, sample, name, filename, pitch, amp, window, rect, gT, gL, gH, gW, sampleListGUI;
       
    *new { arg server=Server.default;
        ^super.new.init(server);
    }
   
    init {arg ser;
   
        server=ser;       
        rect=Rect(3, 900, 200, 210);
        window = SCWindow.new("",rect);
        window.front;
        window.name="Sample Pool";
        window.view.background = Color(0.4,0.4,0.5);
        //window.userCanClose_(\false);
        sample=[];
        name=[];
        filename=[];
        pitch=[];
        amp=[];
       
        this.createGUI;
           
        server.boot;
       
        ^this
               
    }
   
    createGUI{
   
        sampleListGUI=SCListView.new(window,Rect(10, 15, 91, 180))
        .background_(Color.clear)
        .hiliteColor_(Color.green(alpha:0.6))
        .action_{|v| }
        .items_([])
        ;
       
        SCButton.new(window,Rect(110, 15, 70, 20))    // Add
        .states_([ [ "Add", Color(1.0, 0.0, 0.0, 1.0), Color(0.0, 0.0, 0.0, 1.0) ]])
        .action_{
            this.addSamples;
        };
        //.font_(Font("Helvetica-Bold", 14));
       
        SCButton.new(window,Rect(110, 175, 70, 20))    // Play
        .states_([ [ "Play", Color(0.0, 0.0, 0.0, 1.0), Color(0.0, 1.0, 0.0, 1.0) ]])
        .action_{       
            var i=sampleListGUI.value;
            if ((sample.size>0) && (i<sample.size)) {
                (sample@i).play;   
            };
            sampleListGUI.focus;
           
        };
        //.font_(Font("Helvetica-Bold", 14));   
       
        window.refresh;
   
    }
       
    addSamples {
   
        CocoaDialog.getPaths({ arg paths; //get soundfiles;
           
            this.loadBuffers(paths);       
           
        });
       
        ^this
           
    }
   
    loadBuffers{ arg paths;
   
        var path, buf, sf;
       
        if (paths.size>0) {
       
            path=paths@0;
       
            sf=SoundFile.openRead(path);   // check file is a sound
       
            if (sf.isNil.not) {
               
                sf.close;
               
                buf=Buffer.read(server, path, action: {

                    sample=sample.add(buf);
                    filename=filename.add(path);
                    name=name.add(path.split.pop.asString);
                    pitch=pitch.add(42.0);
                    amp=amp.add(1.0);
                    {sampleListGUI.items_(name);}.defer;
                    paths.removeAt(0);       
                   
                    this.loadBuffers(paths);    // call this method until all sounds loaded
                                                 // this also means the server is loading samples 1 at a time
                   
                });
               
            }{ // else.if not a sound file
           
                paths.removeAt(0);               
                this.loadBuffers(paths);
               
            };   
       
        }
       
    }
   
    getSampleList{
   
        ^sample
   
    }
   
    dump {
   
        "Samples:".postln;
        sample.postln;
        "Names:".postln;
        name.postln;
        "Filenames:".postln;
        filename.postln;
        "Pitch:".postln;
        pitch.postln;
        "Amp:".postln;
        amp.postln;   
       
        ^this
       
    }
   
   
} // end.Sample Pool Object




Invite your Facebook friends to Messenger! Get Started!
_______________________________________________
sc-users mailing list
sc-users@...
http://lists.create.ucsb.edu/mailman/listinfo/sc-users

Re: problems loading multiple samples

by James Harkins-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Try increasing the maxSize argument to getPaths.

If you select more items than maxSize specifies, crashes are likely. But, I'm surprised this happens with just 10 files because the default is 20.

When I have some time, I'll make this more explicit in the help file.
hjh

On May 13, 2008, at 6:14 AM, Neil Cosgrove wrote:

Hi,

I am trying to write a simple Sample Pool to load in multiple samples and play them. (See below).

I'm using     CocoaDialog.getPaths
and then     Buffer.read
to get them in.

this works fine when you are loading 1 sample at a time but when you select say 10 or more at the same time and try to load them supercollider crashs. It also crashes when you try and play them.


: H. James Harkins

: jamshark70@...

: http://www.dewdrop-world.net

.::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..:


"Come said the Muse,

Sing me a song no poet has yet chanted,

Sing me the universal."  -- Whitman



_______________________________________________
sc-users mailing list
sc-users@...
http://lists.create.ucsb.edu/mailman/listinfo/sc-users

Re: problems loading multiple samples

by Neil Cosgrove :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

Hi hjh,

thanks alot, that worked!

i was loading the samples i wanted + other misc files at that got discarded. hence i was going over the default 20 when it looked like it wasn't

cheers

ndc


Date: Tue, 13 May 2008 07:52:57 -0400
To: sc-users@...
From: jamshark70@...
Subject: Re: [sc-users] problems loading multiple samples

Try increasing the maxSize argument to getPaths.

If you select more items than maxSize specifies, crashes are likely. But, I'm surprised this happens with just 10 files because the default is 20.

When I have some time, I'll make this more explicit in the help file.
hjh

On May 13, 2008, at 6:14 AM, Neil Cosgrove wrote:

Hi,

I am trying to write a simple Sample Pool to load in multiple samples and play them. (See below).

I'm using     CocoaDialog.getPaths
and then     Buffer.read
to get them in.

this works fine when you are loading 1 sample at a time but when you select say 10 or more at the same time and try to load them supercollider crashs. It also crashes when you try and play them.


: H. James Harkins

: jamshark70@...

: http://www.dewdrop-world.net

.::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..:


"Come said the Muse,

Sing me a song no poet has yet chanted,

Sing me the universal."  -- Whitman




Get 5GB of online storage for free! Get it Now!
_______________________________________________
sc-users mailing list
sc-users@...
http://lists.create.ucsb.edu/mailman/listinfo/sc-users