Csound Csound-dev Csound-tekno Search About

[Cs-dev] Problem with csoundTabbleCopyOut()

Date2014-03-14 14:45
FromRory Walsh
Subject[Cs-dev] Problem with csoundTabbleCopyOut()
Attachmentstest.cpp  example1.csd  None  None  
Attached are the source and csd file that will produce the problem.

Backtrace:
#0  __memcpy_ssse3_back ()
    at ../sysdeps/x86_64/multiarch/memcpy-ssse3-back.S:1579
#1  0x00007ffff7a6b992 in csoundTableCopyOut (csound=0x609030, table=1,
    ptable=0x0) at /home/rory/sourcecode/csound-csound6-git/Top/threadsafe.c:50
#2  0x0000000000404e12 in Csound::TableCopyOut(int, float*) ()
#3  0x0000000000403779 in main ()


Date2014-03-19 14:59
FromRory Walsh
SubjectRe: [Cs-dev] Problem with csoundTabbleCopyOut()
AttachmentsNone  None  
I tried to do some more digging around this but I can't see why memcpy is giving a problem. When I break at memcpy:

memcpy(ptable, ftab, (size_t) (len*sizeof(MYFLT)));

The values read:
ptable = 0x4035c0
len = 1024
ftab = 0x7a2d50

These addresses appear to be valid, but how would one find out for sure?


On 14 March 2014 14:45, Rory Walsh <rorywalsh@ear.ie> wrote:
Attached are the source and csd file that will produce the problem.

Backtrace:
#0  __memcpy_ssse3_back ()
    at ../sysdeps/x86_64/multiarch/memcpy-ssse3-back.S:1579
#1  0x00007ffff7a6b992 in csoundTableCopyOut (csound=0x609030, table=1,
    ptable=0x0) at /home/rory/sourcecode/csound-csound6-git/Top/threadsafe.c:50
#2  0x0000000000404e12 in Csound::TableCopyOut(int, float*) ()
#3  0x0000000000403779 in main ()



Date2014-03-19 15:16
FromRory Walsh
SubjectRe: [Cs-dev] Problem with csoundTabbleCopyOut()
AttachmentsNone  None  
I thought the following code might catch something but Csound runs through it without any issue.

MYFLT tmp;
int i=0;
for (i = 0; i < len; i++)
{
    tmp = ptable[i];
    tmp = ftab[i];
}

I'm happy to try out any suggestions :) I also tried creating the function table in instr0 but that didn't help either.




On 19 March 2014 14:59, Rory Walsh <rorywalsh@ear.ie> wrote:
I tried to do some more digging around this but I can't see why memcpy is giving a problem. When I break at memcpy:

memcpy(ptable, ftab, (size_t) (len*sizeof(MYFLT)));

The values read:
ptable = 0x4035c0
len = 1024
ftab = 0x7a2d50

These addresses appear to be valid, but how would one find out for sure?


On 14 March 2014 14:45, Rory Walsh <rorywalsh@ear.ie> wrote:
Attached are the source and csd file that will produce the problem.

Backtrace:
#0  __memcpy_ssse3_back ()
    at ../sysdeps/x86_64/multiarch/memcpy-ssse3-back.S:1579
#1  0x00007ffff7a6b992 in csoundTableCopyOut (csound=0x609030, table=1,
    ptable=0x0) at /home/rory/sourcecode/csound-csound6-git/Top/threadsafe.c:50
#2  0x0000000000404e12 in Csound::TableCopyOut(int, float*) ()
#3  0x0000000000403779 in main ()




Date2014-03-19 15:18
FromVictor Lazzarini
SubjectRe: [Cs-dev] Problem with csoundTabbleCopyOut()
ptable = 0x0 is the problem (see #1).

========================
Dr Victor Lazzarini
Senior Lecturer
NUI Maynooth, Ireland
victor dot lazzarini at nuim dot ie




On 14 Mar 2014, at 14:45, Rory Walsh  wrote:

> Attached are the source and csd file that will produce the problem. 
> 
> Backtrace:
> #0  __memcpy_ssse3_back ()
>     at ../sysdeps/x86_64/multiarch/memcpy-ssse3-back.S:1579
> #1  0x00007ffff7a6b992 in csoundTableCopyOut (csound=0x609030, table=1, 
>     ptable=0x0) at /home/rory/sourcecode/csound-csound6-git/Top/threadsafe.c:50
> #2  0x0000000000404e12 in Csound::TableCopyOut(int, float*) ()
> #3  0x0000000000403779 in main ()
> 
> ------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and their
> applications. Written by three acclaimed leaders in the field,
> this first edition is now available. Download your free book today!
> http://p.sf.net/sfu/13534_NeoTech_______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2014-03-19 15:19
FromVictor Lazzarini
SubjectRe: [Cs-dev] Problem with csoundTabbleCopyOut()
MYFLT* temp = 0;
int tableSize = csound->TableLength(1);
csound->TableCopyOut(1, temp);

You need memory to copy into.  Try allocating it.


========================
Dr Victor Lazzarini
Senior Lecturer
NUI Maynooth, Ireland
victor dot lazzarini at nuim dot ie




On 19 Mar 2014, at 14:59, Rory Walsh  wrote:

> I tried to do some more digging around this but I can't see why memcpy is giving a problem. When I break at memcpy:
> 
> memcpy(ptable, ftab, (size_t) (len*sizeof(MYFLT)));
> 
> The values read:
> ptable = 0x4035c0
> len = 1024
> ftab = 0x7a2d50
> 
> These addresses appear to be valid, but how would one find out for sure?
> 
> 
> On 14 March 2014 14:45, Rory Walsh  wrote:
> Attached are the source and csd file that will produce the problem. 
> 
> Backtrace:
> #0  __memcpy_ssse3_back ()
>     at ../sysdeps/x86_64/multiarch/memcpy-ssse3-back.S:1579
> #1  0x00007ffff7a6b992 in csoundTableCopyOut (csound=0x609030, table=1, 
>     ptable=0x0) at /home/rory/sourcecode/csound-csound6-git/Top/threadsafe.c:50
> #2  0x0000000000404e12 in Csound::TableCopyOut(int, float*) ()
> #3  0x0000000000403779 in main ()
> 
> 
> ------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and their
> applications. Written by three acclaimed leaders in the field,
> this first edition is now available. Download your free book today!
> http://p.sf.net/sfu/13534_NeoTech_______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2014-03-19 15:34
FromRory Walsh
SubjectRe: [Cs-dev] Problem with csoundTabbleCopyOut()
AttachmentsNone  None  
That gives the same error. I also just tried explicitly allocating enough space ala:

int tableSize = csound->TableLength(1);
MYFLT* temp = (MYFLT *)malloc(tableSize * sizeof(MYFLT));
csound->TableCopyOut(1, temp);

but that gives a whole host of new errors:

0  0x00007ffff700e425  __GI_raise  ../nptl/sysdeps/unix/sysv/linux/raise.c  64
1  0x00007ffff7011b8b  __GI_abort  abort.c  91
2  0x00007ffff704c39e  __libc_message  ../sysdeps/unix/sysv/linux/libc_fatal.c  201
3  0x00007ffff7056b96  malloc_printerr  malloc.c  5039
4  0x00007ffff790bd03  mfree  /home/rory/sourcecode/csound-csound6-git/Engine/memalloc.c  157
5  0x00007ffff79042c1  orcompact  /home/rory/sourcecode/csound-csound6-git/Engine/insert.c  813
6  0x00007ffff790f714  csoundCleanup  /home/rory/sourcecode/csound-csound6-git/Engine/musmon.c  447
7  0x00007ffff7a61b48  reset  /home/rory/sourcecode/csound-csound6-git/Top/csound.c  2646
8  0x00007ffff7a5e64c  csoundDestroy  /home/rory/sourcecode/csound-csound6-git/Top/csound.c  1212
9  0x000000000040551f  Csound::~Csound()   
10  0x0000000000405552  Csound::~Csound()   
11  0x00000000004037f6  main   

I'm not sure why ptable was 0x0 in my first report from a few days ago, it certainly seems valid now. I think I might have tried initialized it to something in an attempt go bypass this problem.


On 19 March 2014 15:19, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
MYFLT* temp = 0;
int tableSize = csound->TableLength(1);
csound->TableCopyOut(1, temp);

You need memory to copy into.  Try allocating it.


========================
Dr Victor Lazzarini
Senior Lecturer
NUI Maynooth, Ireland
victor dot lazzarini at nuim dot ie




On 19 Mar 2014, at 14:59, Rory Walsh <rorywalsh@ear.ie> wrote:

> I tried to do some more digging around this but I can't see why memcpy is giving a problem. When I break at memcpy:
>
> memcpy(ptable, ftab, (size_t) (len*sizeof(MYFLT)));
>
> The values read:
> ptable = 0x4035c0
> len = 1024
> ftab = 0x7a2d50
>
> These addresses appear to be valid, but how would one find out for sure?
>
>
> On 14 March 2014 14:45, Rory Walsh <rorywalsh@ear.ie> wrote:
> Attached are the source and csd file that will produce the problem.
>
> Backtrace:
> #0  __memcpy_ssse3_back ()
>     at ../sysdeps/x86_64/multiarch/memcpy-ssse3-back.S:1579
> #1  0x00007ffff7a6b992 in csoundTableCopyOut (csound=0x609030, table=1,
>     ptable=0x0) at /home/rory/sourcecode/csound-csound6-git/Top/threadsafe.c:50
> #2  0x0000000000404e12 in Csound::TableCopyOut(int, float*) ()
> #3  0x0000000000403779 in main ()
>
>
> ------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and their
> applications. Written by three acclaimed leaders in the field,
> this first edition is now available. Download your free book today!
> http://p.sf.net/sfu/13534_NeoTech_______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel


Date2014-03-19 15:57
Fromjpff@cs.bath.ac.uk
SubjectRe: [Cs-dev] Problem with csoundTabbleCopyOut()
AttachmentsNone  

Date2014-03-19 16:00
FromVictor Lazzarini
SubjectRe: [Cs-dev] Problem with csoundTabbleCopyOut()
I don’t know: your test program works here when I allocate memory. It prints out the table too.

int main(int argc, char *argv[])
{
/*Create an instance of Csound*/
Csound* csound = new Csound;
csound->Compile("example1.csd");
csound->PerformKsmps();
int tableSize = csound->TableLength(1);
printf("%d \n", tableSize);
MYFLT *temp = new MYFLT[tableSize];
csound->TableCopyOut(1, temp);

for(int i=0;iPerform();
/*delete instance of csound*/
delete csound;
delete[] temp;
}

========================
Dr Victor Lazzarini
Senior Lecturer
NUI Maynooth, Ireland
victor dot lazzarini at nuim dot ie




On 19 Mar 2014, at 15:34, Rory Walsh  wrote:

> That gives the same error. I also just tried explicitly allocating enough space ala:
> 
> int tableSize = csound->TableLength(1);
> MYFLT* temp = (MYFLT *)malloc(tableSize * sizeof(MYFLT));
> csound->TableCopyOut(1, temp);
> 
> but that gives a whole host of new errors:
> 
> 0  0x00007ffff700e425  __GI_raise  ../nptl/sysdeps/unix/sysv/linux/raise.c  64
> 1  0x00007ffff7011b8b  __GI_abort  abort.c  91
> 2  0x00007ffff704c39e  __libc_message  ../sysdeps/unix/sysv/linux/libc_fatal.c  201
> 3  0x00007ffff7056b96  malloc_printerr  malloc.c  5039
> 4  0x00007ffff790bd03  mfree  /home/rory/sourcecode/csound-csound6-git/Engine/memalloc.c  157
> 5  0x00007ffff79042c1  orcompact  /home/rory/sourcecode/csound-csound6-git/Engine/insert.c  813
> 6  0x00007ffff790f714  csoundCleanup  /home/rory/sourcecode/csound-csound6-git/Engine/musmon.c  447
> 7  0x00007ffff7a61b48  reset  /home/rory/sourcecode/csound-csound6-git/Top/csound.c  2646
> 8  0x00007ffff7a5e64c  csoundDestroy  /home/rory/sourcecode/csound-csound6-git/Top/csound.c  1212
> 9  0x000000000040551f  Csound::~Csound()    
> 10  0x0000000000405552  Csound::~Csound()    
> 11  0x00000000004037f6  main    
> 
> I'm not sure why ptable was 0x0 in my first report from a few days ago, it certainly seems valid now. I think I might have tried initialized it to something in an attempt go bypass this problem. 
> 
> 
> On 19 March 2014 15:19, Victor Lazzarini  wrote:
> MYFLT* temp = 0;
> int tableSize = csound->TableLength(1);
> csound->TableCopyOut(1, temp);
> 
> You need memory to copy into.  Try allocating it.
> 
> 
> ========================
> Dr Victor Lazzarini
> Senior Lecturer
> NUI Maynooth, Ireland
> victor dot lazzarini at nuim dot ie
> 
> 
> 
> 
> On 19 Mar 2014, at 14:59, Rory Walsh  wrote:
> 
> > I tried to do some more digging around this but I can't see why memcpy is giving a problem. When I break at memcpy:
> >
> > memcpy(ptable, ftab, (size_t) (len*sizeof(MYFLT)));
> >
> > The values read:
> > ptable = 0x4035c0
> > len = 1024
> > ftab = 0x7a2d50
> >
> > These addresses appear to be valid, but how would one find out for sure?
> >
> >
> > On 14 March 2014 14:45, Rory Walsh  wrote:
> > Attached are the source and csd file that will produce the problem.
> >
> > Backtrace:
> > #0  __memcpy_ssse3_back ()
> >     at ../sysdeps/x86_64/multiarch/memcpy-ssse3-back.S:1579
> > #1  0x00007ffff7a6b992 in csoundTableCopyOut (csound=0x609030, table=1,
> >     ptable=0x0) at /home/rory/sourcecode/csound-csound6-git/Top/threadsafe.c:50
> > #2  0x0000000000404e12 in Csound::TableCopyOut(int, float*) ()
> > #3  0x0000000000403779 in main ()
> >
> >
> > ------------------------------------------------------------------------------
> > Learn Graph Databases - Download FREE O'Reilly Book
> > "Graph Databases" is the definitive new guide to graph databases and their
> > applications. Written by three acclaimed leaders in the field,
> > this first edition is now available. Download your free book today!
> > http://p.sf.net/sfu/13534_NeoTech_______________________________________________
> > Csound-devel mailing list
> > Csound-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/csound-devel
> 
> 
> ------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and their
> applications. Written by three acclaimed leaders in the field,
> this first edition is now available. Download your free book today!
> http://p.sf.net/sfu/13534_NeoTech
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
> 
> ------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and their
> applications. Written by three acclaimed leaders in the field,
> this first edition is now available. Download your free book today!
> http://p.sf.net/sfu/13534_NeoTech_______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2014-03-19 16:06
FromRory Walsh
SubjectRe: [Cs-dev] Problem with csoundTabbleCopyOut()
AttachmentsNone  None  
Weird. It works when I use your C++ method of allocation, but causes problems when I use malloc? Anyhow, that should hopefully get me past that problem. Now to try it on a full-blown scale..


On 19 March 2014 16:00, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
I don’t know: your test program works here when I allocate memory. It prints out the table too.

int main(int argc, char *argv[])
{
/*Create an instance of Csound*/
Csound* csound = new Csound;
csound->Compile("example1.csd");
csound->PerformKsmps();
int tableSize = csound->TableLength(1);
printf("%d \n", tableSize);
MYFLT *temp = new MYFLT[tableSize];
csound->TableCopyOut(1, temp);

for(int i=0;i<tableSize;i++)
        printf("%f\n", temp[i]);

csound->Perform();
/*delete instance of csound*/
delete csound;
delete[] temp;
}

========================
Dr Victor Lazzarini
Senior Lecturer
NUI Maynooth, Ireland
victor dot lazzarini at nuim dot ie




On 19 Mar 2014, at 15:34, Rory Walsh <rorywalsh@ear.ie> wrote:

