initialize a buffer with a cycle of waveform - stored waveform too short

gianmaria allibrante's icon

Hello, i tring to generate a single cycle of cosine and to store it inside a bufffer (the puropose is to use this buffer as oscillator as wavetable), but inside the buffer the cycle stored is always too short, im unable to fit the enitre buffer with a single cycle,
As you can see from the displayed buffer (4096 samples) the wave form is always up to 20 times short then what i need,

Thanks for support

{
	"boxes" : [ 		{
			"box" : 			{
				"maxclass" : "newobj",
				"text" : "print COS_VAL",
				"numinlets" : 1,
				"patching_rect" : [ 461.0, 567.0, 90.0, 20.0 ],
				"numoutlets" : 0,
				"id" : "obj-3"
			}

		}
, 		{
			"box" : 			{
				"maxclass" : "newobj",
				"text" : "uzi 4096",
				"numinlets" : 2,
				"patching_rect" : [ 461.0, 374.0, 54.0, 20.0 ],
				"numoutlets" : 3,
				"outlettype" : [ "bang", "bang", "int" ],
				"id" : "obj-4"
			}

		}
, 		{
			"box" : 			{
				"maxclass" : "newobj",
				"text" : "buffer~ wavetable6 4096",
				"numinlets" : 1,
				"patching_rect" : [ 461.0, 637.0, 124.0, 20.0 ],
				"numoutlets" : 2,
				"outlettype" : [ "float", "bang" ],
				"id" : "obj-17"
			}

		}
, 		{
			"box" : 			{
				"maxclass" : "button",
				"numinlets" : 1,
				"patching_rect" : [ 461.0, 331.0, 24.0, 24.0 ],
				"numoutlets" : 1,
				"outlettype" : [ "bang" ],
				"id" : "obj-19",
				"parameter_enable" : 0
			}

		}
, 		{
			"box" : 			{
				"maxclass" : "newobj",
				"text" : "expr sin(2 * 3.14159 * $f1 / 4096)",
				"numinlets" : 1,
				"patching_rect" : [ 461.0, 485.0, 159.0, 20.0 ],
				"numoutlets" : 1,
				"outlettype" : [ "" ],
				"id" : "obj-6"
			}

		}
, 		{
			"box" : 			{
				"maxclass" : "newobj",
				"text" : "counter 0 4095",
				"numinlets" : 5,
				"patching_rect" : [ 461.0, 413.0, 89.0, 20.0 ],
				"numoutlets" : 4,
				"outlettype" : [ "int", "", "", "int" ],
				"id" : "obj-18"
			}

		}
, 		{
			"box" : 			{
				"maxclass" : "newobj",
				"text" : "poke~ wavetable6",
				"numinlets" : 3,
				"patching_rect" : [ 339.0, 532.0, 94.0, 20.0 ],
				"numoutlets" : 0,
				"id" : "obj-20"
			}

		}
 ],
	"lines" : [ 		{
			"patchline" : 			{
				"source" : [ "obj-18", 0 ],
				"destination" : [ "obj-6", 0 ],
				"order" : 0
			}

		}
, 		{
			"patchline" : 			{
				"source" : [ "obj-6", 0 ],
				"destination" : [ "obj-3", 0 ],
				"order" : 0
			}

		}
, 		{
			"patchline" : 			{
				"source" : [ "obj-6", 0 ],
				"destination" : [ "obj-20", 0 ],
				"order" : 1
			}

		}
, 		{
			"patchline" : 			{
				"source" : [ "obj-18", 0 ],
				"destination" : [ "obj-20", 1 ],
				"order" : 1
			}

		}
, 		{
			"patchline" : 			{
				"source" : [ "obj-4", 0 ],
				"destination" : [ "obj-18", 0 ]
			}

		}
, 		{
			"patchline" : 			{
				"source" : [ "obj-19", 0 ],
				"destination" : [ "obj-4", 0 ]
			}

		}
 ],
	"appversion" : 	{
		"major" : 8,
		"minor" : 6,
		"revision" : 5,
		"architecture" : "x64",
		"modernui" : 1
	}
,
	"classnamespace" : "box"
}
TFL's icon

Three things:

  1. Please use Edit > "Copy compressed" before pasting your patch in the forum instead of just copying them.

  2. If you check the documentation for the duration argument of [buffer~] you'll see that it's expressed in milliseconds. If you want to define it in samples, use @samps attribute instead.

  3. You need to first send the index to [poke~], then the value for that index. For this I use [t i i], but you could have also put [poke~] on the right side of [expr] and let the right-to-left execution order to the job.

Max Patch
Copy patch and select New From Clipboard in Max.

But even more simple would be to use the 'fill' method of [buffer~]:

Max Patch
Copy patch and select New From Clipboard in Max.

Roman Thilenius's icon

4.) there are better objects than buffer~ to store wavetables or functions, for example cycle~.

gianmaria allibrante's icon

Thanks for your replys, im want to recreate the Elektron Machinedrum EFM-BF, the FM drumbass, according to the PDF https://www.elektronauts.com/files/603 Machinedrum use a table of 2**15 16 bit samples, no inerpolation, this allow very interesting result when the feedback is active, "the system behave chaotic" pag 14, but i noticed that i need to use gen to do it.

gianmaria allibrante's icon
Max Patch
Copy patch and select New From Clipboard in Max.

while in m4l things are synced, into Live the "osc" phase is resetted un 1ms before the evolepes are triggered... any advice to better practice to setup en environment that offer all the resources needed to bit precision? thanks