Author Topic: .lyr, .cur, .mid files (aka NCN) karaoke format  (Read 12886 times)

SnakeByte

  • Guest
I have some Thai karaoke software and it stores the lyric text in a .lyr file, position data in a .cur file, and the MIDI song data in a .mid file.
What I am trying to do is create a list of Midi marks from the .lyr and .cur files, so that they look like they came from the MIDI file.
The .cur file seems to just be a file of Int16 values and the .lyr file is just a text file of the lyrics.
I convert the .lyr file to a char array and the .cur file to an Int16 array.
The int16 array is always longer than the char array.
The units represented by the values in the Int16 array do not match any obvious unit (milliseconds, bytes, etc.)
Does anyone know how to parse the .cur and .lyr files to create a midi mark list?
The .cur file is related to both the .mid file and the .lyr file, but I am unable to reverse engineer the relationship.
Any help would be greatly appreciated.

kxth10

  • Posts: 29
Re: .lyr, .cur, .mid files (aka NCN) karaoke format
« Reply #1 on: 8 Aug '10 - 18:38 »
I have C source code to convert NCN 3 Files to .kar file (for Windows x86)
by Mr. Tim Lauren (USA)
read data of xxxx.cur 2 byte and read xxxx.lyr 1 byte to play karaoke
miditime = (cur byte1+cur byte2)*midi resolution/24
see

currentTime = (ch2 + (ch3 * 256)) * (resolution / 24)

You can use this code by run batfile by short name path only (not use long name path)
Run : makekar midPath lyrPath curPath karPath
eg : makekar C:\karaoke\song\0\0001.mid C:\karaoke\lyrics\0\0001.lyr C:\karaoke\cursor\0\0001.cur C:\kar\0\0001.kar
good luck

Code: [Select]
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

// makekar midPath lyrPath curPath karPath
// makekar C:\karaoke\song\0\0001.mid C:\karaoke\lyrics\0\0001.lyr C:\karaoke\cursor\0\0001.cur C:\kar\0\0001.kar

void lyr2txt(char lyrfile[], char song[], char singer[]);
void dec2hex(int decNumber);
int char2num(char ch);