> That gives the same error. I also just tried explicitly allocating enough space ala:
>
> int tableSize = csound->TableLength(1);
> MYFLT* temp = (MYFLT *)malloc(tableSize * sizeof(MYFLT));
> csound->TableCopyOut(1, temp);
>
> but that gives a whole host of new errors:
>
> 0  0x00007ffff700e425  __GI_raise  ../nptl/sysdeps/unix/sysv/linux/raise.c  64
> 1  0x00007ffff7011b8b  __GI_abort  abort.c  91
> 2  0x00007ffff704c39e  __libc_message  ../sysdeps/unix/sysv/linux/libc_fatal.c  201
> 3  0x00007ffff7056b96  malloc_printerr  malloc.c  5039
> 4  0x00007ffff790bd03  mfree  /home/rory/sourcecode/csound-csound6-git/Engine/memalloc.c  157
> 5  0x00007ffff79042c1  orcompact  /home/rory/sourcecode/csound-csound6-git/Engine/insert.c  813
> 6  0x00007ffff790f714  csoundCleanup  /home/rory/sourcecode/csound-csound6-git/Engine/musmon.c  447
> 7  0x00007ffff7a61b48  reset  /home/rory/sourcecode/csound-csound6-git/Top/csound.c  2646
> 8  0x00007ffff7a5e64c  csoundDestroy  /home/rory/sourcecode/csound-csound6-git/Top/csound.c  1212
> 9  0x000000000040551f  Csound::~Csound()
> 10  0x0000000000405552  Csound::~Csound()
> 11  0x00000000004037f6  main
>
> I'm not sure why ptable was 0x0 in my first report from a few days ago, it certainly seems valid now. I think I might have tried initialized it to something in an attempt go bypass this problem.
>
>
> On 19 March 2014 15:19, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
> MYFLT* temp = 0;
> int tableSize = csound->TableLength(1);
> csound->TableCopyOut(1, temp);
>
> You need memory to copy into.  Try allocating it.
>
>
> ========================
> Dr Victor Lazzarini
> Senior Lecturer
> NUI Maynooth, Ireland
> victor dot lazzarini at nuim dot ie
>
>
>
>
> On 19 Mar 2014, at 14:59, Rory Walsh <rorywalsh@ear.ie> wrote:
>
> > I tried to do some more digging around this but I can't see why memcpy is giving a problem. When I break at memcpy:
> >
> > memcpy(ptable, ftab, (size_t) (len*sizeof(MYFLT)));
> >
> > The values read:
> > ptable = 0x4035c0
> > len = 1024
> > ftab = 0x7a2d50
> >
> > These addresses appear to be valid, but how would one find out for sure?
> >
> >
> > On 14 March 2014 14:45, Rory Walsh <rorywalsh@ear.ie> wrote:
> > Attached are the source and csd file that will produce the problem.
> >
> > Backtrace:
> > #0  __memcpy_ssse3_back ()
> >     at ../sysdeps/x86_64/multiarch/memcpy-ssse3-back.S:1579
> > #1  0x00007ffff7a6b992 in csoundTableCopyOut (csound=0x609030, table=1,
> >     ptable=0x0) at /home/rory/sourcecode/csound-csound6-git/Top/threadsafe.c:50
> > #2  0x0000000000404e12 in Csound::TableCopyOut(int, float*) ()
> > #3  0x0000000000403779 in main ()
> >
> >
> > ------------------------------------------------------------------------------
> > Learn Graph Databases - Download FREE O'Reilly Book
> > "Graph Databases" is the definitive new guide to graph databases and their
> > applications. Written by three acclaimed leaders in the field,
> > this first edition is now available. Download your free book today!
> > http://p.sf.net/sfu/13534_NeoTech_______________________________________________
> > Csound-devel mailing list
> > Csound-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/csound-devel
>
>
> ------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and their
> applications. Written by three acclaimed leaders in the field,
> this first edition is now available. Download your free book today!
> http://p.sf.net/sfu/13534_NeoTech
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
> ------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and their
> applications. Written by three acclaimed leaders in the field,
> this first edition is now available. Download your free book today!
> http://p.sf.net/sfu/13534_NeoTech_______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel


Date2014-03-19 17:51
FromRory Walsh
SubjectRe: [Cs-dev] Problem with csoundTabbleCopyOut()
Attachmentsexample1.csd  None  None  
So I'm looking for a way to access values from tables that have been resized, and in a threadsafe manor. As I need to dynamically alter my temp array I tried using a std::vector which I resize between calls to csoundPerformKsmps(). But as soon as I resize the table it gives me the same error as I was getting to start with. I've attached a csd file that uses John's ftresize opcodes and runs fine in Csound. Coupled with the code from below it will crash at the memcpy line in csoundTableCopyOut() I pointed to before. Any ideas on what I might be doing wrong? std::vector allocates memory when resize is called, and

std::vector<MYFLT> temp (1024);

while(csound->PerformKsmps()==0){
    tableSize = csound->TableLength(1);
    if(testTableSize!=tableSize){
        testTableSize = tableSize;
        csound->Message("Table size is now: %d\n", testTableSize);    
    }
    temp.resize(tableSize);   
    csound->TableCopyOut(1, &temp[0]);   
}

Btw, I also tried with std::vector::data() which returns a direct pointer to the vector's internal array but that results in the same problem. Any ideas?



On 19 March 2014 16:06, Rory Walsh <rorywalsh@ear.ie> wrote:
Weird. It works when I use your C++ method of allocation, but causes problems when I use malloc? Anyhow, that should hopefully get me past that problem. Now to try it on a full-blown scale..


On 19 March 2014 16:00, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
I don’t know: your test program works here when I allocate memory. It prints out the table too.

int main(int argc, char *argv[])
{
/*Create an instance of Csound*/
Csound* csound = new Csound;
csound->Compile("example1.csd");
csound->PerformKsmps();
int tableSize = csound->TableLength(1);
printf("%d \n", tableSize);
MYFLT *temp = new MYFLT[tableSize];
csound->TableCopyOut(1, temp);

for(int i=0;i<tableSize;i++)
        printf("%f\n", temp[i]);

csound->Perform();
/*delete instance of csound*/
delete csound;
delete[] temp;
}

========================
Dr Victor Lazzarini
Senior Lecturer
NUI Maynooth, Ireland
victor dot lazzarini at nuim dot ie




On 19 Mar 2014, at 15:34, Rory Walsh <rorywalsh@ear.ie> wrote:

> That gives the same error. I also just tried explicitly allocating enough space ala:
>
> int tableSize = csound->TableLength(1);
> MYFLT* temp = (MYFLT *)malloc(tableSize * sizeof(MYFLT));
> csound->TableCopyOut(1, temp);
>
> but that gives a whole host of new errors:
>
> 0  0x00007ffff700e425  __GI_raise  ../nptl/sysdeps/unix/sysv/linux/raise.c  64
> 1  0x00007ffff7011b8b  __GI_abort  abort.c  91
> 2  0x00007ffff704c39e  __libc_message  ../sysdeps/unix/sysv/linux/libc_fatal.c  201
> 3  0x00007ffff7056b96  malloc_printerr  malloc.c  5039
> 4  0x00007ffff790bd03  mfree  /home/rory/sourcecode/csound-csound6-git/Engine/memalloc.c  157
> 5  0x00007ffff79042c1  orcompact  /home/rory/sourcecode/csound-csound6-git/Engine/insert.c  813
> 6  0x00007ffff790f714  csoundCleanup  /home/rory/sourcecode/csound-csound6-git/Engine/musmon.c  447
> 7  0x00007ffff7a61b48  reset  /home/rory/sourcecode/csound-csound6-git/Top/csound.c  2646
> 8  0x00007ffff7a5e64c  csoundDestroy  /home/rory/sourcecode/csound-csound6-git/Top/csound.c  1212
> 9  0x000000000040551f  Csound::~Csound()
> 10  0x0000000000405552  Csound::~Csound()
> 11  0x00000000004037f6  main
>
> I'm not sure why ptable was 0x0 in my first report from a few days ago, it certainly seems valid now. I think I might have tried initialized it to something in an attempt go bypass this problem.
>
>
> On 19 March 2014 15:19, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
> MYFLT* temp = 0;
> int tableSize = csound->TableLength(1);
> csound->TableCopyOut(1, temp);
>
> You need memory to copy into.  Try allocating it.
>
>
> ========================
> Dr Victor Lazzarini
> Senior Lecturer
> NUI Maynooth, Ireland
> victor dot lazzarini at nuim dot ie
>
>
>
>
> On 19 Mar 2014, at 14:59, Rory Walsh <rorywalsh@ear.ie> wrote:
>
> > I tried to do some more digging around this but I can't see why memcpy is giving a problem. When I break at memcpy:
> >
> > memcpy(ptable, ftab, (size_t) (len*sizeof(MYFLT)));
> >
> > The values read:
> > ptable = 0x4035c0
> > len = 1024
> > ftab = 0x7a2d50
> >
> > These addresses appear to be valid, but how would one find out for sure?
> >
> >
> > On 14 March 2014 14:45, Rory Walsh <rorywalsh@ear.ie> wrote:
> > Attached are the source and csd file that will produce the problem.
> >
> > Backtrace:
> > #0  __memcpy_ssse3_back ()
> >     at ../sysdeps/x86_64/multiarch/memcpy-ssse3-back.S:1579
> > #1  0x00007ffff7a6b992 in csoundTableCopyOut (csound=0x609030, table=1,
> >     ptable=0x0) at /home/rory/sourcecode/csound-csound6-git/Top/threadsafe.c:50
> > #2  0x0000000000404e12 in Csound::TableCopyOut(int, float*) ()
> > #3  0x0000000000403779 in main ()
> >
> >
> > ------------------------------------------------------------------------------
> > Learn Graph Databases - Download FREE O'Reilly Book
> > "Graph Databases" is the definitive new guide to graph databases and their
> > applications. Written by three acclaimed leaders in the field,
> > this first edition is now available. Download your free book today!
> > http://p.sf.net/sfu/13534_NeoTech_______________________________________________
> > Csound-devel mailing list
> > Csound-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/csound-devel
>
>
> ------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and their
> applications. Written by three acclaimed leaders in the field,
> this first edition is now available. Download your free book today!
> http://p.sf.net/sfu/13534_NeoTech
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
> ------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and their
> applications. Written by three acclaimed leaders in the field,
> this first edition is now available. Download your free book today!
> http://p.sf.net/sfu/13534_NeoTech_______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel



Date2014-03-19 19:18
FromVictor Lazzarini
SubjectRe: [Cs-dev] Problem with csoundTabbleCopyOut()
I don’t know again. This works here:

 std::vector temp (1);
 int tableSize = csound->TableLength(1);
 temp.resize(tableSize);
 csound->TableCopyOut(1, temp.data());


========================
Dr Victor Lazzarini
Senior Lecturer
NUI Maynooth, Ireland
victor dot lazzarini at nuim dot ie




On 19 Mar 2014, at 17:51, Rory Walsh  wrote:

> So I'm looking for a way to access values from tables that have been resized, and in a threadsafe manor. As I need to dynamically alter my temp array I tried using a std::vector which I resize between calls to csoundPerformKsmps(). But as soon as I resize the table it gives me the same error as I was getting to start with. I've attached a csd file that uses John's ftresize opcodes and runs fine in Csound. Coupled with the code from below it will crash at the memcpy line in csoundTableCopyOut() I pointed to before. Any ideas on what I might be doing wrong? std::vector allocates memory when resize is called, and 
> 
> std::vector temp (1024);
> 
> while(csound->PerformKsmps()==0){
>     tableSize = csound->TableLength(1);
>     if(testTableSize!=tableSize){
>         testTableSize = tableSize;
>         csound->Message("Table size is now: %d\n", testTableSize);     
>     }
>     temp.resize(tableSize);    
>     csound->TableCopyOut(1, &temp[0]);    
> }
> 
> Btw, I also tried with std::vector::data() which returns a direct pointer to the vector's internal array but that results in the same problem. Any ideas?
> 
> 
> 
> On 19 March 2014 16:06, Rory Walsh  wrote:
> Weird. It works when I use your C++ method of allocation, but causes problems when I use malloc? Anyhow, that should hopefully get me past that problem. Now to try it on a full-blown scale..
> 
> 
> On 19 March 2014 16:00, Victor Lazzarini  wrote:
> I don’t know: your test program works here when I allocate memory. It prints out the table too.
> 
> int main(int argc, char *argv[])
> {
> /*Create an instance of Csound*/
> Csound* csound = new Csound;
> csound->Compile("example1.csd");
> csound->PerformKsmps();
> int tableSize = csound->TableLength(1);
> printf("%d \n", tableSize);
> MYFLT *temp = new MYFLT[tableSize];
> csound->TableCopyOut(1, temp);
> 
> for(int i=0;i         printf("%f\n", temp[i]);
> 
> csound->Perform();
> /*delete instance of csound*/
> delete csound;
> delete[] temp;
> }
> 
> ========================
> Dr Victor Lazzarini
> Senior Lecturer
> NUI Maynooth, Ireland
> victor dot lazzarini at nuim dot ie
> 
> 
> 
> 
> On 19 Mar 2014, at 15:34, Rory Walsh  wrote:
> 
> > That gives the same error. I also just tried explicitly allocating enough space ala:
> >
> > int tableSize = csound->TableLength(1);
> > MYFLT* temp = (MYFLT *)malloc(tableSize * sizeof(MYFLT));
> > csound->TableCopyOut(1, temp);
> >
> > but that gives a whole host of new errors:
> >
> > 0  0x00007ffff700e425  __GI_raise  ../nptl/sysdeps/unix/sysv/linux/raise.c  64
> > 1  0x00007ffff7011b8b  __GI_abort  abort.c  91
> > 2  0x00007ffff704c39e  __libc_message  ../sysdeps/unix/sysv/linux/libc_fatal.c  201
> > 3  0x00007ffff7056b96  malloc_printerr  malloc.c  5039
> > 4  0x00007ffff790bd03  mfree  /home/rory/sourcecode/csound-csound6-git/Engine/memalloc.c  157
> > 5  0x00007ffff79042c1  orcompact  /home/rory/sourcecode/csound-csound6-git/Engine/insert.c  813
> > 6  0x00007ffff790f714  csoundCleanup  /home/rory/sourcecode/csound-csound6-git/Engine/musmon.c  447
> > 7  0x00007ffff7a61b48  reset  /home/rory/sourcecode/csound-csound6-git/Top/csound.c  2646
> > 8  0x00007ffff7a5e64c  csoundDestroy  /home/rory/sourcecode/csound-csound6-git/Top/csound.c  1212
> > 9  0x000000000040551f  Csound::~Csound()
> > 10  0x0000000000405552  Csound::~Csound()
> > 11  0x00000000004037f6  main
> >
> > I'm not sure why ptable was 0x0 in my first report from a few days ago, it certainly seems valid now. I think I might have tried initialized it to something in an attempt go bypass this problem.
> >
> >
> > On 19 March 2014 15:19, Victor Lazzarini  wrote:
> > MYFLT* temp = 0;
> > int tableSize = csound->TableLength(1);
> > csound->TableCopyOut(1, temp);
> >
> > You need memory to copy into.  Try allocating it.
> >
> >
> > ========================
> > Dr Victor Lazzarini
> > Senior Lecturer
> > NUI Maynooth, Ireland
> > victor dot lazzarini at nuim dot ie
> >
> >
> >
> >
> > On 19 Mar 2014, at 14:59, Rory Walsh  wrote:
> >
> > > I tried to do some more digging around this but I can't see why memcpy is giving a problem. When I break at memcpy:
> > >
> > > memcpy(ptable, ftab, (size_t) (len*sizeof(MYFLT)));
> > >
> > > The values read:
> > > ptable = 0x4035c0
> > > len = 1024
> > > ftab = 0x7a2d50
> > >
> > > These addresses appear to be valid, but how would one find out for sure?
> > >
> > >
> > > On 14 March 2014 14:45, Rory Walsh  wrote:
> > > Attached are the source and csd file that will produce the problem.
> > >
> > > Backtrace:
> > > #0  __memcpy_ssse3_back ()
> > >     at ../sysdeps/x86_64/multiarch/memcpy-ssse3-back.S:1579
> > > #1  0x00007ffff7a6b992 in csoundTableCopyOut (csound=0x609030, table=1,
> > >     ptable=0x0) at /home/rory/sourcecode/csound-csound6-git/Top/threadsafe.c:50
> > > #2  0x0000000000404e12 in Csound::TableCopyOut(int, float*) ()
> > > #3  0x0000000000403779 in main ()
> > >
> > >
> > > ------------------------------------------------------------------------------
> > > Learn Graph Databases - Download FREE O'Reilly Book
> > > "Graph Databases" is the definitive new guide to graph databases and their
> > > applications. Written by three acclaimed leaders in the field,
> > > this first edition is now available. Download your free book today!
> > > http://p.sf.net/sfu/13534_NeoTech_______________________________________________
> > > Csound-devel mailing list
> > > Csound-devel@lists.sourceforge.net
> > > https://lists.sourceforge.net/lists/listinfo/csound-devel
> >
> >
> > ------------------------------------------------------------------------------
> > Learn Graph Databases - Download FREE O'Reilly Book
> > "Graph Databases" is the definitive new guide to graph databases and their
> > applications. Written by three acclaimed leaders in the field,
> > this first edition is now available. Download your free book today!
> > http://p.sf.net/sfu/13534_NeoTech
> > _______________________________________________
> > Csound-devel mailing list
> > Csound-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/csound-devel
> >
> > ------------------------------------------------------------------------------
> > Learn Graph Databases - Download FREE O'Reilly Book
> > "Graph Databases" is the definitive new guide to graph databases and their
> > applications. Written by three acclaimed leaders in the field,
> > this first edition is now available. Download your free book today!
> > http://p.sf.net/sfu/13534_NeoTech_______________________________________________
> > Csound-devel mailing list
> > Csound-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/csound-devel
> 
> 
> ------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and their
> applications. Written by three acclaimed leaders in the field,
> this first edition is now available. Download your free book today!
> http://p.sf.net/sfu/13534_NeoTech
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
> 
> 
> ------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and their
> applications. Written by three acclaimed leaders in the field,
> this first edition is now available. Download your free book today!
> http://p.sf.net/sfu/13534_NeoTech_______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2014-03-19 19:23
FromRory Walsh
SubjectRe: [Cs-dev] Problem with csoundTabbleCopyOut()
AttachmentsNone  None  
And you are using the attached .csd with the continuously changing ftables? Also, are you making those 4 calls after every csoundPerformKsmp()? I take it you are on OSX? I haven't tried this on Windows. Still trying to get it to work on Linux. Hmm..


