Support and General Use > Plugins/Viewers

sncviewer plugin

<< < (15/38) > >>

carmenm:
Ok so i tried to implement it, i am almost there. But yet i am on the same problem for so many hours now.... i need some help. A lrc file is made so that on a line you can have multiple timetags for one lyric

--- Code: ---[02:37.01][02:44.31]Where soul meets body
--- End code ---
So i had to put all the lyrics in a list, then to order them and finally to put them on list of lyrics sncs.
here is the code for the temp list before ordering

--- Code: ---while((len = rb->read_line(fd, buf, BUFFERSIZE))>0)
{
buffer=buf;
j=0;
while (((is_time_tag =timetag(buffer,&temp.time_in_ms))==true) && (nrLRC <= MAX_SECTIONS) )
{
j++;
buffer=&buffer[10];

}
for(i=0;i<j;i++)
{
lrcs[nrLRC].time_in_ms=temp.time_in_ms;
lrcs[nrLRC].lyrics=buffer;
nrLRC++;

}
}
--- End code ---
in the for i put all the lyrics which were on the same line. inthe for, if i rb->splash(HZ>>1,true, lrcs[nrLRC].lyrics); everything is ok.
but my problem is that just after that i want to order it and even before doing it, all the lyrics are wrong, in fact they contains the last lyric. So i think there must be a problem in the for above, may be when i change one i change all the others(that would explain yet if i splash it "seems" ok).  I am not sure and i spent all night on that so i would need some help. I think that i am almost there ... just one step.... :-\

Here is the file if someone wants to look at it




[attachment deleted by admin, too old]

(:@):
lyrics:
- rb->read_line(fd, buf, BUFFERSIZE)): the buffer "buf" will be overwritten after every line; lrcs[].lyrics will point to a position in buf, but after reading the file, buf contains the last line and all your lrcs[].lyrics will point to a position in buf (the last line)

time:
- temp.time_in_ms will be overwritten every time timetag(buffer,&temp.time_in_ms)) is called.
lrcs[nrLRC].time_in_ms=temp.time_in_ms;// will only save the last time, even if you have more than one:
[00:00.00]                      lrcs[0].time_in_ms=0
[02:37.01][02:44.31]     lrcs[1].time_in_ms=02:44.31,lrcs[2].time_in_ms=02:44.31
[03:00.00]                      lrcs[1].time_in_ms=03:00.00

do you understand what I mean?

carmenm:
Yeah i understand quite well what you mean, but i am a little lost under c. I am used to develop under c++ where i can do new . Here i cant. How can i not point to buf but copy the content to lrcs[].lyrics ? I think that the only real problem i encounter to finish it

OUps!!!!And for time your right i tried to change my code to optimized but i made that quite big mistake...

--- Code: ---while((len = rb->read_line(fd, buf, BUFFERSIZE))>0)
{
buffer=buf;
                j=nrLRC;
if ((is_time_tag = timetag(buffer,&(lrcs[nrLRC].time_in_ms))==true) )
{
nrLRC++;
buffer=&buffer[10];
while ((is_time_tag =timetag(buffer,&(lrcs[nrLRC].time_in_ms))==true) &&nrLRC <= MAX_SECTIONS )
{
nrLRC++;
buffer=&buffer[10];
}
i=0;
  for(i=j;i<nrLRC;i++)
lrcs[i].lyrics=buffer;
}
}
--- End code ---
that way the time is right but i still always copy the same value for the lyric

(:@):

--- Quote from: carmenm on March 08, 2006, 10:06:46 AM --- How can i not point to buf but copy the content to lrcs[].lyrics ?

--- End quote ---
I use rb->plugin_get_buffer() to get the memory. you can use strcpy/memcpy to copy from buf to rb->plugin_get_buffer() or directly save to rb->plugin_get_buffer(). let the lrcs[].lyrics point to rb->plugin_get_buffer().

carmenm:
(sorry to keep on asking, but it saves me a lot of time...)

--- Code: ---while((len = rb->read_line(fd, buf, BUFFERSIZE))>0)
{
rb->memcpy(buffer,buf,len);
                j=nrLRC;
if ((is_time_tag = timetag(buffer,&(lrcs[nrLRC].time_in_ms))==true) )
{
nrLRC++;
buffer=&buffer[10];
while ((is_time_tag =timetag(buffer,&(lrcs[nrLRC].time_in_ms))==true) &&nrLRC <= MAX_SECTIONS )
{
nrLRC++;
buffer=&buffer[10];
}
i=0;
  for(i=j;i<nrLRC;i++)
lrcs[i].lyrics=buffer;
}
}
--- End code ---

there i use memcpy to copy buf into buffer. But when i do lrcs[].lyrics=buffer;, does all lrcs[].lyrics points to the same "buffer" or is buffer copied into lrcs[].lyrics???

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version