void main( int argc, char *argv[] )
{
FILE *mid, *cur, *kar, *txt, *tmp;

char midfile[80];
char lyrfile[80];
char curfile[80];
char karfile[80];
char txtfile[80];

char midBuffer [400000];
char txtBuffer [100000];
char curBuffer [200000];
char hexNumber[10];

char song[80];
char singer[80];

int byteRead, txtReadLen, curReadLen, maxIndex, TimeBase;
int numTrack, n, n1, n2, n3, n4, i, j, songLen, singerLen;
int track1Len, part1, resolution;
int lastTime, currentTime, deltaTime;
int track2Len, k, hexLen;

unsigned char ch1, ch2, ch3, ch4;
unsigned char b1, b2;

DWORD value, nBytesWritten, dwBuffer;


strcpy( midfile, argv[1] );
strcpy( lyrfile, argv[2] );
strcpy( curfile, argv[3] );
strcpy( karfile, argv[4] );

// strcpy( midfile,   "c:/karadata/karapro/song/6/6182.mid" );
// strcpy( lyrfile,   "c:/karadata/karapro/lyrics/6/6182.lyr" );
// strcpy( curfile,   "c:/karadata/karapro/cursor/6/6182.cur" );
// strcpy( karfile,   "6182.kar" );

if (( mid = fopen( midfile, "rb" )) == NULL )
{
fprintf( stdout, "Error Open .mid file.\n" );
    return;
}
if (( kar = fopen( karfile, "wb" )) == NULL )
{
fprintf( stdout, "Error Open .kar file.\n" );
    return;
}
if (( tmp = fopen( "Track2.txt", "wb" )) == NULL )
{
fprintf( stdout, "Error Open Track2.txt file.\n" );
    return;
}

byteRead = fread(midBuffer,1,400000,mid);

fclose(mid);

// read number of tracks
ch1 = midBuffer[10];
ch2 = midBuffer[11];
n1 = (int) ch1;
n2 = (int) ch2;
numTrack = (n1 << 8) + n2;

// read track number 1 data lenght
ch1 = midBuffer[18];
ch2 = midBuffer[19];
ch3 = midBuffer[20];
ch4 = midBuffer[21];
n1 = (int) ch1;
n2 = (int) ch2;
n3 = (int) ch3;
n4 = (int) ch4;
track1Len = (n1<<24) + (n2<<16) + (n3<<8) + n4;

// add one more track
numTrack = numTrack + 1;
b1 = numTrack / 256;
b2 = numTrack - (b1 * 256);

midBuffer[10] = b1;
midBuffer[11] = b2;

// write part1 to .kar file
part1 = 21 + track1Len;
for ( i = 0; i <= part1; i++)
{
fputc(midBuffer[i], kar);
}

// Read resolution
ch1 = midBuffer[12];
ch2 = midBuffer[13];
resolution = (ch1 << 8) + ch2;
TimeBase = resolution / 4;

// Create txt file (Temp.txt) from lyr file
lyr2txt(lyrfile, song, singer);

songLen = (int)strlen(song) - 1;
singerLen = (int)strlen(singer) - 1;

k = 0;
k = k + 4 + (2 + songLen); // 00 FF 01 XX @T.....
k = k + 4 + (2 + singerLen); // 00 FF 01 XX @T.....
k = k + 9;           // 4 byte + "Words" = 9



// Read cur and txt files into buffers
strcpy( txtfile,   "Temp.txt" );

if (( txt = fopen( txtfile, "rb" )) == NULL )
{
fprintf( stdout, "Error Open .txt file.\n" );
    return;
}
if (( cur = fopen( curfile, "rb" )) == NULL )
{
fprintf( stdout, "Error Open .cur file.\n" );
    return;
}

txtReadLen = fread(txtBuffer,1,100000,txt);
curReadLen = fread(curBuffer,1,200000,cur);
fclose(txt);
fclose(cur);

// write the track2 header 'MTrk'
fputc(0x4D, kar);
fputc(0x54, kar);
fputc(0x72, kar);
fputc(0x6B, kar);

// calculate the lenght of the second track
if ((txtReadLen - 1) <= (curReadLen / 2) )
{
maxIndex = txtReadLen - 1;
}
else
{
maxIndex = curReadLen / 2;
}

// Get text and write text event
n = 0;
lastTime = 0;

for ( j = 0; j < maxIndex; j++)
{
ch1 = txtBuffer[j];

ch2 = curBuffer[n];
n = n + 1;
ch3 = curBuffer[n];
n = n + 1;

if ((ch2 == 0xFF) && (ch3 == 0xFF))
{
continue;
}

currentTime = (ch2 + (ch3 * 256)) * (resolution / 24);

if (currentTime < lastTime)
{
currentTime = lastTime;
}


deltaTime = currentTime - lastTime;
lastTime = currentTime;

value = (DWORD)deltaTime;

if (value == 0)
{
// fputc(0x00, kar);
k++;
}
else
{
nBytesWritten = 0;
dwBuffer = value & 0x7F;

while ((value >>=7) > 0)
{
dwBuffer <<= 8;
dwBuffer |= 0x80;
dwBuffer += (value & 0x7F);
}
while (TRUE)
{
// fputc((BYTE)dwBuffer, kar);
k++;
nBytesWritten++;
if(dwBuffer & 0x80)
dwBuffer >>= 8;
else
break;
}
}

// fputc(0xFF, tmp);
k = k + 1;
// fputc(0x01, tmp);
k = k + 1;
// fputc(0x01, tmp);
k = k + 1;
// fputc(ch1, tmp);
k = k + 1;
}

k = k + 4;       // 4 is end of track2 "00 FF 2F 00"

// fprintf(stdout, "Track2 Lenght = %d\n", k);

track2Len = k;

itoa(track2Len,hexNumber,16);

hexLen = strlen(hexNumber);

ch4 = 0;
ch3 = 0;
ch2 = 0;
ch1 = 0;

if (hexLen == 1)
{
ch1 = char2num(hexNumber[0]);
}
else if (hexLen == 2)
{
ch1 = char2num(hexNumber[0]) * 16 + char2num(hexNumber[1]);
}
else if (hexLen == 3)
{
ch1 = char2num(hexNumber[1]) * 16 + char2num(hexNumber[2]);
ch2 = char2num(hexNumber[0]);
}
else if (hexLen == 4)
{
ch1 = char2num(hexNumber[2]) * 16 + char2num(hexNumber[3]);
ch2 = char2num(hexNumber[0]) * 16 + char2num(hexNumber[1]);
}

// write track2 lenght
fputc(ch4, kar);
fputc(ch3, kar);
fputc(ch2, kar);
fputc(ch1, kar);

// Track name Words
fputc(0x00, kar);
fputc(0xFF, kar);
fputc(0x03, kar);
fputc(0x05, kar);
fputc(0x57, kar);
fputc(0x6F, kar);
fputc(0x72, kar);
fputc(0x64, kar);
fputc(0x73, kar);

// write song title
fputc(0x00, kar);
fputc(0xFF, kar);
fputc(0x01, kar);
fputc(songLen + 2, kar);
fputc('@', kar);
fputc('T', kar);
for (i = 0; i < songLen; i++)
{
fputc(song[i], kar);
}


// write singer name

fputc(0x00, kar);
fputc(0xFF, kar);
fputc(0x01, kar);
fputc(singerLen + 2, kar);
fputc('@', kar);
fputc('T', kar);
for (i = 0; i < singerLen; i++)
{
fputc(singer[i], kar);
}

// Get text and write text event
n = 0;
lastTime = 0;

for ( j = 0; j < maxIndex; j++)
{
ch1 = txtBuffer[j];

ch2 = curBuffer[n];
// fprintf(tmp, "%d  %x ", n, ch2);
n = n + 1;
ch3 = curBuffer[n];
// fprintf(tmp, "%x", ch3);
n = n + 1;

if ((ch2 == 0xFF) && (ch3 == 0xFF))
{
continue;
}


currentTime = (ch2 + (ch3 * 256)) * (TimeBase / 6);
//  or        currentTime = (ch2 + (ch3 * 256)) * (Resolution / 24);

if (currentTime < lastTime)
{
currentTime = lastTime;
}

// fprintf(tmp, "--- %d\n", currentTime);
deltaTime = currentTime - lastTime;
lastTime = currentTime;

value = (DWORD)deltaTime;

if (value == 0)
{
fputc(0x00, kar);
}
else
{
nBytesWritten = 0;
dwBuffer = value & 0x7F;

while ((value >>=7) > 0)
{
dwBuffer <<= 8;
dwBuffer |= 0x80;
dwBuffer += (value & 0x7F);
}
while (TRUE)
{
fputc((BYTE)dwBuffer, kar);
nBytesWritten++;
if(dwBuffer & 0x80)
dwBuffer >>= 8;
else
break;
}
}

fputc(0xFF, kar);
fputc(0x01, kar);
fputc(0x01, kar); // only 1 char
fputc(ch1, kar); // only 1 char

}

// write end of track2
fputc(0x00, kar);
fputc(0xFF, kar);
fputc(0x2F, kar);
fputc(0x00, kar);

// Write the rest to .kar file
for ( i = part1 + 1; i < byteRead; i++)
{
fputc(midBuffer[i], kar);
}

fclose(kar);

}

//===============================================================
void lyr2txt(char lyrfile[], char song[], char singer[])
{
char bufstr[80];
char txtfile[80];
char line3[80], line4[80];
int buflen, i;
FILE *lyr, *txt;

lyr = fopen( lyrfile, "r" );
if (lyr == NULL) {
printf("Error open .lyr file for reading");
return;
}

strcpy( txtfile,   "Temp.txt" );
txt = fopen( txtfile, "w" );
if (txt == NULL) {
printf("Error open .txt file for writing");
return;
}

fgets( song, 80, lyr );
fgets( singer, 80, lyr );
fgets( line3, 80, lyr );
fgets( line4, 80, lyr );

// fputs( line1, txt );

fputc( 0x2F, txt );

    while ( fgets( bufstr, 80, lyr ) != 0)
{
buflen = strlen ( bufstr );
if ( buflen > 0 )
{
for ( i=0; i<buflen-1; i++ )
fputc( bufstr[i], txt );
fputc( 0x2F, txt );
}
}

fclose( lyr );
fclose( txt );   
}

void dec2hex(int decNumber)
{
char hexNumber[10];
itoa(decNumber,hexNumber,16);
printf("Hexa decimal number:Ox%s\n",hexNumber);

}

int char2num(char ch)
{
int num;

switch(ch)
{
case '0' : num = 0; break;
case '1' : num = 1; break;
case '2' : num = 2; break;
case '3' : num = 3; break;
case '4' : num = 4; break;
case '5' : num = 5; break;
case '6' : num = 6; break;
case '7' : num = 7; break;
case '8' : num = 8; break;
case '9' : num = 9; break;
case 'a' : num = 10; break;
case 'b' : num = 11; break;
case 'c' : num = 12; break;
case 'd' : num = 13; break;
case 'e' : num = 14; break;
case 'f' : num = 15; break;

}
return num;
}
« Last Edit: 30 Sep '19 - 10:51 by kxth10 »

Fabio

  • Guest
Re: .lyr, .cur, .mid files (aka NCN) karaoke format
« Reply #2 on: 12 Oct '11 - 10:35 »
I know this post is over a year old, but I'm hoping the kxth10 is still around.  This is the closest I've seen to converting ncn files to kar.  I've tried to compile your source but all it does is create a kar file (which doesn't work) and a track2.txt file (which doesn't contain anything).  Windows just reports that TCC stopped working.  I've tried other compilers and they all create the two files (kar and txt) but again they don't work.  They all have different errors (some report abnormal program termination).  The closest I've gotten to a real error is LCC with:

Exception 0xc000005:
Segment Violation
address 0x40155b

But I don't know what it means.  I'm hoping you can tell me what you used to compile it or if there's a bug can fix it.

In advance thank you for trying.

-Fabio

zkw

  • Posts: 1
Re: .lyr, .cur, .mid files (aka NCN) karaoke format
« Reply #3 on: 28 Jun '12 - 00:45 »
I tried using makekar to migrate a Nick Karaoke track collection to PyKaraoke.  It worked but I needed multibyte character support and it seemed easier to start over, so anyone still looking to do this (and anyone not comfortable with compiling things from source) might want to try my Perl version: https://github.com/zw/ncn-to-kar.

I'm replying here because this is the first (and most useful) hit when searching the web for NCN-to-KAR conversion.

kxth10

  • Posts: 29
Re: .lyr, .cur, .mid files (aka NCN) karaoke format
« Reply #4 on: 6 Jul '12 - 17:45 »
NCN Kara File (Thai Karaoke)
curTime=Read *.cur 2 byte 
read *.lyr 1 string , space or End of line from line 5 to end of file
play midi file and read midi time
If midi time = curTime add next string to karaoke

CurTime = MIDI Time * Tempo * 24 / 60

Download VB6 source code (Play NCN Karaoke)
http://www.4shared.com/rar/3cyinzf8/SF_Karaoke_1.html

Good luck
Code: [Select]
Private Sub ReadNCN()
    Dim Byte1 As Byte, Byte2 As Byte, i As Single, j As Integer, z As Single, n As Single
   
    On Error Resume Next
   
    'Read Cursor file
    i = 0
    Open App.Path & "\NCN\Cursor\" & Left(File1.filename, Len(File1.filename) - 4) & ".cur" For Random As #1 Len = 1
        Do While Not EOF(1)
            Get #1, , Byte1
            Get #1, , Byte2
            If Not Byte2 = 255 Then
                ReDim Preserve Cursor(i)
                Cursor(i) = Byte1 + Byte2 * 256
                i = i + 1
            End If
        Loop
    Close #1
   
    'Read Lyric file
    i = 0
    Open App.Path & "\NCN\Lyrics\" & Left(File1.filename, Len(File1.filename) - 4) & ".lyr" For Input As #2
        Do While Not EOF(2)
            ReDim Preserve Lyric(i)
            Line Input #2, Lyric(i)
            i = i + 1
        Loop
    Close #2
   
    ' add lyric & curtime to lixtbox
    z = 0
    List1.Clear
    For i = 4 To UBound(Cursor)
        For j = 0 To Len(Lyric(i))
            If j = 0 Then
                List1.AddItem Space(10) & "/" & vbTab & " : " & Cursor(z)
                z = z + 1
            Else
                List1.AddItem Space(10) & Mid(Lyric(i), j, 1) & vbTab & " : " & Cursor(z)
                z = z + 1
            End If
        Next j
    Next i
    List1.ListIndex = 0
End Sub

Private Sub tmrMidiTest_Timer()
    Tempo = 60000000 \ BASS_MIDI_StreamGetEvent(chan, 0, MIDI_EVENT_TEMPO)
    playTime = BASS_ChannelBytes2Seconds(chan, BASS_ChannelGetPosition(chan, BASS_POS_BYTE))
    curTime = playTime * Tempo * 24 \ 60             
    If curTime > Cursor(b) Then
        b=b+1
        List1.ListIndex = List1.ListIndex + 1
        .....
    End If
End Sub
« Last Edit: 26 Aug '18 - 09:26 by kxth10 »

CMH234

  • Guest
Re: .lyr, .cur, .mid files (aka NCN) karaoke format
« Reply #5 on: 10 Sep '12 - 07:26 »
I tried using makekar to migrate a Nick Karaoke track collection to PyKaraoke.  It worked but I needed multibyte character support and it seemed easier to start over, so anyone still looking to do this (and anyone not comfortable with compiling things from source) might want to try my Perl version: https://github.com/zw/ncn-to-kar.

I'm replying here because this is the first (and most useful) hit when searching the web for NCN-to-KAR conversion.

Your program looks great. I'm getting this error. It repeats over and over. Here are the first couple of lines. Any suggestions?

Thanks
Chris

timestamp 0 out of order at E:\Karaoke05_2009\ncn-to-kar.pl line 145, <$lyric_fh
> line 114.
timestamp 0 out of order at E:\Karaoke05_2009\ncn-to-kar.pl line 145, <$lyric_fh
> line 115.

Thanks Chris

snakebyteme

  • Guest
Re: .lyr, .cur, .mid files (aka NCN) karaoke format
« Reply #6 on: 4 Apr '13 - 14:15 »
Thanks for all the help on this.

The cursor time is incorrect in the VB example:

Dim curTime As Integer = playTime * tempo * 24 \ 60

The cursor time must first be resolved to a MIDI tick position:

        Dim ch1 As Byte
        Dim ch2 As Byte
        Dim resolution As Integer
        Dim timeBase As Single

        Using midiFS As New IO.FileStream(midi, IO.FileMode.Open)
            Dim midBuffer(midiFS.Length - 1) As Byte
            midiFS.Read(midBuffer, 0, midiFS.Length)
            ' Read resolution
            ch1 = midBuffer(12)
            ch2 = midBuffer(13)
            resolution = (ch1 << 8) + ch2
            timeBase = resolution / 4
        End Using

        Dim myCursorList As New List(Of Long)
        Using fs As New FileStream(cur, FileMode.Open)
            While fs.Position < fs.Length - 1
                Dim byte1 As Byte = fs.ReadByte()
                Dim byte2 As Byte = fs.ReadByte()
                Dim tickPos As Long = (byte1 + (byte2 * 256)) * (resolution / 24)
                myCursorList.Add(tickPos)
            End While
        End Using

And now for BASS:

        Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, 0)

        ' load optional plugins for packed soundfonts (others may be used too)
        Call Bass.BASS_PluginLoad(System.AppDomain.CurrentDomain.BaseDirectory() & "bassmidi.dll")
        Call Bass.BASS_PluginLoad(System.AppDomain.CurrentDomain.BaseDirectory() & "bassflac.dll")
        Call Bass.BASS_PluginLoad(System.AppDomain.CurrentDomain.BaseDirectory() & "basswv.dll")

        Dim stream As Integer = Un4seen.Bass.AddOn.Midi.BassMidi.BASS_MIDI_StreamCreateFile(inputMidiFileName, 0, 0, BASSFlag.BASS_STREAM_DECODE, 0)
        Dim mySoundFont As Long = Un4seen.Bass.AddOn.Midi.BassMidi.BASS_MIDI_FontInit(soundFontFileName, 0)
        Dim myFontArray(0) As BASS_MIDI_FONT
        myFontArray(0).font = mySoundFont
        myFontArray(0).preset = -1 ' use all presets
        myFontArray(0).bank = 0 ' use default bank(s)
        Call Un4seen.Bass.AddOn.Midi.BassMidi.BASS_MIDI_StreamSetFonts(0, myFontArray, 1) ' set default soundfont
        Call Un4seen.Bass.AddOn.Midi.BassMidi.BASS_MIDI_StreamSetFonts(stream, myFontArray, 1) ' set for current stream too

        While Bass.BASS_ChannelIsActive(stream) = BASSActive.BASS_ACTIVE_PLAYING
            Dim currentTickPos As Long = Bass.BASS_ChannelGetPosition(stream, BASSMode.BASS_POS_MIDI_TICK)
            Dim playTime = Bass.BASS_ChannelBytes2Seconds(stream, Bass.BASS_ChannelGetPosition(stream, BASSMode.BASS_POS_BYTES))
            'Locate Characters that have the current tick value (currentTickPos)
            'Their "real time" play time (00:00:000)  is playTime (in seconds as a float)
        End While