On 19 March 2014 19:18, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
I don’t know again. This works here:

 std::vector<MYFLT> temp (1);
 int tableSize = csound->TableLength(1);
 temp.resize(tableSize);
 csound->TableCopyOut(1, temp.data());


========================
Dr Victor Lazzarini
Senior Lecturer
NUI Maynooth, Ireland
victor dot lazzarini at nuim dot ie




On 19 Mar 2014, at 17:51, Rory Walsh <rorywalsh@ear.ie> wrote:

> So I'm looking for a way to access values from tables that have been resized, and in a threadsafe manor. As I need to dynamically alter my temp array I tried using a std::vector which I resize between calls to csoundPerformKsmps(). But as soon as I resize the table it gives me the same error as I was getting to start with. I've attached a csd file that uses John's ftresize opcodes and runs fine in Csound. Coupled with the code from below it will crash at the memcpy line in csoundTableCopyOut() I pointed to before. Any ideas on what I might be doing wrong? std::vector allocates memory when resize is called, and
>
> std::vector<MYFLT> temp (1024);
>
> while(csound->PerformKsmps()==0){
>     tableSize = csound->TableLength(1);
>     if(testTableSize!=tableSize){
>         testTableSize = tableSize;
>         csound->Message("Table size is now: %d\n", testTableSize);
>     }
>     temp.resize(tableSize);
>     csound->TableCopyOut(1, &temp[0]);
> }
>
> Btw, I also tried with std::vector::data() which returns a direct pointer to the vector's internal array but that results in the same problem. Any ideas?
>
>
>
> On 19 March 2014 16:06, Rory Walsh <rorywalsh@ear.ie> wrote:
> Weird. It works when I use your C++ method of allocation, but causes problems when I use malloc? Anyhow, that should hopefully get me past that problem. Now to try it on a full-blown scale..
>
>
> On 19 March 2014 16:00, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
> I don’t know: your test program works here when I allocate memory. It prints out the table too.
>
> int main(int argc, char *argv[])
> {
> /*Create an instance of Csound*/
> Csound* csound = new Csound;
> csound->Compile("example1.csd");
> csound->PerformKsmps();
> int tableSize = csound->TableLength(1);
> printf("%d \n", tableSize);
> MYFLT *temp = new MYFLT[tableSize];
> csound->TableCopyOut(1, temp);
>
> for(int i=0;i<tableSize;i++)
>         printf("%f\n", temp[i]);
>
> csound->Perform();
> /*delete instance of csound*/
> delete csound;
> delete[] temp;
> }
>
> ========================
> Dr Victor Lazzarini
> Senior Lecturer
> NUI Maynooth, Ireland
> victor dot lazzarini at nuim dot ie
>
>
>
>
> On 19 Mar 2014, at 15:34, Rory Walsh <rorywalsh@ear.ie> wrote:
>
> > That gives the same error. I also just tried explicitly allocating enough space ala:
> >
> > int tableSize = csound->TableLength(1);
> > MYFLT* temp = (MYFLT *)malloc(tableSize * sizeof(MYFLT));
> > csound->TableCopyOut(1, temp);
> >
> > but that gives a whole host of new errors:
> >
> > 0  0x00007ffff700e425  __GI_raise  ../nptl/sysdeps/unix/sysv/linux/raise.c  64
> > 1  0x00007ffff7011b8b  __GI_abort  abort.c  91
> > 2  0x00007ffff704c39e  __libc_message  ../sysdeps/unix/sysv/linux/libc_fatal.c  201
> > 3  0x00007ffff7056b96  malloc_printerr  malloc.c  5039
> > 4  0x00007ffff790bd03  mfree  /home/rory/sourcecode/csound-csound6-git/Engine/memalloc.c  157
> > 5  0x00007ffff79042c1  orcompact  /home/rory/sourcecode/csound-csound6-git/Engine/insert.c  813
> > 6  0x00007ffff790f714  csoundCleanup  /home/rory/sourcecode/csound-csound6-git/Engine/musmon.c  447
> > 7  0x00007ffff7a61b48  reset  /home/rory/sourcecode/csound-csound6-git/Top/csound.c  2646
> > 8  0x00007ffff7a5e64c  csoundDestroy  /home/rory/sourcecode/csound-csound6-git/Top/csound.c  1212
> > 9  0x000000000040551f  Csound::~Csound()
> > 10  0x0000000000405552  Csound::~Csound()
> > 11  0x00000000004037f6  main
> >
> > I'm not sure why ptable was 0x0 in my first report from a few days ago, it certainly seems valid now. I think I might have tried initialized it to something in an attempt go bypass this problem.
> >
> >
> > On 19 March 2014 15:19, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
> > MYFLT* temp = 0;
> > int tableSize = csound->TableLength(1);
> > csound->TableCopyOut(1, temp);
> >
> > You need memory to copy into.  Try allocating it.
> >
> >
> > ========================
> > Dr Victor Lazzarini
> > Senior Lecturer
> > NUI Maynooth, Ireland
> > victor dot lazzarini at nuim dot ie
> >
> >
> >
> >
> > On 19 Mar 2014, at 14:59, Rory Walsh <rorywalsh@ear.ie> wrote:
> >
> > > I tried to do some more digging around this but I can't see why memcpy is giving a problem. When I break at memcpy:
> > >
> > > memcpy(ptable, ftab, (size_t) (len*sizeof(MYFLT)));
> > >
> > > The values read:
> > > ptable = 0x4035c0
> > > len = 1024
> > > ftab = 0x7a2d50
> > >
> > > These addresses appear to be valid, but how would one find out for sure?
> > >
> > >
> > > On 14 March 2014 14:45, Rory Walsh <rorywalsh@ear.ie> wrote:
> > > Attached are the source and csd file that will produce the problem.
> > >
> > > Backtrace:
> > > #0  __memcpy_ssse3_back ()
> > >     at ../sysdeps/x86_64/multiarch/memcpy-ssse3-back.S:1579
> > > #1  0x00007ffff7a6b992 in csoundTableCopyOut (csound=0x609030, table=1,
> > >     ptable=0x0) at /home/rory/sourcecode/csound-csound6-git/Top/threadsafe.c:50
> > > #2  0x0000000000404e12 in Csound::TableCopyOut(int, float*) ()
> > > #3  0x0000000000403779 in main ()
> > >
> > >
> > > ------------------------------------------------------------------------------
> > > Learn Graph Databases - Download FREE O'Reilly Book
> > > "Graph Databases" is the definitive new guide to graph databases and their
> > > applications. Written by three acclaimed leaders in the field,
> > > this first edition is now available. Download your free book today!
> > > http://p.sf.net/sfu/13534_NeoTech_______________________________________________
> > > Csound-devel mailing list
> > > Csound-devel@lists.sourceforge.net
> > > https://lists.sourceforge.net/lists/listinfo/csound-devel
> >
> >
> > ------------------------------------------------------------------------------
> > Learn Graph Databases - Download FREE O'Reilly Book
> > "Graph Databases" is the definitive new guide to graph databases and their
> > applications. Written by three acclaimed leaders in the field,
> > this first edition is now available. Download your free book today!
> > http://p.sf.net/sfu/13534_NeoTech
> > _______________________________________________
> > Csound-devel mailing list
> > Csound-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/csound-devel
> >
> > ------------------------------------------------------------------------------
> > Learn Graph Databases - Download FREE O'Reilly Book
> > "Graph Databases" is the definitive new guide to graph databases and their
> > applications. Written by three acclaimed leaders in the field,
> > this first edition is now available. Download your free book today!
> > http://p.sf.net/sfu/13534_NeoTech_______________________________________________
> > Csound-devel mailing list
> > Csound-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/csound-devel
>
>
> ------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and their
> applications. Written by three acclaimed leaders in the field,
> this first edition is now available. Download your free book today!
> http://p.sf.net/sfu/13534_NeoTech
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
>
> <example1.csd>------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and their
> applications. Written by three acclaimed leaders in the field,
> this first edition is now available. Download your free book today!
> http://p.sf.net/sfu/13534_NeoTech_______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel


Date2014-03-19 19:33
FromVictor Lazzarini
SubjectRe: [Cs-dev] Problem with csoundTabbleCopyOut()
yes, no crashes with this program, on OSX

int main(int argc, char *argv[])
{
/*Create an instance of Csound*/
Csound* csound = new Csound;
csound->Compile("example1.csd");
csound->PerformKsmps();
 int testTableSize, tableSize;
std::vector temp (1024);

while(csound->PerformKsmps()==0){
    tableSize = csound->TableLength(1);
    if(testTableSize!=tableSize){
        testTableSize = tableSize;
        csound->Message("Table size is now: %d\n", testTableSize);     
    }
    temp.resize(tableSize);    
    csound->TableCopyOut(1, &temp[0]);    
}
/*delete instance of csound*/
delete csound;
//delete temp;
}

========================
Dr Victor Lazzarini
Senior Lecturer
NUI Maynooth, Ireland
victor dot lazzarini at nuim dot ie




On 19 Mar 2014, at 19:23, Rory Walsh  wrote:

> And you are using the attached .csd with the continuously changing ftables? Also, are you making those 4 calls after every csoundPerformKsmp()? I take it you are on OSX? I haven't tried this on Windows. Still trying to get it to work on Linux. Hmm.. 
> 
> 
> On 19 March 2014 19:18, Victor Lazzarini  wrote:
> I don’t know again. This works here:
> 
>  std::vector temp (1);
>  int tableSize = csound->TableLength(1);
>  temp.resize(tableSize);
>  csound->TableCopyOut(1, temp.data());
> 
> 
> ========================
> Dr Victor Lazzarini
> Senior Lecturer
> NUI Maynooth, Ireland
> victor dot lazzarini at nuim dot ie
> 
> 
> 
> 
> On 19 Mar 2014, at 17:51, Rory Walsh  wrote:
> 
> > So I'm looking for a way to access values from tables that have been resized, and in a threadsafe manor. As I need to dynamically alter my temp array I tried using a std::vector which I resize between calls to csoundPerformKsmps(). But as soon as I resize the table it gives me the same error as I was getting to start with. I've attached a csd file that uses John's ftresize opcodes and runs fine in Csound. Coupled with the code from below it will crash at the memcpy line in csoundTableCopyOut() I pointed to before. Any ideas on what I might be doing wrong? std::vector allocates memory when resize is called, and
> >
> > std::vector temp (1024);
> >
> > while(csound->PerformKsmps()==0){
> >     tableSize = csound->TableLength(1);
> >     if(testTableSize!=tableSize){
> >         testTableSize = tableSize;
> >         csound->Message("Table size is now: %d\n", testTableSize);
> >     }
> >     temp.resize(tableSize);
> >     csound->TableCopyOut(1, &temp[0]);
> > }
> >
> > Btw, I also tried with std::vector::data() which returns a direct pointer to the vector's internal array but that results in the same problem. Any ideas?
> >
> >
> >
> > On 19 March 2014 16:06, Rory Walsh  wrote:
> > Weird. It works when I use your C++ method of allocation, but causes problems when I use malloc? Anyhow, that should hopefully get me past that problem. Now to try it on a full-blown scale..
> >
> >
> > On 19 March 2014 16:00, Victor Lazzarini  wrote:
> > I don’t know: your test program works here when I allocate memory. It prints out the table too.
> >
> > int main(int argc, char *argv[])
> > {
> > /*Create an instance of Csound*/
> > Csound* csound = new Csound;
> > csound->Compile("example1.csd");
> > csound->PerformKsmps();
> > int tableSize = csound->TableLength(1);
> > printf("%d \n", tableSize);
> > MYFLT *temp = new MYFLT[tableSize];
> > csound->TableCopyOut(1, temp);
> >
> > for(int i=0;i >         printf("%f\n", temp[i]);
> >
> > csound->Perform();
> > /*delete instance of csound*/
> > delete csound;
> > delete[] temp;
> > }
> >
> > ========================
> > Dr Victor Lazzarini
> > Senior Lecturer
> > NUI Maynooth, Ireland
> > victor dot lazzarini at nuim dot ie
> >
> >
> >
> >
> > On 19 Mar 2014, at 15:34, Rory Walsh  wrote:
> >
> > > That gives the same error. I also just tried explicitly allocating enough space ala:
> > >
> > > int tableSize = csound->TableLength(1);
> > > MYFLT* temp = (MYFLT *)malloc(tableSize * sizeof(MYFLT));
> > > csound->TableCopyOut(1, temp);
> > >
> > > but that gives a whole host of new errors:
> > >
> > > 0  0x00007ffff700e425  __GI_raise  ../nptl/sysdeps/unix/sysv/linux/raise.c  64
> > > 1  0x00007ffff7011b8b  __GI_abort  abort.c  91
> > > 2  0x00007ffff704c39e  __libc_message  ../sysdeps/unix/sysv/linux/libc_fatal.c  201
> > > 3  0x00007ffff7056b96  malloc_printerr  malloc.c  5039
> > > 4  0x00007ffff790bd03  mfree  /home/rory/sourcecode/csound-csound6-git/Engine/memalloc.c  157
> > > 5  0x00007ffff79042c1  orcompact  /home/rory/sourcecode/csound-csound6-git/Engine/insert.c  813
> > > 6  0x00007ffff790f714  csoundCleanup  /home/rory/sourcecode/csound-csound6-git/Engine/musmon.c  447
> > > 7  0x00007ffff7a61b48  reset  /home/rory/sourcecode/csound-csound6-git/Top/csound.c  2646
> > > 8  0x00007ffff7a5e64c  csoundDestroy  /home/rory/sourcecode/csound-csound6-git/Top/csound.c  1212
> > > 9  0x000000000040551f  Csound::~Csound()
> > > 10  0x0000000000405552  Csound::~Csound()
> > > 11  0x00000000004037f6  main
> > >
> > > I'm not sure why ptable was 0x0 in my first report from a few days ago, it certainly seems valid now. I think I might have tried initialized it to something in an attempt go bypass this problem.
> > >
> > >
> > > On 19 March 2014 15:19, Victor Lazzarini  wrote:
> > > MYFLT* temp = 0;
> > > int tableSize = csound->TableLength(1);
> > > csound->TableCopyOut(1, temp);
> > >
> > > You need memory to copy into.  Try allocating it.
> > >
> > >
> > > ========================
> > > Dr Victor Lazzarini
> > > Senior Lecturer
> > > NUI Maynooth, Ireland
> > > victor dot lazzarini at nuim dot ie
> > >
> > >
> > >
> > >
> > > On 19 Mar 2014, at 14:59, Rory Walsh  wrote:
> > >
> > > > I tried to do some more digging around this but I can't see why memcpy is giving a problem. When I break at memcpy:
> > > >
> > > > memcpy(ptable, ftab, (size_t) (len*sizeof(MYFLT)));
> > > >
> > > > The values read:
> > > > ptable = 0x4035c0
> > > > len = 1024
> > > > ftab = 0x7a2d50
> > > >
> > > > These addresses appear to be valid, but how would one find out for sure?
> > > >
> > > >
> > > > On 14 March 2014 14:45, Rory Walsh  wrote:
> > > > Attached are the source and csd file that will produce the problem.
> > > >
> > > > Backtrace:
> > > > #0  __memcpy_ssse3_back ()
> > > >     at ../sysdeps/x86_64/multiarch/memcpy-ssse3-back.S:1579
> > > > #1  0x00007ffff7a6b992 in csoundTableCopyOut (csound=0x609030, table=1,
> > > >     ptable=0x0) at /home/rory/sourcecode/csound-csound6-git/Top/threadsafe.c:50
> > > > #2  0x0000000000404e12 in Csound::TableCopyOut(int, float*) ()
> > > > #3  0x0000000000403779 in main ()
> > > >
> > > >
> > > > ------------------------------------------------------------------------------
> > > > Learn Graph Databases - Download FREE O'Reilly Book
> > > > "Graph Databases" is the definitive new guide to graph databases and their
> > > > applications. Written by three acclaimed leaders in the field,
> > > > this first edition is now available. Download your free book today!
> > > > http://p.sf.net/sfu/13534_NeoTech_______________________________________________
> > > > Csound-devel mailing list
> > > > Csound-devel@lists.sourceforge.net
> > > > https://lists.sourceforge.net/lists/listinfo/csound-devel
> > >
> > >
> > > ------------------------------------------------------------------------------
> > > Learn Graph Databases - Download FREE O'Reilly Book
> > > "Graph Databases" is the definitive new guide to graph databases and their
> > > applications. Written by three acclaimed leaders in the field,
> > > this first edition is now available. Download your free book today!
> > > http://p.sf.net/sfu/13534_NeoTech
> > > _______________________________________________
> > > Csound-devel mailing list
> > > Csound-devel@lists.sourceforge.net
> > > https://lists.sourceforge.net/lists/listinfo/csound-devel
> > >
> > > ------------------------------------------------------------------------------
> > > Learn Graph Databases - Download FREE O'Reilly Book
> > > "Graph Databases" is the definitive new guide to graph databases and their
> > > applications. Written by three acclaimed leaders in the field,
> > > this first edition is now available. Download your free book today!
> > > http://p.sf.net/sfu/13534_NeoTech_______________________________________________
> > > Csound-devel mailing list
> > > Csound-devel@lists.sourceforge.net
> > > https://lists.sourceforge.net/lists/listinfo/csound-devel
> >
> >
> > ------------------------------------------------------------------------------
> > Learn Graph Databases - Download FREE O'Reilly Book
> > "Graph Databases" is the definitive new guide to graph databases and their
> > applications. Written by three acclaimed leaders in the field,
> > this first edition is now available. Download your free book today!
> > http://p.sf.net/sfu/13534_NeoTech
> > _______________________________________________
> > Csound-devel mailing list
> > Csound-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/csound-devel
> >
> >
> > ------------------------------------------------------------------------------
> > Learn Graph Databases - Download FREE O'Reilly Book
> > "Graph Databases" is the definitive new guide to graph databases and their
> > applications. Written by three acclaimed leaders in the field,
> > this first edition is now available. Download your free book today!
> > http://p.sf.net/sfu/13534_NeoTech_______________________________________________
> > Csound-devel mailing list
> > Csound-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/csound-devel
> 
> 
> ------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and their
> applications. Written by three acclaimed leaders in the field,
> this first edition is now available. Download your free book today!
> http://p.sf.net/sfu/13534_NeoTech
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
> 
> ------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and their
> applications. Written by three acclaimed leaders in the field,
> this first edition is now available. Download your free book today!
> http://p.sf.net/sfu/13534_NeoTech_______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2014-03-19 19:36
FromRory Walsh
SubjectRe: [Cs-dev] Problem with csoundTabbleCopyOut()
AttachmentsNone  None  
I'm stumped. I'm using the latest develop code from git. I'll try it out on windows and see how it goes. For now I'm changing tact. I think it probably better to write recordings to a temp file on disk, and then load that into a function table if users wish to edit it. I would still like the option of resizing tables on the fly though. But I can work around it for now.  


On 19 March 2014 19:33, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
yes, no crashes with this program, on OSX

int main(int argc, char *argv[])
{
/*Create an instance of Csound*/
Csound* csound = new Csound;
csound->Compile("example1.csd");
csound->PerformKsmps();
 int testTableSize, tableSize;
std::vector<MYFLT> temp (1024);

while(csound->PerformKsmps()==0){
    tableSize = csound->TableLength(1);
    if(testTableSize!=tableSize){
        testTableSize = tableSize;
        csound->Message("Table size is now: %d\n", testTableSize);
    }
    temp.resize(tableSize);
    csound->TableCopyOut(1, &temp[0]);
}
/*delete instance of csound*/
delete csound;
//delete temp;
}

========================
Dr Victor Lazzarini
Senior Lecturer
NUI Maynooth, Ireland
victor dot lazzarini at nuim dot ie




On 19 Mar 2014, at 19:23, Rory Walsh <rorywalsh@ear.ie> wrote:

> And you are using the attached .csd with the continuously changing ftables? Also, are you making those 4 calls after every csoundPerformKsmp()? I take it you are on OSX? I haven't tried this on Windows. Still trying to get it to work on Linux. Hmm..
>
>
> On 19 March 2014 19:18, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
> I don’t know again. This works here:
>
>  std::vector<MYFLT> temp (1);
>  int tableSize = csound->TableLength(1);
>  temp.resize(tableSize);
>  csound->TableCopyOut(1, temp.data());
>
>
> ========================
> Dr Victor Lazzarini
> Senior Lecturer
> NUI Maynooth, Ireland
> victor dot lazzarini at nuim dot ie
>
>
>
>
> On 19 Mar 2014, at 17:51, Rory Walsh <rorywalsh@ear.ie> wrote:
>
> > So I'm looking for a way to access values from tables that have been resized, and in a threadsafe manor. As I need to dynamically alter my temp array I tried using a std::vector which I resize between calls to csoundPerformKsmps(). But as soon as I resize the table it gives me the same error as I was getting to start with. I've attached a csd file that uses John's ftresize opcodes and runs fine in Csound. Coupled with the code from below it will crash at the memcpy line in csoundTableCopyOut() I pointed to before. Any ideas on what I might be doing wrong? std::vector allocates memory when resize is called, and
> >
> > std::vector<MYFLT> temp (1024);
> >
> > while(csound->PerformKsmps()==0){
> >     tableSize = csound->TableLength(1);
> >     if(testTableSize!=tableSize){
> >         testTableSize = tableSize;
> >         csound->Message("Table size is now: %d\n", testTableSize);
> >     }
> >     temp.resize(tableSize);
> >     csound->TableCopyOut(1, &temp[0]);
> > }
> >
> > Btw, I also tried with std::vector::data() which returns a direct pointer to the vector's internal array but that results in the same problem. Any ideas?
> >
> >
> >
> > On 19 March 2014 16:06, Rory Walsh <rorywalsh@ear.ie> wrote:
> > Weird. It works when I use your C++ method of allocation, but causes problems when I use malloc? Anyhow, that should hopefully get me past that problem. Now to try it on a full-blown scale..
> >
> >
> > On 19 March 2014 16:00, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
> > I don’t know: your test program works here when I allocate memory. It prints out the table too.
> >
> > int main(int argc, char *argv[])
> > {
> > /*Create an instance of Csound*/
> > Csound* csound = new Csound;
> > csound->Compile("example1.csd");
> > csound->PerformKsmps();
> > int tableSize = csound->TableLength(1);
> > printf("%d \n", tableSize);
> > MYFLT *temp = new MYFLT[tableSize];
> > csound->TableCopyOut(1, temp);
> >
> > for(int i=0;i<tableSize;i++)
> >         printf("%f\n", temp[i]);
> >
> > csound->Perform();
> > /*delete instance of csound*/
> > delete csound;
> > delete[] temp;
> > }
> >
> > ========================
> > Dr Victor Lazzarini
> > Senior Lecturer
> > NUI Maynooth, Ireland
> > victor dot lazzarini at nuim dot ie
> >
> >
> >
> >
> > On 19 Mar 2014, at 15:34, Rory Walsh <rorywalsh@ear.ie> wrote:
> >
> > > That gives the same error. I also just tried explicitly allocating enough space ala:
> > >
> > > int tableSize = csound->TableLength(1);
> > > MYFLT* temp = (MYFLT *)malloc(tableSize * sizeof(MYFLT));
> > > csound->TableCopyOut(1, temp);
> > >
> > > but that gives a whole host of new errors:
> > >
> > > 0  0x00007ffff700e425  __GI_raise  ../nptl/sysdeps/unix/sysv/linux/raise.c  64
> > > 1  0x00007ffff7011b8b  __GI_abort  abort.c  91
> > > 2  0x00007ffff704c39e  __libc_message  ../sysdeps/unix/sysv/linux/libc_fatal.c  201
> > > 3  0x00007ffff7056b96  malloc_printerr  malloc.c  5039
> > > 4  0x00007ffff790bd03  mfree  /home/rory/sourcecode/csound-csound6-git/Engine/memalloc.c  157
> > > 5  0x00007ffff79042c1  orcompact  /home/rory/sourcecode/csound-csound6-git/Engine/insert.c  813
> > > 6  0x00007ffff790f714  csoundCleanup  /home/rory/sourcecode/csound-csound6-git/Engine/musmon.c  447
> > > 7  0x00007ffff7a61b48  reset  /home/rory/sourcecode/csound-csound6-git/Top/csound.c  2646
> > > 8  0x00007ffff7a5e64c  csoundDestroy  /home/rory/sourcecode/csound-csound6-git/Top/csound.c  1212
> > > 9  0x000000000040551f  Csound::~Csound()
> > > 10  0x0000000000405552  Csound::~Csound()
> > > 11  0x00000000004037f6  main
> > >
> > > I'm not sure why ptable was 0x0 in my first report from a few days ago, it certainly seems valid now. I think I might have tried initialized it to something in an attempt go bypass this problem.
> > >
> > >
> > > On 19 March 2014 15:19, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
> > > MYFLT* temp = 0;
> > > int tableSize = csound->TableLength(1);
> > > csound->TableCopyOut(1, temp);
> > >
> > > You need memory to copy into.  Try allocating it.
> > >
> > >
> > > ========================
> > > Dr Victor Lazzarini
> > > Senior Lecturer
> > > NUI Maynooth, Ireland
> > > victor dot lazzarini at nuim dot ie
> > >
> > >
> > >
> > >
> > > On 19 Mar 2014, at 14:59, Rory Walsh <rorywalsh@ear.ie> wrote:
> > >
> > > > I tried to do some more digging around this but I can't see why memcpy is giving a problem. When I break at memcpy:
> > > >
> > > > memcpy(ptable, ftab, (size_t) (len*sizeof(MYFLT)));
> > > >
> > > > The values read:
> > > > ptable = 0x4035c0
> > > > len = 1024
> > > > ftab = 0x7a2d50
> > > >
> > > > These addresses appear to be valid, but how would one find out for sure?
> > > >
> > > >
> > > > On 14 March 2014 14:45, Rory Walsh <rorywalsh@ear.ie> wrote:
> > > > Attached are the source and csd file that will produce the problem.
> > > >
> > > > Backtrace:
> > > > #0  __memcpy_ssse3_back ()
> > > >     at ../sysdeps/x86_64/multiarch/memcpy-ssse3-back.S:1579
> > > > #1  0x00007ffff7a6b992 in csoundTableCopyOut (csound=0x609030, table=1,
> > > >     ptable=0x0) at /home/rory/sourcecode/csound-csound6-git/Top/threadsafe.c:50
> > > > #2  0x0000000000404e12 in Csound::TableCopyOut(int, float*) ()
> > > > #3  0x0000000000403779 in main ()
> > > >
> > > >
> > > > ------------------------------------------------------------------------------
> > > > Learn Graph Databases - Download FREE O'Reilly Book
> > > > "Graph Databases" is the definitive new guide to graph databases and their
> > > > applications. Written by three acclaimed leaders in the field,
> > > > this first edition is now available. Download your free book today!
> > > > http://p.sf.net/sfu/13534_NeoTech_______________________________________________
> > > > Csound-devel mailing list
> > > > Csound-devel@lists.sourceforge.net
> > > > https://lists.sourceforge.net/lists/listinfo/csound-devel
> > >
> > >
> > > ------------------------------------------------------------------------------
> > > Learn Graph Databases - Download FREE O'Reilly Book
> > > "Graph Databases" is the definitive new guide to graph databases and their
> > > applications. Written by three acclaimed leaders in the field,
> > > this first edition is now available. Download your free book today!
> > > http://p.sf.net/sfu/13534_NeoTech
> > > _______________________________________________
> > > Csound-devel mailing list
> > > Csound-devel@lists.sourceforge.net
> > > https://lists.sourceforge.net/lists/listinfo/csound-devel
> > >
> > > ------------------------------------------------------------------------------
> > > Learn Graph Databases - Download FREE O'Reilly Book
> > > "Graph Databases" is the definitive new guide to graph databases and their
> > > applications. Written by three acclaimed leaders in the field,
> > > this first edition is now available. Download your free book today!
> > > http://p.sf.net/sfu/13534_NeoTech_______________________________________________
> > > Csound-devel mailing list
> > > Csound-devel@lists.sourceforge.net
> > > https://lists.sourceforge.net/lists/listinfo/csound-devel
> >
> >
> > ------------------------------------------------------------------------------
> > Learn Graph Databases - Download FREE O'Reilly Book
> > "Graph Databases" is the definitive new guide to graph databases and their
> > applications. Written by three acclaimed leaders in the field,
> > this first edition is now available. Download your free book today!
> > http://p.sf.net/sfu/13534_NeoTech
> > _______________________________________________
> > Csound-devel mailing list
> > Csound-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/csound-devel
> >
> >
> > <example1.csd>------------------------------------------------------------------------------
> > Learn Graph Databases - Download FREE O'Reilly Book
> > "Graph Databases" is the definitive new guide to graph databases and their
> > applications. Written by three acclaimed leaders in the field,
> > this first edition is now available. Download your free book today!
> > http://p.sf.net/sfu/13534_NeoTech_______________________________________________
> > Csound-devel mailing list
> > Csound-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/csound-devel
>
>
> ------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and their
> applications. Written by three acclaimed leaders in the field,
> this first edition is now available. Download your free book today!
> http://p.sf.net/sfu/13534_NeoTech
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
> ------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and their
> applications. Written by three acclaimed leaders in the field,
> this first edition is now available. Download your free book today!
> http://p.sf.net/sfu/13534_NeoTech_______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel


Date2014-03-19 22:53
FromSteven Yi
SubjectRe: [Cs-dev] Problem with csoundTabbleCopyOut()
Just to double-check, did you define MYFLT=double?

On Wed, Mar 19, 2014 at 3:36 PM, Rory Walsh  wrote:
> I'm stumped. I'm using the latest develop code from git. I'll try it out on
> windows and see how it goes. For now I'm changing tact. I think it probably
> better to write recordings to a temp file on disk, and then load that into a
> function table if users wish to edit it. I would still like the option of
> resizing tables on the fly though. But I can work around it for now.
>
>
> On 19 March 2014 19:33, Victor Lazzarini  wrote:
>>
>> yes, no crashes with this program, on OSX
>>
>> int main(int argc, char *argv[])
>> {
>> /*Create an instance of Csound*/
>> Csound* csound = new Csound;
>> csound->Compile("example1.csd");
>> csound->PerformKsmps();
>>  int testTableSize, tableSize;
>> std::vector temp (1024);
>>
>> while(csound->PerformKsmps()==0){
>>     tableSize = csound->TableLength(1);
>>     if(testTableSize!=tableSize){
>>         testTableSize = tableSize;
>>         csound->Message("Table size is now: %d\n", testTableSize);
>>     }
>>     temp.resize(tableSize);
>>     csound->TableCopyOut(1, &temp[0]);
>> }
>> /*delete instance of csound*/
>> delete csound;
>> //delete temp;
>> }
>>
>> ========================
>> Dr Victor Lazzarini
>> Senior Lecturer
>> NUI Maynooth, Ireland
>> victor dot lazzarini at nuim dot ie
>>
>>
>>
>>
>> On 19 Mar 2014, at 19:23, Rory Walsh  wrote:
>>
>> > And you are using the attached .csd with the continuously changing
>> > ftables? Also, are you making those 4 calls after every csoundPerformKsmp()?
>> > I take it you are on OSX? I haven't tried this on Windows. Still trying to
>> > get it to work on Linux. Hmm..
>> >
>> >
>> > On 19 March 2014 19:18, Victor Lazzarini 
>> > wrote:
>> > I don't know again. This works here:
>> >
>> >  std::vector temp (1);
>> >  int tableSize = csound->TableLength(1);
>> >  temp.resize(tableSize);
>> >  csound->TableCopyOut(1, temp.data());
>> >
>> >
>> > ========================
>> > Dr Victor Lazzarini
>> > Senior Lecturer
>> > NUI Maynooth, Ireland
>> > victor dot lazzarini at nuim dot ie
>> >
>> >
>> >
>> >
>> > On 19 Mar 2014, at 17:51, Rory Walsh  wrote:
>> >
>> > > So I'm looking for a way to access values from tables that have been
>> > > resized, and in a threadsafe manor. As I need to dynamically alter my temp
>> > > array I tried using a std::vector which I resize between calls to
>> > > csoundPerformKsmps(). But as soon as I resize the table it gives me the same
>> > > error as I was getting to start with. I've attached a csd file that uses
>> > > John's ftresize opcodes and runs fine in Csound. Coupled with the code from
>> > > below it will crash at the memcpy line in csoundTableCopyOut() I pointed to
>> > > before. Any ideas on what I might be doing wrong? std::vector allocates
>> > > memory when resize is called, and
>> > >
>> > > std::vector temp (1024);
>> > >
>> > > while(csound->PerformKsmps()==0){
>> > >     tableSize = csound->TableLength(1);
>> > >     if(testTableSize!=tableSize){
>> > >         testTableSize = tableSize;
>> > >         csound->Message("Table size is now: %d\n", testTableSize);
>> > >     }
>> > >     temp.resize(tableSize);
>> > >     csound->TableCopyOut(1, &temp[0]);
>> > > }
>> > >
>> > > Btw, I also tried with std::vector::data() which returns a direct
>> > > pointer to the vector's internal array but that results in the same problem.
>> > > Any ideas?
>> > >
>> > >
>> > >
>> > > On 19 March 2014 16:06, Rory Walsh  wrote:
>> > > Weird. It works when I use your C++ method of allocation, but causes
>> > > problems when I use malloc? Anyhow, that should hopefully get me past that
>> > > problem. Now to try it on a full-blown scale..
>> > >
>> > >
>> > > On 19 March 2014 16:00, Victor Lazzarini 
>> > > wrote:
>> > > I don't know: your test program works here when I allocate memory. It
>> > > prints out the table too.
>> > >
>> > > int main(int argc, char *argv[])
>> > > {
>> > > /*Create an instance of Csound*/
>> > > Csound* csound = new Csound;
>> > > csound->Compile("example1.csd");
>> > > csound->PerformKsmps();
>> > > int tableSize = csound->TableLength(1);
>> > > printf("%d \n", tableSize);
>> > > MYFLT *temp = new MYFLT[tableSize];
>> > > csound->TableCopyOut(1, temp);
>> > >
>> > > for(int i=0;i> > >         printf("%f\n", temp[i]);
>> > >
>> > > csound->Perform();
>> > > /*delete instance of csound*/
>> > > delete csound;
>> > > delete[] temp;
>> > > }
>> > >
>> > > ========================
>> > > Dr Victor Lazzarini
>> > > Senior Lecturer
>> > > NUI Maynooth, Ireland
>> > > victor dot lazzarini at nuim dot ie
>> > >
>> > >
>> > >
>> > >
>> > > On 19 Mar 2014, at 15:34, Rory Walsh  wrote:
>> > >
>> > > > That gives the same error. I also just tried explicitly allocating
>> > > > enough space ala:
>> > > >
>> > > > int tableSize = csound->TableLength(1);
>> > > > MYFLT* temp = (MYFLT *)malloc(tableSize * sizeof(MYFLT));
>> > > > csound->TableCopyOut(1, temp);
>> > > >
>> > > > but that gives a whole host of new errors:
>> > > >
>> > > > 0  0x00007ffff700e425  __GI_raise
>> > > > ../nptl/sysdeps/unix/sysv/linux/raise.c  64
>> > > > 1  0x00007ffff7011b8b  __GI_abort  abort.c  91
>> > > > 2  0x00007ffff704c39e  __libc_message
>> > > > ../sysdeps/unix/sysv/linux/libc_fatal.c  201
>> > > > 3  0x00007ffff7056b96  malloc_printerr  malloc.c  5039
>> > > > 4  0x00007ffff790bd03  mfree
>> > > > /home/rory/sourcecode/csound-csound6-git/Engine/memalloc.c  157
>> > > > 5  0x00007ffff79042c1  orcompact
>> > > > /home/rory/sourcecode/csound-csound6-git/Engine/insert.c  813
>> > > > 6  0x00007ffff790f714  csoundCleanup
>> > > > /home/rory/sourcecode/csound-csound6-git/Engine/musmon.c  447
>> > > > 7  0x00007ffff7a61b48  reset
>> > > > /home/rory/sourcecode/csound-csound6-git/Top/csound.c  2646
>> > > > 8  0x00007ffff7a5e64c  csoundDestroy
>> > > > /home/rory/sourcecode/csound-csound6-git/Top/csound.c  1212
>> > > > 9  0x000000000040551f  Csound::~Csound()
>> > > > 10  0x0000000000405552  Csound::~Csound()
>> > > > 11  0x00000000004037f6  main
>> > > >
>> > > > I'm not sure why ptable was 0x0 in my first report from a few days
>> > > > ago, it certainly seems valid now. I think I might have tried initialized it
>> > > > to something in an attempt go bypass this problem.
>> > > >
>> > > >
>> > > > On 19 March 2014 15:19, Victor Lazzarini 
>> > > > wrote:
>> > > > MYFLT* temp = 0;
>> > > > int tableSize = csound->TableLength(1);
>> > > > csound->TableCopyOut(1, temp);
>> > > >
>> > > > You need memory to copy into.  Try allocating it.
>> > > >
>> > > >
>> > > > ========================
>> > > > Dr Victor Lazzarini
>> > > > Senior Lecturer
>> > > > NUI Maynooth, Ireland
>> > > > victor dot lazzarini at nuim dot ie
>> > > >
>> > > >
>> > > >
>> > > >
>> > > > On 19 Mar 2014, at 14:59, Rory Walsh  wrote:
>> > > >
>> > > > > I tried to do some more digging around this but I can't see why
>> > > > > memcpy is giving a problem. When I break at memcpy:
>> > > > >
>> > > > > memcpy(ptable, ftab, (size_t) (len*sizeof(MYFLT)));
>> > > > >
>> > > > > The values read:
>> > > > > ptable = 0x4035c0
>> > > > > len = 1024
>> > > > > ftab = 0x7a2d50
>> > > > >
>> > > > > These addresses appear to be valid, but how would one find out for
>> > > > > sure?
>> > > > >
>> > > > >
>> > > > > On 14 March 2014 14:45, Rory Walsh  wrote:
>> > > > > Attached are the source and csd file that will produce the
>> > > > > problem.
>> > > > >
>> > > > > Backtrace:
>> > > > > #0  __memcpy_ssse3_back ()
>> > > > >     at ../sysdeps/x86_64/multiarch/memcpy-ssse3-back.S:1579
>> > > > > #1  0x00007ffff7a6b992 in csoundTableCopyOut (csound=0x609030,
>> > > > > table=1,
>> > > > >     ptable=0x0) at
>> > > > > /home/rory/sourcecode/csound-csound6-git/Top/threadsafe.c:50
>> > > > > #2  0x0000000000404e12 in Csound::TableCopyOut(int, float*) ()
>> > > > > #3  0x0000000000403779 in main ()
>> > > > >
>> > > > >
>> > > > >
>> > > > > ------------------------------------------------------------------------------
>> > > > > Learn Graph Databases - Download FREE O'Reilly Book
>> > > > > "Graph Databases" is the definitive new guide to graph databases
>> > > > > and their
>> > > > > applications. Written by three acclaimed leaders in the field,
>> > > > > this first edition is now available. Download your free book
>> > > > > today!
>> > > > >
>> > > > > http://p.sf.net/sfu/13534_NeoTech_______________________________________________
>> > > > > Csound-devel mailing list
>> > > > > Csound-devel@lists.sourceforge.net
>> > > > > https://lists.sourceforge.net/lists/listinfo/csound-devel
>> > > >
>> > > >
>> > > >
>> > > > ------------------------------------------------------------------------------
>> > > > Learn Graph Databases - Download FREE O'Reilly Book
>> > > > "Graph Databases" is the definitive new guide to graph databases and
>> > > > their
>> > > > applications. Written by three acclaimed leaders in the field,
>> > > > this first edition is now available. Download your free book today!
>> > > > http://p.sf.net/sfu/13534_NeoTech
>> > > > _______________________________________________
>> > > > Csound-devel mailing list
>> > > > Csound-devel@lists.sourceforge.net
>> > > > https://lists.sourceforge.net/lists/listinfo/csound-devel
>> > > >
>> > > >
>> > > > ------------------------------------------------------------------------------
>> > > > Learn Graph Databases - Download FREE O'Reilly Book
>> > > > "Graph Databases" is the definitive new guide to graph databases and
>> > > > their
>> > > > applications. Written by three acclaimed leaders in the field,
>> > > > this first edition is now available. Download your free book today!
>> > > >
>> > > > http://p.sf.net/sfu/13534_NeoTech_______________________________________________
>> > > > Csound-devel mailing list
>> > > > Csound-devel@lists.sourceforge.net
>> > > > https://lists.sourceforge.net/lists/listinfo/csound-devel
>> > >
>> > >
>> > >
>> > > ------------------------------------------------------------------------------
>> > > Learn Graph Databases - Download FREE O'Reilly Book
>> > > "Graph Databases" is the definitive new guide to graph databases and
>> > > their
>> > > applications. Written by three acclaimed leaders in the field,
>> > > this first edition is now available. Download your free book today!
>> > > http://p.sf.net/sfu/13534_NeoTech
>> > > _______________________________________________
>> > > Csound-devel mailing list
>> > > Csound-devel@lists.sourceforge.net
>> > > https://lists.sourceforge.net/lists/listinfo/csound-devel
>> > >
>> > >
>> > >
>> > > ------------------------------------------------------------------------------
>> > > Learn Graph Databases - Download FREE O'Reilly Book
>> > > "Graph Databases" is the definitive new guide to graph databases and
>> > > their
>> > > applications. Written by three acclaimed leaders in the field,
>> > > this first edition is now available. Download your free book today!
>> > >
>> > > http://p.sf.net/sfu/13534_NeoTech_______________________________________________
>> > > Csound-devel mailing list
>> > > Csound-devel@lists.sourceforge.net
>> > > https://lists.sourceforge.net/lists/listinfo/csound-devel
>> >
>> >
>> >
>> > ------------------------------------------------------------------------------
>> > Learn Graph Databases - Download FREE O'Reilly Book
>> > "Graph Databases" is the definitive new guide to graph databases and
>> > their
>> > applications. Written by three acclaimed leaders in the field,
>> > this first edition is now available. Download your free book today!
>> > http://p.sf.net/sfu/13534_NeoTech
>> > _______________________________________________
>> > Csound-devel mailing list
>> > Csound-devel@lists.sourceforge.net
>> > https://lists.sourceforge.net/lists/listinfo/csound-devel
>> >
>> >
>> > ------------------------------------------------------------------------------
>> > Learn Graph Databases - Download FREE O'Reilly Book
>> > "Graph Databases" is the definitive new guide to graph databases and
>> > their
>> > applications. Written by three acclaimed leaders in the field,
>> > this first edition is now available. Download your free book today!
>> >
>> > http://p.sf.net/sfu/13534_NeoTech_______________________________________________
>> > Csound-devel mailing list
>> > Csound-devel@lists.sourceforge.net
>> > https://lists.sourceforge.net/lists/listinfo/csound-devel
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Learn Graph Databases - Download FREE O'Reilly Book
>> "Graph Databases" is the definitive new guide to graph databases and their
>> applications. Written by three acclaimed leaders in the field,
>> this first edition is now available. Download your free book today!
>> http://p.sf.net/sfu/13534_NeoTech
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
>
>
> ------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and their
> applications. Written by three acclaimed leaders in the field,
> this first edition is now available. Download your free book today!
> http://p.sf.net/sfu/13534_NeoTech
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2014-03-19 23:25
FromRory Walsh
SubjectRe: [Cs-dev] Problem with csoundTabbleCopyOut()
AttachmentsNone  None  
I didn't for the basic example I was testing, but I do for Cabbage and it bombs there too. So I just tried now the following command line, but no luck:

g++ test.cpp -I../include -L. -lcsound64 -D "USE_DOUBLE=1" -g -o testApp

I'll try windows tomorrow and see if I get any different results.


On 19 March 2014 22:53, Steven Yi <stevenyi@gmail.com> wrote:
Just to double-check, did you define MYFLT=double?

