Cabbage Logo
Back to Cabbage Site

Loading samples (was Backgroundcolour not working)

I’m just trying to use a signaldisplay, and when I type backgroundcolour it doesn’t turn red like colour does. The display also doesn’t show up when I run the instrument, and I think this might be why.

Looks there is an issue there, I can’t seem to get the background colour to work here either. I’ll take a look. But I was able to get the signaldisplay widget to show up and display some signals. Did you try the example in the Misc example menu?

Hi @arcanom. I fixed the background colour issue. Were you able to get this widget to work? Let me know if not and I will post a simple example.

If you click the artifacts link on the following page you will get new installers for both OSX and Windows. Let me know if they work Ok for you.

Thank you for your help, I’ll make sure to try again soon! However, I won’t be trying again until I figure out how to load samples for a wavetable.

Loads samples into a wavetable, or simply play them back from a wavetable? Did you try teh SampleLoadAndPlayback.csd from the Misc examples? It might be a good start. It loads a bunch of samples to a list of wavetables using the ftsamplebank opcode. It could be done manually too. You can also have a read of this short tutorial.

I’m trying to laod .wav files and use them as wavetables. The problems I’m running into are numbering the tables (I get the message “Invalid ftable no. 1000.000000” when I press a key), playing back single cycles, changing wavetable position and accounting for different lengths, pitches, and pitch changes in the wav files. So far I only know how to load the files, and set up a phasor and a table opcode.

Can you post the code that’s giving you the problems?

giwt1 chnget “wt1”

giFTNL = 1000
giFTNR = 2000

ginumtabL ftsamplebank “C:/Program Files/Csound6_x64/mysamples”, giFTNL, 0, 0, 1
ginumtabR ftsamplebank “C:/Program Files/Csound6_x64/mysamples”, giFTNR, 0, 0, 2

This is supposed to load all the wavetables, and giwt1 should get the number of each file from a combobox. This will be used to select a wavetable later.

iWt1L = giFTNL + giwt1
iWt1R = giFTNR + giwt1

This should set iWt1L and iWt1R to the number of the function table that should be used.

aphase phasor 1, 0

awavL tab aphase, iWt1L, 1
awavR tab aphase, iWt1R, 1

This is supposed to output left and right channel audio signals by reading the table with a phasor. I’m not sure how to get it to read only a specific cycle, but I wanted to figure out the function table number problem first.
I’d also like to know if there is a way to remove pitch changes when loading in a WAV file, or to account for them when reading the function table.

Sorry I took so long to reply.

I think you meant to post this to another thread? Would you mind reposting to the relevant thread?

Actually this is the right thread. You asked for the code that was giving me problems. Sorry for any confusion, but that was the code you asked for.

:joy::joy: My apologies, too many messages and not enough beer makes Rory go :crazy_face: Honestly, I was certain this discussion was part of another thread.

Anyhow, is there any way you could post a complete example? There are many factors that could be preventing this from working correctly, but its hard to tell what it is from the little snippets of code you posted.

vslider bounds (170, 10, 40, 100) channel ("oct"), text("Oct") range(-4, 4, 0, 1, 1)
vslider bounds (200, 10, 40, 100) channel ("semis") text("Semis") range(-12, 12, 0, 1, 1)
vslider bounds (230, 10, 40, 100) channel ("cents") text("Fine") range(-100, 100, 0, 1, 1)
hslider bounds (10, 130, 150, 20) channel ("wtp")  range(0, 1, 0, 1, .001)
combobox bounds (10, 100, 150, 30) channel ("wt1") populate ("*.wav", "C:/Program Files/Csound6_x64/mysamples")
;display


;labels
label bounds (10, 10, 150, 20) align("centre") text("Oscillator 1")

That was all the widgets other than the keyboard and form.

-n -d -+rtmidi=NULL -M0 -m0d --midi-key-cps=4 --midi-velocity-amp=5 --displays

That was everything under CsOptions.

giwt1 chnget “wt1”

giFTNL = 1000
giFTNR = 2000

ginumtabL ftsamplebank “C:/Program Files/Csound6_x64/mysamples”, giFTNL, 0, 0, 1
ginumtabR ftsamplebank “C:/Program Files/Csound6_x64/mysamples”, giFTNR, 0, 0, 2

That was how I tried to load my samples.

instr 1 ;oscillator 1
;get info from sliders
koct chnget “oct”
ksem chnget “semis”
kcen chnget “cents”

;set variables
iFreq = p4
iAmp = p5
kOct = octave(koct)
kSemis = semitone(ksem)
kFine = cent(kcen)

iWt1L = giFTNL + giwt1
iWt1R = giFTNR + giwt1 ; table numbers for the selected wavetable

isize = ftlen(iWt1L)

isecs = 44100/isize ;length of table in seconds

;sound generation

aphase phasor 1, 0 ; phasor for table reading

awavL tab aphase, iWt1L, 1
awavR tab aphase, iWt1R, 1 ; table reading

;mixing voices
aOscL = awavLiAmp
aOscR = awavR
iAmp

;output
outs aOscL, aOscR
endin

That was the instrument in which I tried to play back the samples. Sorry if the code’s hard to read, I’m pretty new at this. Also sorry that it’s so long.

By the way, if you have too many messages, you could take breaks from replying right? For example, you keep replying to this thread surprisingly fast.

I’m a very faster replier of messages, don’t take it personally :rofl: can you simply as the entire .csd file as an attachment for me? Thanks :+1:

First synth.csd (2.0 KB)

Thanks for looking into this.

So it seems that something has broken the ftsamplebank opcode :rage: Anyhow, no worries, we have lots of other options. Attached is an instrument that should do something similar to what you wanted, only instead of loading all function tables in a single move, it simply loads the one it needs for the current note.

First synth.csd (1.9 KB)

Have a look through the file. If there is anything you don’t understand just ask. Btw, don’t forget to change the path back to your sample directory in the combobox declaration. Let me know.

p.s. I fixed that issue in ftsamplebank ( looks like I was the cause of that myself :joy:) It will be available in the next release of Csound, or if you can’t wait, you can grab the latest beta installer for Csound on Windows and use that.

1 Like

Thank you so much! I’ll keep experimenting and see if I’ll be able to figure out the rest of what I need. And sorry for such a late reply.

@rorywalsh where can I get the latest installer for the ftsamplebank fix? or do I have to build?

cheers

I actually created a continuous deployment build for Csound on MacOS. You can find it here. Note that it’s a pretty minimal version, but if you’re not using too many plugin opcodes you should be fine :wink: I wouldn’t go removing your current install. Just rename it, it’s in the system /Library/Frameworks folder.

Thanks Rory, I installed that fine - terminal reports 6.14

However the Misc/SampleLoadAndPlayback example still prints gkNumTables as 0. I also tried the example from the Csound manual, and got the same result.

Bizarro