# Expand the tablesize with silence

**URL:** <https://forum.csound.com/t/expand-the-tablesize-with-silence/678>\
**Category:** General\
**Created:** [February 14, 2022, 11:44am UTC](https://forum.csound.com/t/expand-the-tablesize-with-silence/678 "2022-02-14T11:44:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tjingboem](https://forum.csound.com/user_avatar/forum.csound.com/tjingboem/32/44_2.png) [@tjingboem](https://forum.csound.com/u/tjingboem)\
**Post date:** [February 14, 2022, 11:44am UTC](https://forum.csound.com/t/expand-the-tablesize-with-silence/678/1 "2022-02-14T11:44:09Z")

</div>

Hello, i have a question:

Using the flooper2 opcode, i have this sample that i like.  
But, sometimes i’d like, while flooper2 is looping, to add some silence (so: zeroes) at the end of the sample before it loops. That will add some space in the repetitions.  
It would be great if this was possible at k rate, but first i was investigating at i rate.

I’ve tried to get this working inside a UDO:

```
opcode samplesilence,i,S

```

Sfile xin  
itable chnget Sfile  
ilen tableng itable  
ilen \*= 20  
itable ftgen 0, 0, 0, 1, Sfile, 0, 0, 0  
chnset itable, Sfile  
xout itable  
endop

but I get all clicks and stutters.  
What could be a solution for this?

PS. probably the easiest wouls be to add a second of silence to all samples…?

---

<div class="post-metadata">

**Author:** ![rory](https://forum.csound.com/user_avatar/forum.csound.com/rory/32/7_2.png) [@rory](https://forum.csound.com/u/rory)\
**Post date:** [February 14, 2022, 3:02pm UTC](https://forum.csound.com/t/expand-the-tablesize-with-silence/678/2 "2022-02-14T15:02:49Z")

</div>

`ilen` is not being used? But is the idea to set the table to be larger than the number of samples in the waveform? If you put this into a UDO and read from the table using any one of the table reading opcodes, it would be quite simple.

```csound
opcode PlayWithSilence, a, ik
    iTable, kSilence xin ;table number, silence in seconds..
    kCanPlay init 1
    iLen ftlen iTable
    kIndex init 0
    setksmps 1

    if kCanPlay == 1 then
        aSig tab kIndex, iTable
        kIndex = (kIndex < iLen ? kIndex+1 : 0) 
    else
        aSig = 0
    endif

    if(kIndex == iLen-1) then
        kCanPlay = sr*kSilence 
        kIndex = 0
    endif

    kCanPlay = (kCanPlay > 1 ? kCanPlay-1 : 1)
    xout aSig
endop

```

---

<div class="post-metadata">

**Author:** ![tjingboem](https://forum.csound.com/user_avatar/forum.csound.com/tjingboem/32/44_2.png) [@tjingboem](https://forum.csound.com/u/tjingboem)\
**Post date:** [February 14, 2022, 6:44pm UTC](https://forum.csound.com/t/expand-the-tablesize-with-silence/678/3 "2022-02-14T18:44:23Z")

</div>

Thanks, Rory, your solution is not exactly what i need, but it helps me thinking.  
What i need is an ftable number or name for flooper2 to read. And sometimes i want this ftable to be bigger and then filled with zeroes.

I’d like to ponder on this some more, because the output now is aSig and not an itable. For sure the same technique can be applied, but this area is definitely not my forte…if i can’t wrap my head around it in a few days, i’d like to ask you once to the rescue…

---

<div class="post-metadata">

**Author:** ![piripero013](https://forum.csound.com/user_avatar/forum.csound.com/piripero013/32/186_2.png) [@piripero013](https://forum.csound.com/u/piripero013)\
**Post date:** [April 11, 2022, 2:56pm UTC](https://forum.csound.com/t/expand-the-tablesize-with-silence/678/4 "2022-04-11T14:56:30Z")

</div>

This is a diy solution, I just added some zeros after the file length. You can adjust the silence length at your pleasure by changing _isilence_ variable.

```csound
instr Tbl
	Sound = "pm_test.wav" //name of your file here
	ifileLen_smpls = filelen(Sound)*sr
	isilence = sr*1.5 //1.5 secs of silence
	itabLen = ifileLen_smpls+isilence
	itbl ftgen 0,0,itabLen,1,Sound,0,0,0

```

```
;adding silence
ksmpl = ifileLen_smpls+1
while ksmpl<itabLen do
	tablew 0,ksmpl,itbl
	ksmpl += 1
od

aIdx = phasor(1/p3)
aSig = table3:a(aIdx,itbl,1)

	outs aSig, aSig

```

endin

```csound

```