On Wed, Mar 19, 2014 at 3:36 PM, Rory Walsh <rorywalsh@ear.ie> wrote:
> I'm stumped. I'm using the latest develop code from git. I'll try it out on
> windows and see how it goes. For now I'm changing tact. I think it probably
> better to write recordings to a temp file on disk, and then load that into a
> function table if users wish to edit it. I would still like the option of
> resizing tables on the fly though. But I can work around it for now.
>
>
> On 19 March 2014 19:33, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
>>
>> yes, no crashes with this program, on OSX
>>
>> int main(int argc, char *argv[])
>> {
>> /*Create an instance of Csound*/
>> Csound* csound = new Csound;
>> csound->Compile("example1.csd");
>> csound->PerformKsmps();
>>  int testTableSize, tableSize;
>> std::vector<MYFLT> temp (1024);
>>
>> while(csound->PerformKsmps()==0){
>>     tableSize = csound->TableLength(1);
>>     if(testTableSize!=tableSize){
>>         testTableSize = tableSize;
>>         csound->Message("Table size is now: %d\n", testTableSize);
>>     }
>>     temp.resize(tableSize);
>>     csound->TableCopyOut(1, &temp[0]);
>> }
>> /*delete instance of csound*/
>> delete csound;
>> //delete temp;
>> }
>>
>> ========================
>> Dr Victor Lazzarini
>> Senior Lecturer
>> NUI Maynooth, Ireland
>> victor dot lazzarini at nuim dot ie
>>
>>
>>
>>
>> On 19 Mar 2014, at 19:23, Rory Walsh <rorywalsh@ear.ie> wrote:
>>
>> > And you are using the attached .csd with the continuously changing
>> > ftables? Also, are you making those 4 calls after every csoundPerformKsmp()?
>> > I take it you are on OSX? I haven't tried this on Windows. Still trying to
>> > get it to work on Linux. Hmm..
>> >
>> >
>> > On 19 March 2014 19:18, Victor Lazzarini <Victor.Lazzarini@nuim.ie>
>> > wrote:
>> > I don't know again. This works here:
>> >
>> >  std::vector<MYFLT> temp (1);
>> >  int tableSize = csound->TableLength(1);
>> >  temp.resize(tableSize);
>> >  csound->TableCopyOut(1, temp.data());
>> >
>> >
>> > ========================
>> > Dr Victor Lazzarini
>> > Senior Lecturer
>> > NUI Maynooth, Ireland
>> > victor dot lazzarini at nuim dot ie
>> >
>> >
>> >
>> >
>> > On 19 Mar 2014, at 17:51, Rory Walsh <rorywalsh@ear.ie> wrote:
>> >
>> > > So I'm looking for a way to access values from tables that have been
>> > > resized, and in a threadsafe manor. As I need to dynamically alter my temp
>> > > array I tried using a std::vector which I resize between calls to
>> > > csoundPerformKsmps(). But as soon as I resize the table it gives me the same
>> > > error as I was getting to start with. I've attached a csd file that uses
>> > > John's ftresize opcodes and runs fine in Csound. Coupled with the code from
>> > > below it will crash at the memcpy line in csoundTableCopyOut() I pointed to
>> > > before. Any ideas on what I might be doing wrong? std::vector allocates
>> > > memory when resize is called, and
>> > >
>> > > std::vector<MYFLT> temp (1024);
>> > >
>> > > while(csound->PerformKsmps()==0){
>> > >     tableSize = csound->TableLength(1);
>> > >     if(testTableSize!=tableSize){
>> > >         testTableSize = tableSize;
>> > >         csound->Message("Table size is now: %d\n", testTableSize);
>> > >     }
>> > >     temp.resize(tableSize);
>> > >     csound->TableCopyOut(1, &temp[0]);
>> > > }
>> > >
>> > > Btw, I also tried with std::vector::data() which returns a direct
>> > > pointer to the vector's internal array but that results in the same problem.
>> > > Any ideas?
>> > >
>> > >
>> > >
>> > > On 19 March 2014 16:06, Rory Walsh <rorywalsh@ear.ie> wrote:
>> > > Weird. It works when I use your C++ method of allocation, but causes
>> > > problems when I use malloc? Anyhow, that should hopefully get me past that
>> > > problem. Now to try it on a full-blown scale..
>> > >
>> > >
>> > > On 19 March 2014 16:00, Victor Lazzarini <Victor.Lazzarini@nuim.ie>
>> > > wrote:
>> > > I don't know: your test program works here when I allocate memory. It
>> > > prints out the table too.
>> > >
>> > > int main(int argc, char *argv[])
>> > > {
>> > > /*Create an instance of Csound*/
>> > > Csound* csound = new Csound;
>> > > csound->Compile("example1.csd");
>> > > csound->PerformKsmps();
>> > > int tableSize = csound->TableLength(1);
>> > > printf("%d \n", tableSize);
>> > > MYFLT *temp = new MYFLT[tableSize];
>> > > csound->TableCopyOut(1, temp);
>> > >
>> > > for(int i=0;i<tableSize;i++)
>> > >         printf("%f\n", temp[i]);
>> > >
>> > > csound->Perform();
>> > > /*delete instance of csound*/
>> > > delete csound;
>> > > delete[] temp;
>> > > }
>> > >
>> > > ========================
>> > > Dr Victor Lazzarini
>> > > Senior Lecturer
>> > > NUI Maynooth, Ireland
>> > > victor dot lazzarini at nuim dot ie
>> > >
>> > >
>> > >
>> > >
>> > > On 19 Mar 2014, at 15:34, Rory Walsh <rorywalsh@ear.ie> wrote:
>> > >
>> > > > That gives the same error. I also just tried explicitly allocating
>> > > > enough space ala:
>> > > >
>> > > > int tableSize = csound->TableLength(1);
>> > > > MYFLT* temp = (MYFLT *)malloc(tableSize * sizeof(MYFLT));
>> > > > csound->TableCopyOut(1, temp);
>> > > >
>> > > > but that gives a whole host of new errors:
>> > > >
>> > > > 0  0x00007ffff700e425  __GI_raise
>> > > > ../nptl/sysdeps/unix/sysv/linux/raise.c  64
>> > > > 1  0x00007ffff7011b8b  __GI_abort  abort.c  91
>> > > > 2  0x00007ffff704c39e  __libc_message
>> > > > ../sysdeps/unix/sysv/linux/libc_fatal.c  201
>> > > > 3  0x00007ffff7056b96  malloc_printerr  malloc.c  5039
>> > > > 4  0x00007ffff790bd03  mfree
>> > > > /home/rory/sourcecode/csound-csound6-git/Engine/memalloc.c  157
>> > > > 5  0x00007ffff79042c1  orcompact
>> > > > /home/rory/sourcecode/csound-csound6-git/Engine/insert.c  813
>> > > > 6  0x00007ffff790f714  csoundCleanup
>> > > > /home/rory/sourcecode/csound-csound6-git/Engine/musmon.c  447
>> > > > 7  0x00007ffff7a61b48  reset
>> > > > /home/rory/sourcecode/csound-csound6-git/Top/csound.c  2646
>> > > > 8  0x00007ffff7a5e64c  csoundDestroy
>> > > > /home/rory/sourcecode/csound-csound6-git/Top/csound.c  1212
>> > > > 9  0x000000000040551f  Csound::~Csound()
>> > > > 10  0x0000000000405552  Csound::~Csound()
>> > > > 11  0x00000000004037f6  main
>> > > >
>> > > > I'm not sure why ptable was 0x0 in my first report from a few days
>> > > > ago, it certainly seems valid now. I think I might have tried initialized it
>> > > > to something in an attempt go bypass this problem.
>> > > >
>> > > >
>> > > > On 19 March 2014 15:19, Victor Lazzarini <Victor.Lazzarini@nuim.ie>
>> > > > wrote:
>> > > > MYFLT* temp = 0;
>> > > > int tableSize = csound->TableLength(1);
>> > > > csound->TableCopyOut(1, temp);
>> > > >
>> > > > You need memory to copy into.  Try allocating it.
>> > > >
>> > > >
>> > > > ========================
>> > > > Dr Victor Lazzarini
>> > > > Senior Lecturer
>> > > > NUI Maynooth, Ireland
>> > > > victor dot lazzarini at nuim dot ie
>> > > >
>> > > >
>> > > >
>> > > >
>> > > > On 19 Mar 2014, at 14:59, Rory Walsh <rorywalsh@ear.ie> wrote:
>> > > >
>> > > > > I tried to do some more digging around this but I can't see why
>> > > > > memcpy is giving a problem. When I break at memcpy:
>> > > > >
>> > > > > memcpy(ptable, ftab, (size_t) (len*sizeof(MYFLT)));
>> > > > >
>> > > > > The values read:
>> > > > > ptable = 0x4035c0
>> > > > > len = 1024
>> > > > > ftab = 0x7a2d50
>> > > > >
>> > > > > These addresses appear to be valid, but how would one find out for
>> > > > > sure?
>> > > > >
>> > > > >
>> > > > > On 14 March 2014 14:45, Rory Walsh <rorywalsh@ear.ie> wrote:
>> > > > > Attached are the source and csd file that will produce the
>> > > > > problem.
>> > > > >
>> > > > > Backtrace:
>> > > > > #0  __memcpy_ssse3_back ()
>> > > > >     at ../sysdeps/x86_64/multiarch/memcpy-ssse3-back.S:1579
>> > > > > #1  0x00007ffff7a6b992 in csoundTableCopyOut (csound=0x609030,
>> > > > > table=1,
>> > > > >     ptable=0x0) at
>> > > > > /home/rory/sourcecode/csound-csound6-git/Top/threadsafe.c:50
>> > > > > #2  0x0000000000404e12 in Csound::TableCopyOut(int, float*) ()
>> > > > > #3  0x0000000000403779 in main ()
>> > > > >
>> > > > >
>> > > > >
>> > > > > ------------------------------------------------------------------------------
>> > > > > Learn Graph Databases - Download FREE O'Reilly Book
>> > > > > "Graph Databases" is the definitive new guide to graph databases
>> > > > > and their
>> > > > > applications. Written by three acclaimed leaders in the field,
>> > > > > this first edition is now available. Download your free book
>> > > > > today!
>> > > > >
>> > > > > http://p.sf.net/sfu/13534_NeoTech_______________________________________________
>> > > > > Csound-devel mailing list
>> > > > > Csound-devel@lists.sourceforge.net
>> > > > > https://lists.sourceforge.net/lists/listinfo/csound-devel
>> > > >
>> > > >
>> > > >
>> > > > ------------------------------------------------------------------------------
>> > > > Learn Graph Databases - Download FREE O'Reilly Book
>> > > > "Graph Databases" is the definitive new guide to graph databases and
>> > > > their
>> > > > applications. Written by three acclaimed leaders in the field,
>> > > > this first edition is now available. Download your free book today!
>> > > > http://p.sf.net/sfu/13534_NeoTech
>> > > > _______________________________________________
>> > > > Csound-devel mailing list
>> > > > Csound-devel@lists.sourceforge.net
>> > > > https://lists.sourceforge.net/lists/listinfo/csound-devel
>> > > >
>> > > >
>> > > > ------------------------------------------------------------------------------
>> > > > Learn Graph Databases - Download FREE O'Reilly Book
>> > > > "Graph Databases" is the definitive new guide to graph databases and
>> > > > their
>> > > > applications. Written by three acclaimed leaders in the field,
>> > > > this first edition is now available. Download your free book today!
>> > > >
>> > > > http://p.sf.net/sfu/13534_NeoTech_______________________________________________
>> > > > Csound-devel mailing list
>> > > > Csound-devel@lists.sourceforge.net
>> > > > https://lists.sourceforge.net/lists/listinfo/csound-devel
>> > >
>> > >
>> > >
>> > > ------------------------------------------------------------------------------
>> > > Learn Graph Databases - Download FREE O'Reilly Book
>> > > "Graph Databases" is the definitive new guide to graph databases and
>> > > their
>> > > applications. Written by three acclaimed leaders in the field,
>> > > this first edition is now available. Download your free book today!
>> > > http://p.sf.net/sfu/13534_NeoTech
>> > > _______________________________________________
>> > > Csound-devel mailing list
>> > > Csound-devel@lists.sourceforge.net
>> > > https://lists.sourceforge.net/lists/listinfo/csound-devel
>> > >
>> > >
>> > >
>> > > <example1.csd>------------------------------------------------------------------------------
>> > > Learn Graph Databases - Download FREE O'Reilly Book
>> > > "Graph Databases" is the definitive new guide to graph databases and
>> > > their
>> > > applications. Written by three acclaimed leaders in the field,
>> > > this first edition is now available. Download your free book today!
>> > >
>> > > http://p.sf.net/sfu/13534_NeoTech_______________________________________________
>> > > Csound-devel mailing list
>> > > Csound-devel@lists.sourceforge.net
>> > > https://lists.sourceforge.net/lists/listinfo/csound-devel
>> >
>> >
>> >
>> > ------------------------------------------------------------------------------
>> > Learn Graph Databases - Download FREE O'Reilly Book
>> > "Graph Databases" is the definitive new guide to graph databases and
>> > their
>> > applications. Written by three acclaimed leaders in the field,
>> > this first edition is now available. Download your free book today!
>> > http://p.sf.net/sfu/13534_NeoTech
>> > _______________________________________________
>> > Csound-devel mailing list
>> > Csound-devel@lists.sourceforge.net
>> > https://lists.sourceforge.net/lists/listinfo/csound-devel
>> >
>> >
>> > ------------------------------------------------------------------------------
>> > Learn Graph Databases - Download FREE O'Reilly Book
>> > "Graph Databases" is the definitive new guide to graph databases and
>> > their
>> > applications. Written by three acclaimed leaders in the field,
>> > this first edition is now available. Download your free book today!
>> >
>> > http://p.sf.net/sfu/13534_NeoTech_______________________________________________
>> > Csound-devel mailing list
>> > Csound-devel@lists.sourceforge.net
>> > https://lists.sourceforge.net/lists/listinfo/csound-devel
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Learn Graph Databases - Download FREE O'Reilly Book
>> "Graph Databases" is the definitive new guide to graph databases and their
>> applications. Written by three acclaimed leaders in the field,
>> this first edition is now available. Download your free book today!
>> http://p.sf.net/sfu/13534_NeoTech
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
>
>
> ------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and their
> applications. Written by three acclaimed leaders in the field,
> this first edition is now available. Download your free book today!
> http://p.sf.net/sfu/13534_NeoTech
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel


Date2014-03-20 00:52
FromVictor Lazzarini
SubjectRe: [Cs-dev] Problem with csoundTabbleCopyOut()
It turns out that the resize opcode had not been updated to the new table code. I did that, and table copy works now.
But with the resize, the ftable pointer is different and tab/tabw could not find and crashed. So I updated these to find the
table at perf time. Probably needs to be done with all other table readers/writers.

in git develop now.

========================
Dr Victor Lazzarini
Senior Lecturer
NUI Maynooth, Ireland
victor dot lazzarini at nuim dot ie




On 19 Mar 2014, at 23:25, Rory Walsh  wrote:

> I didn't for the basic example I was testing, but I do for Cabbage and it bombs there too. So I just tried now the following command line, but no luck:
> 
> g++ test.cpp -I../include -L. -lcsound64 -D "USE_DOUBLE=1" -g -o testApp
> 
> I'll try windows tomorrow and see if I get any different results.
> 
> 
> On 19 March 2014 22:53, Steven Yi  wrote:
> Just to double-check, did you define MYFLT=double?
> 
> On Wed, Mar 19, 2014 at 3:36 PM, Rory Walsh  wrote:
> > I'm stumped. I'm using the latest develop code from git. I'll try it out on
> > windows and see how it goes. For now I'm changing tact. I think it probably
> > better to write recordings to a temp file on disk, and then load that into a
> > function table if users wish to edit it. I would still like the option of
> > resizing tables on the fly though. But I can work around it for now.
> >
> >
> > On 19 March 2014 19:33, Victor Lazzarini  wrote:
> >>
> >> yes, no crashes with this program, on OSX
> >>
> >> int main(int argc, char *argv[])
> >> {
> >> /*Create an instance of Csound*/
> >> Csound* csound = new Csound;
> >> csound->Compile("example1.csd");
> >> csound->PerformKsmps();
> >>  int testTableSize, tableSize;
> >> std::vector temp (1024);
> >>
> >> while(csound->PerformKsmps()==0){
> >>     tableSize = csound->TableLength(1);
> >>     if(testTableSize!=tableSize){
> >>         testTableSize = tableSize;
> >>         csound->Message("Table size is now: %d\n", testTableSize);
> >>     }
> >>     temp.resize(tableSize);
> >>     csound->TableCopyOut(1, &temp[0]);
> >> }
> >> /*delete instance of csound*/
> >> delete csound;
> >> //delete temp;
> >> }
> >>
> >> ========================
> >> Dr Victor Lazzarini
> >> Senior Lecturer
> >> NUI Maynooth, Ireland
> >> victor dot lazzarini at nuim dot ie
> >>
> >>
> >>
> >>
> >> On 19 Mar 2014, at 19:23, Rory Walsh  wrote:
> >>
> >> > And you are using the attached .csd with the continuously changing
> >> > ftables? Also, are you making those 4 calls after every csoundPerformKsmp()?
> >> > I take it you are on OSX? I haven't tried this on Windows. Still trying to
> >> > get it to work on Linux. Hmm..
> >> >
> >> >
> >> > On 19 March 2014 19:18, Victor Lazzarini 
> >> > wrote:
> >> > I don't know again. This works here:
> >> >
> >> >  std::vector temp (1);
> >> >  int tableSize = csound->TableLength(1);
> >> >  temp.resize(tableSize);
> >> >  csound->TableCopyOut(1, temp.data());
> >> >
> >> >
> >> > ========================
> >> > Dr Victor Lazzarini
> >> > Senior Lecturer
> >> > NUI Maynooth, Ireland
> >> > victor dot lazzarini at nuim dot ie
> >> >
> >> >
> >> >
> >> >
> >> > On 19 Mar 2014, at 17:51, Rory Walsh  wrote:
> >> >
> >> > > So I'm looking for a way to access values from tables that have been
> >> > > resized, and in a threadsafe manor. As I need to dynamically alter my temp
> >> > > array I tried using a std::vector which I resize between calls to
> >> > > csoundPerformKsmps(). But as soon as I resize the table it gives me the same
> >> > > error as I was getting to start with. I've attached a csd file that uses
> >> > > John's ftresize opcodes and runs fine in Csound. Coupled with the code from
> >> > > below it will crash at the memcpy line in csoundTableCopyOut() I pointed to
> >> > > before. Any ideas on what I might be doing wrong? std::vector allocates
> >> > > memory when resize is called, and
> >> > >
> >> > > std::vector temp (1024);
> >> > >
> >> > > while(csound->PerformKsmps()==0){
> >> > >     tableSize = csound->TableLength(1);
> >> > >     if(testTableSize!=tableSize){
> >> > >         testTableSize = tableSize;
> >> > >         csound->Message("Table size is now: %d\n", testTableSize);
> >> > >     }
> >> > >     temp.resize(tableSize);
> >> > >     csound->TableCopyOut(1, &temp[0]);
> >> > > }
> >> > >
> >> > > Btw, I also tried with std::vector::data() which returns a direct
> >> > > pointer to the vector's internal array but that results in the same problem.
> >> > > Any ideas?
> >> > >
> >> > >
> >> > >
> >> > > On 19 March 2014 16:06, Rory Walsh  wrote:
> >> > > Weird. It works when I use your C++ method of allocation, but causes
> >> > > problems when I use malloc? Anyhow, that should hopefully get me past that
> >> > > problem. Now to try it on a full-blown scale..
> >> > >
> >> > >
> >> > > On 19 March 2014 16:00, Victor Lazzarini 
> >> > > wrote:
> >> > > I don't know: your test program works here when I allocate memory. It
> >> > > prints out the table too.
> >> > >
> >> > > int main(int argc, char *argv[])
> >> > > {
> >> > > /*Create an instance of Csound*/
> >> > > Csound* csound = new Csound;
> >> > > csound->Compile("example1.csd");
> >> > > csound->PerformKsmps();
> >> > > int tableSize = csound->TableLength(1);
> >> > > printf("%d \n", tableSize);
> >> > > MYFLT *temp = new MYFLT[tableSize];
> >> > > csound->TableCopyOut(1, temp);
> >> > >
> >> > > for(int i=0;i >> > >         printf("%f\n", temp[i]);
> >> > >
> >> > > csound->Perform();
> >> > > /*delete instance of csound*/
> >> > > delete csound;
> >> > > delete[] temp;
> >> > > }
> >> > >
> >> > > ========================
> >> > > Dr Victor Lazzarini
> >> > > Senior Lecturer
> >> > > NUI Maynooth, Ireland
> >> > > victor dot lazzarini at nuim dot ie
> >> > >
> >> > >
> >> > >
> >> > >
> >> > > On 19 Mar 2014, at 15:34, Rory Walsh  wrote:
> >> > >
> >> > > > That gives the same error. I also just tried explicitly allocating
> >> > > > enough space ala:
> >> > > >
> >> > > > int tableSize = csound->TableLength(1);
> >> > > > MYFLT* temp = (MYFLT *)malloc(tableSize * sizeof(MYFLT));
> >> > > > csound->TableCopyOut(1, temp);
> >> > > >
> >> > > > but that gives a whole host of new errors:
> >> > > >
> >> > > > 0  0x00007ffff700e425  __GI_raise
> >> > > > ../nptl/sysdeps/unix/sysv/linux/raise.c  64
> >> > > > 1  0x00007ffff7011b8b  __GI_abort  abort.c  91
> >> > > > 2  0x00007ffff704c39e  __libc_message
> >> > > > ../sysdeps/unix/sysv/linux/libc_fatal.c  201
> >> > > > 3  0x00007ffff7056b96  malloc_printerr  malloc.c  5039
> >> > > > 4  0x00007ffff790bd03  mfree
> >> > > > /home/rory/sourcecode/csound-csound6-git/Engine/memalloc.c  157
> >> > > > 5  0x00007ffff79042c1  orcompact
> >> > > > /home/rory/sourcecode/csound-csound6-git/Engine/insert.c  813
> >> > > > 6  0x00007ffff790f714  csoundCleanup
> >> > > > /home/rory/sourcecode/csound-csound6-git/Engine/musmon.c  447
> >> > > > 7  0x00007ffff7a61b48  reset
> >> > > > /home/rory/sourcecode/csound-csound6-git/Top/csound.c  2646
> >> > > > 8  0x00007ffff7a5e64c  csoundDestroy
> >> > > > /home/rory/sourcecode/csound-csound6-git/Top/csound.c  1212
> >> > > > 9  0x000000000040551f  Csound::~Csound()
> >> > > > 10  0x0000000000405552  Csound::~Csound()
> >> > > > 11  0x00000000004037f6  main
> >> > > >
> >> > > > I'm not sure why ptable was 0x0 in my first report from a few days
> >> > > > ago, it certainly seems valid now. I think I might have tried initialized it
> >> > > > to something in an attempt go bypass this problem.
> >> > > >
> >> > > >
> >> > > > On 19 March 2014 15:19, Victor Lazzarini 
> >> > > > wrote:
> >> > > > MYFLT* temp = 0;
> >> > > > int tableSize = csound->TableLength(1);
> >> > > > csound->TableCopyOut(1, temp);
> >> > > >
> >> > > > You need memory to copy into.  Try allocating it.
> >> > > >
> >> > > >
> >> > > > ========================
> >> > > > Dr Victor Lazzarini
> >> > > > Senior Lecturer
> >> > > > NUI Maynooth, Ireland
> >> > > > victor dot lazzarini at nuim dot ie
> >> > > >
> >> > > >
> >> > > >
> >> > > >
> >> > > > On 19 Mar 2014, at 14:59, Rory Walsh  wrote:
> >> > > >
> >> > > > > I tried to do some more digging around this but I can't see why
> >> > > > > memcpy is giving a problem. When I break at memcpy:
> >> > > > >
> >> > > > > memcpy(ptable, ftab, (size_t) (len*sizeof(MYFLT)));
> >> > > > >
> >> > > > > The values read:
> >> > > > > ptable = 0x4035c0
> >> > > > > len = 1024
> >> > > > > ftab = 0x7a2d50
> >> > > > >
> >> > > > > These addresses appear to be valid, but how would one find out for
> >> > > > > sure?
> >> > > > >
> >> > > > >
> >> > > > > On 14 March 2014 14:45, Rory Walsh  wrote:
> >> > > > > Attached are the source and csd file that will produce the
> >> > > > > problem.
> >> > > > >
> >> > > > > Backtrace:
> >> > > > > #0  __memcpy_ssse3_back ()
> >> > > > >     at ../sysdeps/x86_64/multiarch/memcpy-ssse3-back.S:1579
> >> > > > > #1  0x00007ffff7a6b992 in csoundTableCopyOut (csound=0x609030,
> >> > > > > table=1,
> >> > > > >     ptable=0x0) at
> >> > > > > /home/rory/sourcecode/csound-csound6-git/Top/threadsafe.c:50
> >> > > > > #2  0x0000000000404e12 in Csound::TableCopyOut(int, float*) ()
> >> > > > > #3  0x0000000000403779 in main ()
> >> > > > >
> >> > > > >
> >> > > > >
> >> > > > > ------------------------------------------------------------------------------
> >> > > > > Learn Graph Databases - Download FREE O'Reilly Book
> >> > > > > "Graph Databases" is the definitive new guide to graph databases
> >> > > > > and their
> >> > > > > applications. Written by three acclaimed leaders in the field,
> >> > > > > this first edition is now available. Download your free book
> >> > > > > today!
> >> > > > >
> >> > > > > http://p.sf.net/sfu/13534_NeoTech_______________________________________________
> >> > > > > Csound-devel mailing list
> >> > > > > Csound-devel@lists.sourceforge.net
> >> > > > > https://lists.sourceforge.net/lists/listinfo/csound-devel
> >> > > >
> >> > > >
> >> > > >
> >> > > > ------------------------------------------------------------------------------
> >> > > > Learn Graph Databases - Download FREE O'Reilly Book
> >> > > > "Graph Databases" is the definitive new guide to graph databases and
> >> > > > their
> >> > > > applications. Written by three acclaimed leaders in the field,
> >> > > > this first edition is now available. Download your free book today!
> >> > > > http://p.sf.net/sfu/13534_NeoTech
> >> > > > _______________________________________________
> >> > > > Csound-devel mailing list
> >> > > > Csound-devel@lists.sourceforge.net
> >> > > > https://lists.sourceforge.net/lists/listinfo/csound-devel
> >> > > >
> >> > > >
> >> > > > ------------------------------------------------------------------------------
> >> > > > Learn Graph Databases - Download FREE O'Reilly Book
> >> > > > "Graph Databases" is the definitive new guide to graph databases and
> >> > > > their
> >> > > > applications. Written by three acclaimed leaders in the field,
> >> > > > this first edition is now available. Download your free book today!
> >> > > >
> >> > > > http://p.sf.net/sfu/13534_NeoTech_______________________________________________
> >> > > > Csound-devel mailing list
> >> > > > Csound-devel@lists.sourceforge.net
> >> > > > https://lists.sourceforge.net/lists/listinfo/csound-devel
> >> > >
> >> > >
> >> > >
> >> > > ------------------------------------------------------------------------------
> >> > > Learn Graph Databases - Download FREE O'Reilly Book
> >> > > "Graph Databases" is the definitive new guide to graph databases and
> >> > > their
> >> > > applications. Written by three acclaimed leaders in the field,
> >> > > this first edition is now available. Download your free book today!
> >> > > http://p.sf.net/sfu/13534_NeoTech
> >> > > _______________________________________________
> >> > > Csound-devel mailing list
> >> > > Csound-devel@lists.sourceforge.net
> >> > > https://lists.sourceforge.net/lists/listinfo/csound-devel
> >> > >
> >> > >
> >> > >
> >> > > ------------------------------------------------------------------------------
> >> > > Learn Graph Databases - Download FREE O'Reilly Book
> >> > > "Graph Databases" is the definitive new guide to graph databases and
> >> > > their
> >> > > applications. Written by three acclaimed leaders in the field,
> >> > > this first edition is now available. Download your free book today!
> >> > >
> >> > > http://p.sf.net/sfu/13534_NeoTech_______________________________________________
> >> > > Csound-devel mailing list
> >> > > Csound-devel@lists.sourceforge.net
> >> > > https://lists.sourceforge.net/lists/listinfo/csound-devel
> >> >
> >> >
> >> >
> >> > ------------------------------------------------------------------------------
> >> > Learn Graph Databases - Download FREE O'Reilly Book
> >> > "Graph Databases" is the definitive new guide to graph databases and
> >> > their
> >> > applications. Written by three acclaimed leaders in the field,
> >> > this first edition is now available. Download your free book today!
> >> > http://p.sf.net/sfu/13534_NeoTech
> >> > _______________________________________________
> >> > Csound-devel mailing list
> >> > Csound-devel@lists.sourceforge.net
> >> > https://lists.sourceforge.net/lists/listinfo/csound-devel
> >> >
> >> >
> >> > ------------------------------------------------------------------------------
> >> > Learn Graph Databases - Download FREE O'Reilly Book
> >> > "Graph Databases" is the definitive new guide to graph databases and
> >> > their
> >> > applications. Written by three acclaimed leaders in the field,
> >> > this first edition is now available. Download your free book today!
> >> >
> >> > http://p.sf.net/sfu/13534_NeoTech_______________________________________________
> >> > Csound-devel mailing list
> >> > Csound-devel@lists.sourceforge.net
> >> > https://lists.sourceforge.net/lists/listinfo/csound-devel
> >>
> >>
> >>
> >> ------------------------------------------------------------------------------
> >> Learn Graph Databases - Download FREE O'Reilly Book
> >> "Graph Databases" is the definitive new guide to graph databases and their
> >> applications. Written by three acclaimed leaders in the field,
> >> this first edition is now available. Download your free book today!
> >> http://p.sf.net/sfu/13534_NeoTech
> >> _______________________________________________
> >> Csound-devel mailing list
> >> Csound-devel@lists.sourceforge.net
> >> https://lists.sourceforge.net/lists/listinfo/csound-devel
> >
> >
> >
> > ------------------------------------------------------------------------------
> > Learn Graph Databases - Download FREE O'Reilly Book
> > "Graph Databases" is the definitive new guide to graph databases and their
> > applications. Written by three acclaimed leaders in the field,
> > this first edition is now available. Download your free book today!
> > http://p.sf.net/sfu/13534_NeoTech
> > _______________________________________________
> > Csound-devel mailing list
> > Csound-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/csound-devel
> >
> 
> ------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and their
> applications. Written by three acclaimed leaders in the field,
> this first edition is now available. Download your free book today!
> http://p.sf.net/sfu/13534_NeoTech
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
> 
> ------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and their
> applications. Written by three acclaimed leaders in the field,
> this first edition is now available. Download your free book today!
> http://p.sf.net/sfu/13534_NeoTech_______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2014-03-20 08:59
FromRory Walsh
SubjectRe: [Cs-dev] Problem with csoundTabbleCopyOut()
AttachmentsNone  None  
Works now. Thanks Victor!


On 20 March 2014 00:52, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
It turns out that the resize opcode had not been updated to the new table code. I did that, and table copy works now.
But with the resize, the ftable pointer is different and tab/tabw could not find and crashed. So I updated these to find the
table at perf time. Probably needs to be done with all other table readers/writers.

in git develop now.

========================
Dr Victor Lazzarini
Senior Lecturer
NUI Maynooth, Ireland
victor dot lazzarini at nuim dot ie




On 19 Mar 2014, at 23:25, Rory Walsh <rorywalsh@ear.ie> wrote:

> I didn't for the basic example I was testing, but I do for Cabbage and it bombs there too. So I just tried now the following command line, but no luck:
>
> g++ test.cpp -I../include -L. -lcsound64 -D "USE_DOUBLE=1" -g -o testApp
>
> I'll try windows tomorrow and see if I get any different results.
>
>
> On 19 March 2014 22:53, Steven Yi <stevenyi@gmail.com> wrote:
> Just to double-check, did you define MYFLT=double?
>
> On Wed, Mar 19, 2014 at 3:36 PM, Rory Walsh <rorywalsh@ear.ie> wrote:
> > I'm stumped. I'm using the latest develop code from git. I'll try it out on
> > windows and see how it goes. For now I'm changing tact. I think it probably
> > better to write recordings to a temp file on disk, and then load that into a
> > function table if users wish to edit it. I would still like the option of
> > resizing tables on the fly though. But I can work around it for now.
> >
> >
> > On 19 March 2014 19:33, Victor Lazzarini <Victor.Lazzarini@nuim.ie> wrote:
> >>
> >> yes, no crashes with this program, on OSX
> >>
> >> int main(int argc, char *argv[])
> >> {
> >> /*Create an instance of Csound*/
> >> Csound* csound = new Csound;
> >> csound->Compile("example1.csd");
> >> csound->PerformKsmps();
> >>  int testTableSize, tableSize;
> >> std::vector<MYFLT> temp (1024);
> >>
> >> while(csound->PerformKsmps()==0){
> >>     tableSize = csound->TableLength(1);
> >>     if(testTableSize!=tableSize){
> >>         testTableSize = tableSize;
> >>         csound->Message("Table size is now: %d\n", testTableSize);
> >>     }
> >>     temp.resize(tableSize);
> >>     csound->TableCopyOut(1, &temp[0]);
> >> }
> >> /*delete instance of csound*/
> >> delete csound;
> >> //delete temp;
> >> }
> >>
> >> ========================
> >> Dr Victor Lazzarini
> >> Senior Lecturer
> >> NUI Maynooth, Ireland
> >> victor dot lazzarini at nuim dot ie
> >>
> >>
> >>
> >>
> >> On 19 Mar 2014, at 19:23, Rory Walsh <rorywalsh@ear.ie> wrote:
> >>
> >> > And you are using the attached .csd with the continuously changing
> >> > ftables? Also, are you making those 4 calls after every csoundPerformKsmp()?
> >> > I take it you are on OSX? I haven't tried this on Windows. Still trying to
> >> > get it to work on Linux. Hmm..
> >> >
> >> >
> >> > On 19 March 2014 19:18, Victor Lazzarini <Victor.Lazzarini@nuim.ie>
> >> > wrote:
> >> > I don't know again. This works here:
> >> >
> >> >  std::vector<MYFLT> temp (1);
> >> >  int tableSize = csound->TableLength(1);
> >> >  temp.resize(tableSize);
> >> >  csound->TableCopyOut(1, temp.data());
> >> >
> >> >
> >> > ========================
> >> > Dr Victor Lazzarini
> >> > Senior Lecturer
> >> > NUI Maynooth, Ireland
> >> > victor dot lazzarini at nuim dot ie
> >> >
> >> >
> >> >
> >> >
> >> > On 19 Mar 2014, at 17:51, Rory Walsh <rorywalsh@ear.ie> wrote:
> >> >
> >> > > So I'm looking for a way to access values from tables that have been
> >> > > resized, and in a threadsafe manor. As I need to dynamically alter my temp
> >> > > array I tried using a std::vector which I resize between calls to
> >> > > csoundPerformKsmps(). But as soon as I resize the table it gives me the same
> >> > > error as I was getting to start with. I've attached a csd file that uses
> >> > > John's ftresize opcodes and runs fine in Csound. Coupled with the code from
> >> > > below it will crash at the memcpy line in csoundTableCopyOut() I pointed to
> >> > > before. Any ideas on what I might be doing wrong? std::vector allocates
> >> > > memory when resize is called, and
> >> > >
> >> > > std::vector<MYFLT> temp (1024);
> >> > >
> >> > > while(csound->PerformKsmps()==0){
> >> > >     tableSize = csound->TableLength(1);
> >> > >     if(testTableSize!=tableSize){
> >> > >         testTableSize = tableSize;
> >> > >         csound->Message("Table size is now: %d\n", testTableSize);
> >> > >     }
> >> > >     temp.resize(tableSize);
> >> > >     csound->TableCopyOut(1, &temp[0]);
> >> > > }
> >> > >
> >> > > Btw, I also tried with std::vector::data() which returns a direct
> >> > > pointer to the vector's internal array but that results in the same problem.
> >> > > Any ideas?
> >> > >
> >> > >
> >> > >
> >> > > On 19 March 2014 16:06, Rory Walsh <rorywalsh@ear.ie> wrote:
> >> > > Weird. It works when I use your C++ method of allocation, but causes
> >> > > problems when I use malloc? Anyhow, that should hopefully get me past that
> >> > > problem. Now to try it on a full-blown scale..
> >> > >
> >> > >
> >> > > On 19 March 2014 16:00, Victor Lazzarini <Victor.Lazzarini@nuim.ie>
> >> > > wrote:
> >> > > I don't know: your test program works here when I allocate memory. It
> >> > > prints out the table too.
> >> > >
> >> > > int main(int argc, char *argv[])
> >> > > {
> >> > > /*Create an instance of Csound*/
> >> > > Csound* csound = new Csound;
> >> > > csound->Compile("example1.csd");
> >> > > csound->PerformKsmps();
> >> > > int tableSize = csound->TableLength(1);
> >> > > printf("%d \n", tableSize);
> >> > > MYFLT *temp = new MYFLT[tableSize];
> >> > > csound->TableCopyOut(1, temp);
> >> > >
> >> > > for(int i=0;i<tableSize;i++)
> >> > >         printf("%f\n", temp[i]);
> >> > >
> >> > > csound->Perform();
> >> > > /*delete instance of csound*/
> >> > > delete csound;
> >> > > delete[] temp;
> >> > > }
> >> > >
> >> > > ========================
> >> > > Dr Victor Lazzarini
> >> > > Senior Lecturer
> >> > > NUI Maynooth, Ireland
> >> > > victor dot lazzarini at nuim dot ie
> >> > >
> >> > >
> >> > >
> >> > >
> >> > > On 19 Mar 2014, at 15:34, Rory Walsh <rorywalsh@ear.ie> wrote:
> >> > >
> >> > > > That gives the same error. I also just tried explicitly allocating
> >> > > > enough space ala:
> >> > > >
> >> > > > int tableSize = csound->TableLength(1);
> >> > > > MYFLT* temp = (MYFLT *)malloc(tableSize * sizeof(MYFLT));
> >> > > > csound->TableCopyOut(1, temp);
> >> > > >
> >> > > > but that gives a whole host of new errors:
> >> > > >
> >> > > > 0  0x00007ffff700e425  __GI_raise
> >> > > > ../nptl/sysdeps/unix/sysv/linux/raise.c  64
> >> > > > 1  0x00007ffff7011b8b  __GI_abort  abort.c  91
> >> > > > 2  0x00007ffff704c39e  __libc_message
> >> > > > ../sysdeps/unix/sysv/linux/libc_fatal.c  201
> >> > > > 3  0x00007ffff7056b96  malloc_printerr  malloc.c  5039
> >> > > > 4  0x00007ffff790bd03  mfree
> >> > > > /home/rory/sourcecode/csound-csound6-git/Engine/memalloc.c  157
> >> > > > 5  0x00007ffff79042c1  orcompact
> >> > > > /home/rory/sourcecode/csound-csound6-git/Engine/insert.c  813
> >> > > > 6  0x00007ffff790f714  csoundCleanup
> >> > > > /home/rory/sourcecode/csound-csound6-git/Engine/musmon.c  447
> >> > > > 7  0x00007ffff7a61b48  reset
> >> > > > /home/rory/sourcecode/csound-csound6-git/Top/csound.c  2646
> >> > > > 8  0x00007ffff7a5e64c  csoundDestroy
> >> > > > /home/rory/sourcecode/csound-csound6-git/Top/csound.c  1212
> >> > > > 9  0x000000000040551f  Csound::~Csound()
> >> > > > 10  0x0000000000405552  Csound::~Csound()
> >> > > > 11  0x00000000004037f6  main
> >> > > >
> >> > > > I'm not sure why ptable was 0x0 in my first report from a few days
> >> > > > ago, it certainly seems valid now. I think I might have tried initialized it
> >> > > > to something in an attempt go bypass this problem.
> >> > > >
> >> > > >
> >> > > > On 19 March 2014 15:19, Victor Lazzarini <Victor.Lazzarini@nuim.ie>
> >> > > > wrote:
> >> > > > MYFLT* temp = 0;
> >> > > > int tableSize = csound->TableLength(1);
> >> > > > csound->TableCopyOut(1, temp);
> >> > > >
> >> > > > You need memory to copy into.  Try allocating it.
> >> > > >
> >> > > >
> >> > > > ========================
> >> > > > Dr Victor Lazzarini
> >> > > > Senior Lecturer
> >> > > > NUI Maynooth, Ireland
> >> > > > victor dot lazzarini at nuim dot ie
> >> > > >
> >> > > >
> >> > > >
> >> > > >
> >> > > > On 19 Mar 2014, at 14:59, Rory Walsh <rorywalsh@ear.ie> wrote:
> >> > > >
> >> > > > > I tried to do some more digging around this but I can't see why
> >> > > > > memcpy is giving a problem. When I break at memcpy:
> >> > > > >
> >> > > > > memcpy(ptable, ftab, (size_t) (len*sizeof(MYFLT)));
> >> > > > >
> >> > > > > The values read:
> >> > > > > ptable = 0x4035c0
> >> > > > > len = 1024
> >> > > > > ftab = 0x7a2d50
> >> > > > >
> >> > > > > These addresses appear to be valid, but how would one find out for
> >> > > > > sure?
> >> > > > >
> >> > > > >
> >> > > > > On 14 March 2014 14:45, Rory Walsh <rorywalsh@ear.ie> wrote:
> >> > > > > Attached are the source and csd file that will produce the
> >> > > > > problem.
> >> > > > >
> >> > > > > Backtrace:
> >> > > > > #0  __memcpy_ssse3_back ()
> >> > > > >     at ../sysdeps/x86_64/multiarch/memcpy-ssse3-back.S:1579
> >> > > > > #1  0x00007ffff7a6b992 in csoundTableCopyOut (csound=0x609030,
> >> > > > > table=1,
> >> > > > >     ptable=0x0) at
> >> > > > > /home/rory/sourcecode/csound-csound6-git/Top/threadsafe.c:50
> >> > > > > #2  0x0000000000404e12 in Csound::TableCopyOut(int, float*) ()
> >> > > > > #3  0x0000000000403779 in main ()
> >> > > > >
> >> > > > >
> >> > > > >
> >> > > > > ------------------------------------------------------------------------------
> >> > > > > Learn Graph Databases - Download FREE O'Reilly Book
> >> > > > > "Graph Databases" is the definitive new guide to graph databases
> >> > > > > and their
> >> > > > > applications. Written by three acclaimed leaders in the field,
> >> > > > > this first edition is now available. Download your free book
> >> > > > > today!
> >> > > > >
> >> > > > > http://p.sf.net/sfu/13534_NeoTech_______________________________________________
> >> > > > > Csound-devel mailing list
> >> > > > > Csound-devel@lists.sourceforge.net
> >> > > > > https://lists.sourceforge.net/lists/listinfo/csound-devel
> >> > > >
> >> > > >
> >> > > >
> >> > > > ------------------------------------------------------------------------------
> >> > > > Learn Graph Databases - Download FREE O'Reilly Book
> >> > > > "Graph Databases" is the definitive new guide to graph databases and
> >> > > > their
> >> > > > applications. Written by three acclaimed leaders in the field,
> >> > > > this first edition is now available. Download your free book today!
> >> > > > http://p.sf.net/sfu/13534_NeoTech
> >> > > > _______________________________________________
> >> > > > Csound-devel mailing list
> >> > > > Csound-devel@lists.sourceforge.net
> >> > > > https://lists.sourceforge.net/lists/listinfo/csound-devel
> >> > > >
> >> > > >
> >> > > > ------------------------------------------------------------------------------
> >> > > > Learn Graph Databases - Download FREE O'Reilly Book
> >> > > > "Graph Databases" is the definitive new guide to graph databases and
> >> > > > their
> >> > > > applications. Written by three acclaimed leaders in the field,
> >> > > > this first edition is now available. Download your free book today!
> >> > > >
> >> > > > http://p.sf.net/sfu/13534_NeoTech_______________________________________________
> >> > > > Csound-devel mailing list
> >> > > > Csound-devel@lists.sourceforge.net
> >> > > > https://lists.sourceforge.net/lists/listinfo/csound-devel
> >> > >
> >> > >
> >> > >
> >> > > ------------------------------------------------------------------------------
> >> > > Learn Graph Databases - Download FREE O'Reilly Book
> >> > > "Graph Databases" is the definitive new guide to graph databases and
> >> > > their
> >> > > applications. Written by three acclaimed leaders in the field,
> >> > > this first edition is now available. Download your free book today!
> >> > > http://p.sf.net/sfu/13534_NeoTech
> >> > > _______________________________________________
> >> > > Csound-devel mailing list
> >> > > Csound-devel@lists.sourceforge.net
> >> > > https://lists.sourceforge.net/lists/listinfo/csound-devel
> >> > >
> >> > >
> >> > >
> >> > > <example1.csd>------------------------------------------------------------------------------
> >> > > Learn Graph Databases - Download FREE O'Reilly Book
> >> > > "Graph Databases" is the definitive new guide to graph databases and
> >> > > their
> >> > > applications. Written by three acclaimed leaders in the field,
> >> > > this first edition is now available. Download your free book today!
> >> > >
> >> > > http://p.sf.net/sfu/13534_NeoTech_______________________________________________
> >> > > Csound-devel mailing list
> >> > > Csound-devel@lists.sourceforge.net
> >> > > https://lists.sourceforge.net/lists/listinfo/csound-devel
> >> >
> >> >
> >> >
> >> > ------------------------------------------------------------------------------
> >> > Learn Graph Databases - Download FREE O'Reilly Book
> >> > "Graph Databases" is the definitive new guide to graph databases and
> >> > their
> >> > applications. Written by three acclaimed leaders in the field,
> >> > this first edition is now available. Download your free book today!
> >> > http://p.sf.net/sfu/13534_NeoTech
> >> > _______________________________________________
> >> > Csound-devel mailing list
> >> > Csound-devel@lists.sourceforge.net
> >> > https://lists.sourceforge.net/lists/listinfo/csound-devel
> >> >
> >> >
> >> > ------------------------------------------------------------------------------
> >> > Learn Graph Databases - Download FREE O'Reilly Book
> >> > "Graph Databases" is the definitive new guide to graph databases and
> >> > their
> >> > applications. Written by three acclaimed leaders in the field,
> >> > this first edition is now available. Download your free book today!
> >> >
> >> > http://p.sf.net/sfu/13534_NeoTech_______________________________________________
> >> > Csound-devel mailing list
> >> > Csound-devel@lists.sourceforge.net
> >> > https://lists.sourceforge.net/lists/listinfo/csound-devel
> >>
> >>
> >>
> >> ------------------------------------------------------------------------------
> >> Learn Graph Databases - Download FREE O'Reilly Book
> >> "Graph Databases" is the definitive new guide to graph databases and their
> >> applications. Written by three acclaimed leaders in the field,
> >> this first edition is now available. Download your free book today!
> >> http://p.sf.net/sfu/13534_NeoTech
> >> _______________________________________________
> >> Csound-devel mailing list
> >> Csound-devel@lists.sourceforge.net
> >> https://lists.sourceforge.net/lists/listinfo/csound-devel
> >
> >
> >
> > ------------------------------------------------------------------------------
> > Learn Graph Databases - Download FREE O'Reilly Book
> > "Graph Databases" is the definitive new guide to graph databases and their
> > applications. Written by three acclaimed leaders in the field,
> > this first edition is now available. Download your free book today!
> > http://p.sf.net/sfu/13534_NeoTech
> > _______________________________________________
> > Csound-devel mailing list
> > Csound-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/csound-devel
> >
>
> ------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and their
> applications. Written by three acclaimed leaders in the field,
> this first edition is now available. Download your free book today!
> http://p.sf.net/sfu/13534_NeoTech
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
> ------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and their
> applications. Written by three acclaimed leaders in the field,
> this first edition is now available. Download your free book today!
> http://p.sf.net/sfu/13534_NeoTech_______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel