On Fri, Sep 9, 2011 at 2:46 PM, Patrice Colet colet.patrice@free.fr wrote:
Hello, I'm not a C expert but I see errors in your code
----- "Rick T" ratulloch@gmail.com a écrit :
Greetings All
I'm having trouble getting my external to work, It compiles with 5 warnings sineq.c:48: warning: unused variable ‘x’ sineq.c:49: warning: unused variable ‘in1’ sineq.c:50: warning: unused variable ‘in2’ sineq.c:51: warning: unused variable ‘in3’ sineq.c:52: warning: unused variable ‘in4’
in http://iem.at/pd/externals-HOWTO/node6.html it's not a t_float but a t_sample for using those variables
True but the variables in my external are floats not samples like in the
example pan~ which takes in 2 different signals. I'm taking in 4 different floats (numbers)
It does a "make" successfully but I get this warning message /usr/bin/ld: warning: cannot find entry symbol xport_dynamic; defaulting to 00000000000007f0
it's certainly caused by your makefile during linking, it's rather export_dynamic, you've certainly made a typo ^^
I thought so to but when I take a look at the make file it looks fine here's a link to the code in (pastebin)
# Makefile # (c) 2006 IOhannes m zmölnig
# path to pd ## change this according to your setup! PDROOT=../../../../pd #PDROOT=/home/zmoelnig/src/pd/
# here we find the sources of pd (and evtl. the pd.lib) PDSRCDIR=$(PDROOT)/src PDLIBDIR=$(PDROOT)/bin
# this is the filename-extension # people have to specify it at the cmdline: eg "make pd_linux" EXTENSION=$(MAKECMDGOALS)
# if no filename-extension is supplied by the user # try to guess one, based on what "uname" tells us UNAME := $(shell uname -s) ifeq ($(UNAME),Linux) DEFAULTEXTENSION= pd_linux else ifeq ($(UNAME),Darwin) DEFAULTEXTENSION= pd_darwin else ifeq (MINGW,$(findstring MINGW,$(UNAME))) DEFAULTEXTENSION= pd_nt else ifeq ($(UNAME),IRIX) UNAMEV := $(shell uname -R) ifeq (6.,$(findstring 6.,$(UNAMEV))) DEFAULTEXTENSION= pd_irix6 else DEFAULTEXTENSION= pd_irix5 endif else DEFAULTEXTENSION=help endif endif endif endif
# if no extension is given, call "make" again with a guessed extension auto: make $(DEFAULTEXTENSION)
# just a stupid fallback help: @echo "choose one command: make pd_linux (linux), make pd_darwin (osX), make pd_irix5 (IRIX5), make pd_irix6 (IRIX6), make dll (MSVC), make pd_nt (MinWG)"
# delete old build files clean: -rm -f *.dll *.pd_* *.o *.obj *~
# we want to compile all C-files we find in the current directory SOURCES=$(sort $(filter %.c, $(wildcard *.c))) # each C-files maps will become an external with the given filename-extension TARGETS=$(SOURCES:.c=.$(EXTENSION))
# ----------------------- Linux -----------------------
pd_linux: $(TARGETS)
LINUXCFLAGS = -DPD -O2 -funroll-loops -fomit-frame-pointer -fPIC \ -Wall -W -Wshadow -Wstrict-prototypes -Werror \ -Wno-unused -Wno-parentheses -Wno-switch
LINUXLDFLAGS = -export_dynamic -shared -lc -lm
LINUXINCLUDE = -I$(PDSRCDIR)
%.pd_linux: %.c $(CC) $(LINUXLDFLAGS) $(LINUXCFLAGS) $(LINUXINCLUDE) -o $*.pd_linux $*.c strip --strip-unneeded $*.pd_linux
# ----------------------- Mac OSX -----------------------
pd_darwin: $(TARGETS)
DARWINCFLAGS = -DPD -O2 -Wall -W -Wshadow -Wstrict-prototypes \ -Wno-unused -Wno-parentheses -Wno-switch
DARWININCLUDE = -I$(PDSRCDIR)
DARWINLDFLAGS = -bundle -undefined suppress -flat_namespace
%.pd_darwin: %.c $(CC) $(DARWINCFLAGS) $(DARWININCLUDE) $(DARWINLDFLAGS) -o $*.pd_darwin $*.c
# ----------------------- IRIX 5.x ----------------------- pd_irix5: $(TARGETS)
SGICFLAGS5 = -o32 -DPD -DSGI -O2
SGIINCLUDE = -I$(PDSRCDIR)
SGILDFLAGS = -elf -shared -rdata_shared
%.pd_irix5: %.c $(CC) $(SGICFLAGS5) $(SGIINCLUDE) -o $*.o -c $*.c $(LD) $(SGILDFLAGS) -o $*.pd_irix5 $*.o rm $*.o
# ----------------------- IRIX 6.x ----------------------- pd_irix6: $(TARGETS)
SGICFLAGS6 = -DPD -DSGI -n32 \ -OPT:roundoff=3 -OPT:IEEE_arithmetic=3 -OPT:cray_ivdep=true \ -Ofast=ip32
%.pd_irix6: %.c $(CC) $(SGICFLAGS6) $(SGIINCLUDE) -o $*.o -c $*.c $(LD) $(SGILDFLAGS) -o $*.pd_irix6 $*.o rm $*.o
# ----------------------- NT ----------------------- dll: $(TARGETS)
PDNTCFLAGS = /W3 /WX /DPD /DNT /D__WIN32__ /DMSW /nologo
VC="C:\Programme\Microsoft Visual Studio\Vc98"
PDNTINCLUDE = /I. /I$(PDROOT)\tcl\include /I$(PDSRCDIR)\src /I$(VC)\include
PDNTLDIR = $(VC)\lib
PDNTLIB = $(PDNTLDIR)\libc.lib \ $(PDNTLDIR)\oldnames.lib \ $(PDNTLDIR)\kernel32.lib \ $(PDLIBDIR)\pd.lib
%.dll: %.c cl $(PDNTCFLAGS) $(PDNTINCLUDE) /c $*.c link /dll /export:$*_setup $*.obj $(PDNTLIB)
pd_nt: $(TARGETS)
MINGWCFLAGS = -DPD -O2 -funroll-loops -fomit-frame-pointer \ -Wall -W -Wshadow -Wstrict-prototypes -Werror \ -Wno-unused -Wno-parentheses -Wno-switch -mms-bitfields
MINGWLDFLAGS = -export_dynamic -shared -lm -lkernel32 -lcoldname -lcrtdll -lpd -L$(PDLIBDIR)
MINGWINCLUDE = -I$(PDSRCDIR)
%.pd_nt: %.c $(CC) $(MINGWLDFLAGS) $(MINGWCFLAGS) $(MINGWINCLUDE) -o $*.dll $*.c
but when I try and add it in PD it says "couldn't create". I've looked at the pan~ tutorial and the d_osc.c file as recommended, which did help. I tried to take pieces from the two which I thought were applicable to my situation but I'm still having some issues.
maybe a little look into bassmu~ source code could also be interesting
Do you know the name for the source file or know where I can find it? I typed in bassmu~ in PD and nothing came back.
Here's a link to the workflow (dropbox) http://dl.dropbox.com/u/6576402/questions/pd/Sine_EQ_Diagram.jpg
Here's a link to the C code online (pastebin) http://pastebin.com/9rK3szUE
My external is a reproduction of the sinewave equation with 4 inputs and one output my logic is to have 4 inlets one for the frequency,amplitude,phase and vertical offset and an output for the created signal. Granted this isn't the final equation but this will help me understand how to create the full equation once done. If you want to see the full equation I'll be using here's a link to it below. Basically it's a 1 second periodic signal with the sample rate at 44100 which the equation gives me control over the frequency,amplitude,phase and vertical offset, which will be controlled by a usb midi controller.
Another question I have is what do I use for the t (time) for my final equation is that the t_sample object in PD? or do I need to create a for loop counting from 1-44100 for a 1 second 44100 sampled equation?
http://dl.dropbox.com/u/6576402/questions/eq1.txt
PS: I'm compiling on ubuntu 10.04 using gcc
On Sun, Sep 4, 2011 at 12:13 PM, Martin Peach < martin.peach@sympatico.ca > wrote:
On 2011-09-04 16:52, Rick T wrote: ...
I've been able to find instructions on how to create a hello world C-external but not one that creates a simple sine wave from a sinewave equation like A*sin(w*t+p) ( https://secure.wikimedia.org/ wikipedia/en/wiki/Sine_wave ) Does anyone have one or know where to find one.
The canonical reference is here: http://iem.at/pd/externals- HOWTO/node6.html You just need to plug your equation into the perform routine. Also check the source for osc~ in d_osc.c of the Pd source, which uses a fancy 32-bit float cosine table scanning method that was useful when it mattered but is getting obsolete as a call to sin() is probably just as fast nowadays.
Martin
Pd-dev mailing list Pd-dev@iem.at http://lists.puredata.info/listinfo/pd-dev
-- Patrice Colet
Aloha and thanks for the help every bit helps --