SnakeByteMe

  • Guest
Re: .lyr, .cur, .mid files (aka NCN) karaoke format
« Reply #7 on: 4 Apr '13 - 14:18 »
Forgot the Code tag up above.
Code: [Select]
        Dim ch1 As Byte
        Dim ch2 As Byte
        Dim resolution As Integer
        Dim timeBase As Single

        Using midiFS As New IO.FileStream(midi, IO.FileMode.Open)
            Dim midBuffer(midiFS.Length - 1) As Byte
            midiFS.Read(midBuffer, 0, midiFS.Length)
            ' Read resolution
            ch1 = midBuffer(12)
            ch2 = midBuffer(13)
            resolution = (ch1 << 8) + ch2
            timeBase = resolution / 4
        End Using

        Dim myCursorList As New List(Of Long)
        Using fs As New FileStream(cur, FileMode.Open)
            While fs.Position < fs.Length - 1
                Dim byte1 As Byte = fs.ReadByte()
                Dim byte2 As Byte = fs.ReadByte()
                Dim tickPos As Long = (byte1 + (byte2 * 256)) * (resolution / 24)
                myCursorList.Add(tickPos)
            End While
        End Using

Code: [Select]
Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, 0)

        ' load optional plugins for packed soundfonts (others may be used too)
        Call Bass.BASS_PluginLoad(System.AppDomain.CurrentDomain.BaseDirectory() & "bassmidi.dll")
        Call Bass.BASS_PluginLoad(System.AppDomain.CurrentDomain.BaseDirectory() & "bassflac.dll")
        Call Bass.BASS_PluginLoad(System.AppDomain.CurrentDomain.BaseDirectory() & "basswv.dll")

        Dim stream As Integer = Un4seen.Bass.AddOn.Midi.BassMidi.BASS_MIDI_StreamCreateFile(inputMidiFileName, 0, 0, BASSFlag.BASS_STREAM_DECODE, 0)
        Dim mySoundFont As Long = Un4seen.Bass.AddOn.Midi.BassMidi.BASS_MIDI_FontInit(soundFontFileName, 0)
        Dim myFontArray(0) As BASS_MIDI_FONT
        myFontArray(0).font = mySoundFont
        myFontArray(0).preset = -1 ' use all presets
        myFontArray(0).bank = 0 ' use default bank(s)
        Call Un4seen.Bass.AddOn.Midi.BassMidi.BASS_MIDI_StreamSetFonts(0, myFontArray, 1) ' set default soundfont
        Call Un4seen.Bass.AddOn.Midi.BassMidi.BASS_MIDI_StreamSetFonts(stream, myFontArray, 1) ' set for current stream too

        While Bass.BASS_ChannelIsActive(stream) = BASSActive.BASS_ACTIVE_PLAYING
            Dim currentTickPos As Long = Bass.BASS_ChannelGetPosition(stream, BASSMode.BASS_POS_MIDI_TICK)
            Dim playTime = Bass.BASS_ChannelBytes2Seconds(stream, Bass.BASS_ChannelGetPosition(stream, BASSMode.BASS_POS_BYTES))
            'Locate Characters that have the current tick value (currentTickPos)
            'Their "real time" play time (00:00:000)  is playTime (in seconds as a float)
        End While

kxth10

  • Posts: 29
Re: .lyr, .cur, .mid files (aka NCN) karaoke format
« Reply #8 on: 6 Mar '16 - 15:28 »
VB6
Convert NCN to Kar
Convert Kar to NCN

Download NCN Utilities.JPG and Rename to NCN Utilities.rar

kxth10

  • Posts: 29
Re: .lyr, .cur, .mid files (aka NCN) karaoke format
« Reply #9 on: 9 Mar '17 - 07:04 »
I know this post is over a year old, but I'm hoping the kxth10 is still around.  This is the closest I've seen to converting ncn files to kar.  I've tried to compile your source but all it does is create a kar file (which doesn't work) and a track2.txt file (which doesn't contain anything).  Windows just reports that TCC stopped working.  I've tried other compilers and they all create the two files (kar and txt) but again they don't work.  They all have different errors (some report abnormal program termination).  The closest I've gotten to a real error is LCC with:

Exception 0xc000005:
Segment Violation
address 0x40155b

But I don't know what it means.  I'm hoping you can tell me what you used to compile it or if there's a bug can fix it.

In advance thank you for trying.

-Fabio
this code use GetShortName only. If you are run this code in long name path --> the target file not found
eg :
NcnPath = GetShortName("D:\NCN Karaoke 2010\")
CurPath = GetShortName("D:\NCN Karaoke 2010\Cursor")
LyrPath = GetShortName("D:\NCN Karaoke 2010\Lyrics")
MidPath = GetShortName("D:\NCN Karaoke 2010\Song")
karPath = GetShortName("D:\Kar to NCN Convert\")


*** Rename "D:\NCN Karaoke 2010\" to "D:\NCN\ <--- OK.
Code: [Select]
Private Function GetShortName(ByVal sLongFileName As String) As String
    Dim lRetVal As Long, sShortPathName As String, iLen As Integer
    'Set up buffer area for API function call return
    sShortPathName = Space(255)
    iLen = Len(sShortPathName)
   
    'Call the function
    lRetVal = GetShortPathName(sLongFileName, sShortPathName, iLen)
    'Strip away unwanted characters.
    GetShortName = Left(sShortPathName, lRetVal)
End Function
« Last Edit: 9 Mar '17 - 07:37 by kxth10 »

kxth10

  • Posts: 29
Re: .lyr, .cur, .mid files (aka NCN) karaoke format
« Reply #10 on: 9 Mar '17 - 07:31 »
I tried using makekar to migrate a Nick Karaoke track collection to PyKaraoke.  It worked but I needed multibyte character support and it seemed easier to start over, so anyone still looking to do this (and anyone not comfortable with compiling things from source) might want to try my Perl version: https://github.com/zw/ncn-to-kar.

I'm replying here because this is the first (and most useful) hit when searching the web for NCN-to-KAR conversion.

Your program looks great. I'm getting this error. It repeats over and over. Here are the first couple of lines. Any suggestions?

Thanks
Chris

timestamp 0 out of order at E:\Karaoke05_2009\ncn-to-kar.pl line 145, <$lyric_fh
> line 114.
timestamp 0 out of order at E:\Karaoke05_2009\ncn-to-kar.pl line 145, <$lyric_fh
> line 115.

Thanks Chris
OK. this solution change long path to short path or convert long path to short path
eg: "E:\Karaoke05_2009\" to "E:\KARA\"