'$include:'opensave.bi'
'$include:'winbox.bi'
Const MusicStep 
= 100 'how much pixels use for 1 second of sample sound  
    '   Name AS STRING * 50
    '  Path AS STRING * 200
 
 
 
    Von 
As Integer ' this is for graphic coordinate for inserting samples 
 
'globalni pole vzorku
 
'pomocne pole SAMplu
 
'---------------------------------- deklarace pro grafickou koordinaci -----------------------------
    '    Inf As Sample
 
ReDim Shared LG
(0) As Graphic 
'left channel graphic (samples position in time, samples position in one from 10 voices [ROW], samples infos [inf as SAMPLE]  
 
'kazdym vkladem samplu se konkretni pole navysi
 
'---------------------------------------------------------------------------------------------------
 
 
 
 
 
test& = BackgroundImage&
 
 
'On Error GoTo errhnd
 
 
 
 
            test$ = SelectFile
                snd = LOADSAMPLE(test$)
                '  Print "Navratova hodnota funkce LOADSAMPLE je:"; snd   'cislo snd se ulozi do pole zasobniku samplu
 
                PLAYSAMPLE snd
 
            ShiftGridX = ShiftGridX + 10 'Grid to LEFT
            If ShiftGridX 
> 0 Then ShiftGridX 
= 0  
 
            ShiftGridX = ShiftGridX - 10 'Grid to RIGHT
            If ShiftGridX 
> 3600 * MusicStep 
Then ShiftGridX 
= 3600 * MusicStep
  
 
            ShiftGridX = ShiftGridX + 1000 'Grid to LEFT
            If ShiftGridX 
> 0 Then ShiftGridX 
= 0  
 
            ShiftGridX = ShiftGridX - 1000 'Grid to RIGHT
            If ShiftGridX 
> 3600 * MusicStep 
Then ShiftGridX 
= 3600 * MusicStep
  
            SaveOutput
 
 
 
    
    If Position 
< 0 Then Position 
= 0     If Position 
> MusicStep 
* 3600 Then Position 
= MusicStep 
* 3600 'maximum is hour long record  
 
 
 
 
    'kresba casove osy
 
 
    
    GridX = ShiftGridX
 
    TimeStart = (-ShiftGridX - 5) / MusicStep
    TimeEnd = (-ShiftGridX / MusicStep) + ((DW - 75) / MusicStep)
 
 
 
 
 
 
    If GridX 
> 80 + MusicStep 
Then         GridX = 0
        '   GridH = GridH + 1
    bG = 1
 
    If TimeStart 
Mod 10 <> 0 Then TimeView 
= Int(TimeStart 
+ 1) Else TimeView 
= _Ceil(TimeStart 
+ .06) '1   posledni upravy v tomto radku     If TimeStart 
< 0 Then TimeView 
= 0     For GridDraw 
= GridX 
To MusicStep 
+ DW 
Step MusicStep 
/ 10         bG = bG + 1 'pro kresbu silnych car
            Line (GridDraw
, DH 
* .1)-(GridDraw
, DH 
* .453), &H40FFFFFF ' Left channel             Line (GridDraw
, DH 
* .905)-(GridDraw
, DH 
* .552), &H40FFFFFF ' RIGHT channel                 Line (GridDraw 
+ 1, DH 
* .09)-(GridDraw 
- 1, DH 
* .453), &H40FFFFFF, BF 
'LEFT channel                 Line (GridDraw 
+ 1, DH 
* .905)-(GridDraw 
- 1, DH 
* .540), &H40FFFFFF, BF 
'RIGHT channel  
                _PrintString (GridDraw 
- CenterText
, DH 
* .07), CenterText$ 
'left                 _PrintString (GridDraw 
- CenterText
, DH 
* .52), CenterText$ 
'right  
                _PrintString (GridDraw 
- 20, DH 
* .055), SecAsTime$
(TimeView
) 'left                 _PrintString (GridDraw 
- 20, DH 
* .505), SecAsTime$
(TimeView
) 'right  
                TimeView = TimeView + 1
 
 
    
 
    InsertLenght = SAMLEN(snd)
    'Locate 3
    'Print InsertLenght, snd
 
 
    If snd 
Then Line (MX
, MY
)-(MX 
+ InsertLenght
, MY 
+ 16), &H99FFFF00, BF
         SelectedTime = (-ShiftGridX + MX - 80) / MusicStep
        InsertStartTime$ = SecAsTime$(SelectedTime)
 
        If LMB 
Then 'akce levym tlacitkem mysi                 InsertSam snd, SelectedTime, MY, MX - ShiftGridX
                'wait for mouse left button release
 
 
                'snd = 0 aby bylo mozno stejny nastroj vlozit na vice mist, neanuluji ho po jednom vkladu, ale az pri stisku Esc   nebo pri otevreni noveho samplu
 
 
        'InsertSam nema kontrolu toho, jestli nevkladas sampl nekam, kde uz jiny je (ve stejnem hlasu a ve stejnem nebo mensim ci prekryvajicim se rozsahu casu)
 
    '--------------- predchozi radky resi vklad hudby, nasleduje reseni zobrazeni hudby ----------------------
    ViewSamplesOnScreen ShiftGridX, DW - ShiftGridX
 
 
 
 
 
 
 
 
 
 
errhnd:
 
 
'test$ = SelectFile
'PRINT test$
'BoxTest = MsgBox("Test okna" + CHR$(0), "Dobrý den" + CHR$(0), 4, 2, 6, 4096)
 
 
 
 
   
    i = 0
        If maxtimeL 
< LG
(i
).TimePos 
+ SAM
(LG
(i
).NR
).UsedLenght 
Then             maxtimeL = LG(i).TimePos + SAM(LG(i).NR).UsedLenght
            iL = i
        i = i + 1
    i = 0
        If maxtimeR 
< RG
(i
).TimePos 
+ SAM
(LG
(i
).NR
).UsedLenght 
Then             maxtimeR = RG(i).TimePos + SAM(LG(i).NR).UsedLenght
            iR = i
        i = i + 1
    i = 0
        TotalTime = maxtimeL
        uI = iL
        TotalTime = maxtimeR
        uI = iR
 
    TotalTime = TotalTime + SAM(uI).UsedLenght
 
    Print "SaveOutput: Celkova spocitana delka audio vystupu je: "; TotalTime
  
    'alokace pameti pro vystup
    L 
= _MemNew(TotalTime 
* 44100 * 2) 'integer 
 
 
    '  LG.NR = cislo samplu
    '  SAM(cislo samplu)...
 
        SamNr = LG(Left).NR
        StartBytePosition& = 2 * LG(Left).TimePos * 44100
        EndBytePosition& = 2 * (LG(Left).TimePos + SAM(SamNr).UsedLenght) * 44100
        LM& = StartBytePosition&
                ValueOut = (CV + Samples(SAM(SamNr).StartO + ReadSam).Left) / 2
                ValueOut = Samples(SAM(SamNr).StartO + ReadSam).Left
 
 
            _MemPut L
, L.OFFSET 
+ LM&
, ValueOut
             LM& = LM& + 2
            ReadSam = ReadSam + SAM(SamNr).Speed / 100
        ReadSam = 0
 
        SamNr = RG(Right).NR
        StartBytePosition& = 2 * RG(Right).TimePos * 44100
        EndBytePosition& = 2 * (RG(Right).TimePos + SAM(SamNr).UsedLenght) * 44100
        RM& = StartBytePosition&
            If CV 
Then ValueOut 
= (CV 
+ Samples
(SAM
(SamNr
).StartO 
+ ReadSam
).Right 
* (SAM
(SamNr
).Volume 
/ 100)) / 2 Else ValueOut 
= Samples
(SAM
(SamNr
).StartO 
+ ReadSam
).Right 
* (SAM
(SamNr
).Volume 
/ 100)             _MemPut R
, R.OFFSET 
+ RM&
, ValueOut
             RM& = RM& + 2
            ReadSam = ReadSam + SAM(SamNr).Speed / 100
        ReadSam = 0
 
    SAVESOUND16S L, R, "output.wav"
 
 
 
 
 
 
 
 
 
Sub ViewSamplesOnScreen 
(PixelsStart
, PixelsEnd
) ' time, time, coordinate - X begin, coordinate - X end     'nejprve se musi urcit, jestli cas je v rozsahu viditelnosti, cili jestl je LG(i).timepos > TimeSart a soucasne je LG(i).timepos + lg(i).timepos + lg (i).inf.usedlenght < timeend
    'musi spocitat delku samplu v pixelech
    V = 0
 
        'prepocitat casovou pozici na pixely
        CalcGraphicStart = LG(V).GrPos
        CalcGraphicEnd = SAM(LG(V).NR).UsedLenght * MusicStep + LG(V).GrPos
 
        '        If PixelsStart <= CalcGraphicStart And PixelsEnd >= CalcGraphicEnd Or PixelsStart < CalcGraphicStart And PixelsStart > CalcGraphicEnd Then 'pokus o vklady long samplu
        'urcit spravnou polohu Y
        VoiceGraphicYs = LeftIns(LG(V).Row).Von + 3
        VoiceGraphicYe = LeftIns(LG(V).Row).Bis - 3
        'nakreslit znacku
        MarkStart = PixelsStart + CalcGraphicStart
        MarkEnd = PixelsStart + CalcGraphicEnd
 
        If MarkStart 
< 80 Then MarkStart 
= 80         If MarkEnd 
< 80 Then MarkEnd 
= 80         If MarkEnd 
> DW 
Then MarkEnd 
= DW
  
        If MarkEnd 
- MarkStart 
Then Line (MarkStart
, VoiceGraphicYs
)-(MarkEnd
, VoiceGraphicYe
), &H70FFAA0E, BF
         '       End If
        V = V + 1
 
    V = 0
 
        'prepocitat casovou pozici na pixely
        CalcGraphicStart = RG(V).GrPos
        CalcGraphicEnd = SAM(RG(V).NR).UsedLenght * MusicStep + RG(V).GrPos
 
        '        If PixelsStart <= CalcGraphicStart And PixelsEnd >= CalcGraphicEnd Then
        'urcit spravnou polohu Y
        VoiceGraphicYs = RightIns(RG(V).Row).Von + 3
        VoiceGraphicYe = RightIns(RG(V).Row).Bis - 3
        'nakreslit znacku
 
        
        MarkStart = PixelsStart + CalcGraphicStart
        MarkEnd = PixelsStart + CalcGraphicEnd
 
        If MarkStart 
< 80 Then MarkStart 
= 80         If MarkEnd 
< 80 Then MarkEnd 
= 80         If MarkEnd 
> DW 
Then MarkEnd 
= DW
  
        If MarkEnd 
- MarkStart 
Then Line (MarkStart
, VoiceGraphicYs
)-(MarkEnd
, VoiceGraphicYe
), &H70FFAA0E, BF
  
 
        '       End If
        V = V + 1
 
 
Sub InsertSam 
(SamNr
, Time
, MousePosY
, RelativePosX
) ' insert sample to voice/channel (every channel contains 10 voices) - LG array for left channel, RG for right channel     test = 0
        test = test + 1
        If MousePosY 
>= LeftIns
(test
).Von 
And MousePosY 
<= LeftIns
(test
).Bis 
Then Voice 
= 10 + test: 
GoTo Pass
         If MousePosY 
>= RightIns
(test
).Von 
And MousePosY 
<= RightIns
(test
).Bis 
Then Voice 
= 30 + test: 
GoTo Pass
     'if mouse is not in correct position, nothing is inserted, so exit sub
 
    Pass:
 
 
    Channel = Voice - 10 '1 - 10 = left; 21 - 30 = right
 
            Voice = Channel
            '   Print "Levy kanal"
            '  Print "Cislo hlasu: "; Voice 'OK
 
 
 
            LG(LGi).Row = Voice
            LG(LGi).NR = SamNr
            LG(LGi).TimePos = Time
            LG(LGi).GrPos = RelativePosX
            'pokud jde o stereo zvuk, vlozi se do obou poli:
            If Chr$(SAM
(SamNr
).Format
) = "S" Then 'if is sample in stereo format, insert both audio channels to both arrays                 RG(RGi).Row = Voice
                RG(RGi).NR = SamNr
                RG(RGi).TimePos = Time
                RG(RGi).GrPos = RelativePosX
                RGi = RGi + 1
            LGi = LGi + 1
 
            Voice = Channel - 20
            '    Print "Pravy kanal"
            '   Print "Cislo hlasu: "; Voice 'OK
 
            RG(RGi).Row = Voice
            RG(RGi).NR = SamNr
            RG(RGi).TimePos = Time
            RG(RGi).GrPos = RelativePosX
            'pokud jde o stereo zvuk, vloz to do obou poli
            If Chr$(SAM
(SamNr
).Format
) = "S" Then 'also: if is sample in stereo, insert both audio channels to both arrays                 LG(LGi).Row = Voice
                LG(LGi).NR = SamNr
                LG(LGi).TimePos = Time
                LG(LGi).GrPos = RelativePosX
                LGi = LGi + 1
            RGi = RGi + 1
 
 
 
 
Function SAMLEN 
(SamNr
) 'Return lane lenght in pixels according to the length of the music     SAMLEN = (SAM(SamNr).UsedLenght - SAM(SamNr).StartPos) * MusicStep
 
Sub PLAYSAMPLE 
(samNr
) 'jen pro prehrani konkretniho samplu, bez mixovani s ostatnimi        For playing 1 sample without mixing     '    Print "PLAYSAMPLE spusten..."
    'bude to tak, ze se bleskove udela WAV soubor a ten se pusti pres _sndplayfile
    Volume = SAM(samNr).Volume / 100
 
    OriginalSize& = SAM(samNr).EndO - SAM(samNr).StartO + 4
    T = 100 / SAM(samNr).Speed 'for music speed options
    T2 = SAM(samNr).Speed / 100 'step for read music data from array definded with DIM
 
    MEMLEN& = T * OriginalSize& * 2
 
 
    S = 0: I2 = 0
 
    ' "Spustena smycka for S od "; SAM(samNr).StartO; " do"; SAM(samNr).EndO; " krok je"; T2
    For S 
= SAM
(samNr
).StartO 
To SAM
(samNr
).EndO 
Step T2
         ' IF samNr > 0 THEN
        ' _SNDRAW (Samples(S).Left / 32768) * Volume, (Samples(S).Right / 32768) * Volume 'ZJISTENO: PRI DRUHEM BEHU SEM JDE PRAZDNA PAMET   L, R
        ' IF TEST = 0 THEN BEEP: TEST = 1
        ' END IF
 
        LeftValue = Samples(S).Left * Volume
        RightValue = Samples(S).Right * Volume
        _MemPut L
, L.OFFSET 
+ I2
, LeftValue
         _MemPut R
, R.OFFSET 
+ I2
, RightValue
         I2 = I2 + 2
 
    ' Print "Jeden prubeh je uspesne dokoncen - konec PLAYSAMPLE, rizeni predano SaveSound16S!"
 
    SAVESOUND16S L, R, "se.wav"
    ' Print "SNDOPEN..."
 
    ' Print "cislo zvuku udelene SNDOPENem "; SamplePlay
 
 
 
 
 
    '
 
 
    size = OFFSET_to_I64(left.SIZE) / 2
 
    HeaderSize = size
            HeaderSize = HeaderSize - 1
 
 
        size 
As Long '              4 bytes  (file size)        subchunksize 
As Long '      4 bytes  (lo / hi), $00000010 for PCM audio        format 
As Integer '         2 bytes  (0001 = standard PCM, 0101 = IBM mu-law, 0102 = IBM a-law, 0103 = IBM AVC ADPCM)        channels 
As Integer '       2 bytes  (1 = mono, 2 = stereo)        rate 
As Long '              4 bytes  (sample rate, standard is 44100)        ByteRate 
As Long '          4 bytes  (= sample rate * number of channels * (bits per channel /8))        Block 
As Integer '          2 bytes  (block align = number of channels * bits per sample /8)        Bits 
As Integer '           2 bytes  (bits per sample. 8 = 8, 16 = 16)        subchunk2 
As String * 4 '   4 bytes  ("data")  contains begin audio samples        lenght 
As Long '            4 bytes  Data block size 
    H16.chunk = "RIFF"
    H16.size = 44 + size * 4
    H16.fomat = "WAVE"
    H16.sub1 = "fmt "
    H16.subchunksize = 16
    H16.format = 1
    H16.channels = 2
    H16.rate = 44100
    H16.ByteRate = 44100 * 2 * 16 / 8
    H16.Block = 4
    H16.Bits = 16
    H16.subchunk2 = "data"
    H16.lenght = size * 4 'stereo and integer = 2 + 2
 
 
 
 
 
    'recalculate audiodata to file - byte - values
 
 
    Start = 0
    '  Print "SaveSound16S: Spustena smycka FOR"
    empty = 0
        If LeftChannel16 
= 0 And RightChannel16 
= 0 Then empty 
= empty 
+ 1  
        _MemPut Recalc
, Recalc.OFFSET 
+ S
, LeftChannel16
         _MemPut Recalc
, Recalc.OFFSET 
+ S 
+ 2, RightChannel16
         S = S + 4
 
    H16.size = 44 + S
    H16.lenght = S
 
 
    'write audio data to file
    ' Print "SaveSound16S: Smycka FOR ukoncena, Spusten SPACE$"; empty; S~&
 
    _MemGet Recalc
, Recalc.OFFSET
, WAVeRAW$
  
    'erase memory
    WAVeRAW$ = ""
    '   Print "SaveSound16S dokonceno, rizeni predano PLAYSAMPLE"
 
 
 
 
 
 
    Size = OFFSET_to_I64(Left.SIZE) 'convertion is used for WAV file header, becuse offset value can not be used directly
 
        size 
As Long '              4 bytes  (file size)        subchunksize 
As Long '      4 bytes  (lo / hi), $00000010 for PCM audio        format 
As Integer '         2 bytes  (0001 = standard PCM, 0101 = IBM mu-law, 0102 = IBM a-law, 0103 = IBM AVC ADPCM)        channels 
As Integer '       2 bytes  (1 = mono, 2 = stereo)        rate 
As Long '              4 bytes  (sample rate, standard is 44100)        ByteRate 
As Long '          4 bytes  (= sample rate * number of channels * (bits per channel /8))        Block 
As Integer '          2 bytes  (block align = number of channels * bits per sample /8)        Bits 
As Integer '           2 bytes  (bits per sample. 8 = 8, 16 = 16)        subchunk2 
As String * 4 '   4 bytes  ("data")  contains begin audio samples        lenght 
As Long '            4 bytes  Data block size 
    H8.chunk = "RIFF"
    H8.size = 44 + Size / 2
 
    H8.fomat = "WAVE"
    H8.sub1 = "fmt "
    H8.subchunksize = 16
    H8.format = 1
    H8.channels = 2
    H8.rate = 44100
    H8.ByteRate = 44100 * 2 * 8 / 8
    H8.Block = 2
    H8.Bits = 8
    H8.subchunk2 = "data"
    H8.lenght = Size / 2
 
 
 
    size = Left.SIZE 'now this value is for memory size used by SINGLE ARRAY - WAV 8bit need 1 byte for 1 channel and 1 sample
 
    'recalculate audiodata to file - byte - values
 
    Recalc 
= _MemNew(size 
/ 2) 'this is value used by WAV - size is 4 byte per sample, we recording stereo (2 x 1 byte) therefore is this divided by 2 
    start& = 0: LRO& = 0
 
        LeftChannel8 = 128 - RawLeft * 128
        RightChannel8 = 128 - RawRight * 128
 
        _MemPut Recalc
, Recalc.OFFSET 
+ s&
, LeftChannel8
         _MemPut Recalc
, Recalc.OFFSET 
+ s& 
+ 1, RightChannel8
         s& = s& + 2
        start& = start& + 4
 
    'write audio data to file
 
    _MemGet Recalc
, Recalc.OFFSET
, WAVeRAW$
  
    'erase memory
    WAVeRAW$ = ""
 
Function TestWaveFormat 
(file 
As String, Left 
As _MEM, Right 
As _MEM, Channels
, LenghtOther
) '          test if WAV is supported 16 bit type or not (if is wav loaded using key S)  
        size 
As Long '              4 bytes  (file size)        subchunksize 
As Long '      4 bytes  (lo / hi), $00000010 for PCM audio        format 
As Integer '         2 bytes  (0001 = standard PCM, 0101 = IBM mu-law, 0102 = IBM a-law, 0103 = IBM AVC ADPCM)        channels 
As Integer '       2 bytes  (1 = mono, 2 = stereo)        rate 
As Long '              4 bytes  (sample rate, standard is 44100)        ByteRate 
As Long '          4 bytes  (= sample rate * number of channels * (bits per channel /8))        Block 
As Integer '          2 bytes  (block align = number of channels * bits per sample /8)        Bits 
As Integer '           2 bytes  (bits per sample. 8 = 8, 16 = 16)        subchunk2 
As String * 4 '   4 bytes  ("data")  contains begin audio samples        lenght 
As Long '            4 bytes  Data block size    TestWaveFormat = H.Bits
    Channels = H.channels
    LenghtOther = H.lenght / (H.Bits / 8) / H.channels / H.rate 'without (   ) generate message Program stop working.... - not in 1.5
    '
 
    ' error:
    'LenghtOther = H.lenght \ (H.Bits \ 8) \ H.channels / H.rate
    'End
 
    '    Print "LenghtOther:"; LenghtOther ' ok
 
    'if H.Bits is not 16, convert it!
        Case 24 'RhoSigma Help ----> thanks RhoSigma for help with this!             '   Print "24 bit vaweform decoder:"
            '   Print H.channels
 
            If H.channels 
= 1 Then multipl 
= 2 Else multipl 
= 1             Left 
= _MemNew((H.lenght \ 
3) * multipl
) 
            index& = 0
 
            For samp& 
= 0 To (Len(f$
) / SO
) - 1 'lenght / block align - 1                 Ls& = 0: Rs& = 0 'clear samples
                    'loop trough little endian file data to build samples
                    Ls& 
= (Ls& 
* 256) + Asc(f$
, (samp& 
* SO
) + i%
) 'shift current value 8 bits left and add next byte                    If H.channels 
= 2 Then Rs& 
= (Rs& 
* 256) + Asc(f$
, (samp& 
* 6) + i% 
+ 3)                 'if MSB (bit 23) is set (negative sample) then sign extend to LONG
                'play normalized samples in range -1.0 to +1.0
                LFT = ((Ls& / 8388608#) * 32767)
                If H.channels 
= 2 Then RGH 
= ((Rs& 
/ 8388608#
) * 32767)                 _MemPut Left
, Left.OFFSET 
+ index&
, LFT
                 index& = index& + 2
 
            Print "8 or 32 bit wavefom not supported yet!"  
 
 
 
 
 
Function LOADSAMPLE 
(path 
As String) '                                            Function load music file and add music data to arrays Samples and also add one record to array SAM and return SAM index         If UCase$(Right$(path
, 3)) = "WAV" Then FileFormat 
= TestWaveFormat
(path
, L
, R
, Chann
, LenghtOther
) Else FileFormat 
= 16: Chann 
= 2 'MP3, OGG = 16, if format is not 16 bit, convert and load it to L, R as INTEGERs (16bit)  
        If FileFormat 
= 16 Then 'wav is 16 bit (supported with _SndOpen)             L = _MemSound(sndswp, 1)
            R = _MemSound(sndswp, 2)
 
        SamplePlay = 0 'predchozi sampl se anuluje
 
 
        StartOffset& 
= UBound(Samples
) + 1        EndOffset& = StartOffset& + OFFSET_to_I64(L.SIZE) 'ok!
 
        SAM(U).StartO = StartOffset&
        SAM(U).EndO = EndOffset&
        If FileFormat 
= 24 Then SAM
(U
).Lenght 
= LenghtOther
         SAM(U).Volume = 100 '                                                  sound volume in percentage
        SAM(U).Speed = 70 '                                                    sound speed in percentage (works)
        SAM(U).Effect = 0
        SAM(U).StartPos = 0 '                                                  default: play sample from begin
        SAM(U).UsedLenght = SAM(U).Lenght '                                    default: play whole sample (full lenght)
        '    SAM(U).Path = path '                                                   just for info, not sure if this will be used or not
        '   SAM(U).Name = _TRIM$(MID$(path, _INSTRREV(1, path, CHR$(92)))) '       just for info, not sure if this will be used or not
 
 
 
        D& = StartOffset&
        Done& = 0
 
            Samples(D&).Left = LSPK
 
            '            IF R.SIZE > 0 THEN
                Samples(D&).Right = RSPK
            '           ELSE
            '          Samples(D&).Right = 0
            '         END IF
            Done& = Done& + 2
            D& = D& + 1
        LOADSAMPLE = U
 
        Print "Error. Path or file"; path$; 
"not found."  
 
 
 
 
        Offset_to_i64 = num
        OFFSET_to_I64 = num
 
 
 
Function BackgroundImage& 
'                                                                                                     Create Background image and fill arrays RightIns and LeftIns with Lane coordinates  
    'pruhu bude 10, mezi levou a pravou stopou bude cca 10 procent mista
 
    LaneHeight = (DH - .3 * DH) / 20
 
    For LeftChannelLanes 
= DH 
* .1 To DH 
* .1 + 9 * LaneHeight 
Step LaneHeight
         i = i + 1
        Line (0, LeftChannelLanes
)-(DW
, LeftChannelLanes 
+ LaneHeight
), _RGBA32(25, 25, 200, 180), BF
         Line (0, LeftChannelLanes
)-(DW
, LeftChannelLanes 
+ LaneHeight
), _RGBA32(25, 25, 25, 25), B
         LeftIns(i).Von = LeftChannelLanes + 5
        LeftIns(i).Bis = LeftChannelLanes + LaneHeight - 5
    i = 0
    For RightChannelLanes 
= LeftChannelLanes 
+ DH 
* .1 To LeftChannelLanes 
+ DH 
* .1 + 9 * LaneHeight 
Step LaneHeight
         i = i + 1
        Line (0, RightChannelLanes
)-(DW
, RightChannelLanes 
+ LaneHeight
), _RGBA32(25, 25, 200, 180), BF
         Line (0, RightChannelLanes
)-(DW
, RightChannelLanes 
+ LaneHeight
), _RGBA32(25, 25, 25, 25), B
         RightIns(i).Von = RightChannelLanes + 5
        RightIns(i).Bis = RightChannelLanes + LaneHeight - 5
    '    PRINT LaneHeight
    BackgroundImage& = sw&
 
 
 
 
 
Function SelectFile$ 
'for browse and select audio file (audio sources)                                                        WINBOX piece         hWnd 
= _WindowHandle 'FindWindow(0, "Open and Save Dialog demo" + CHR$(0)) 'get window handle using _TITLE string        hWnd&& 
= FindWindow
(0, "FOCdemo" + CHR$(0)) 'get window handle using _TITLE string 
    Filter$ = "WAV files (*.WAV)|*.WAV|MP3 files (*.MP3)|*.MP3|OGG files (*.OGG)|*.OGG|"
    Flags& = OFN_FILEMUSTEXIST + OFN_NOCHANGEDIR + OFN_READONLY '    add flag constants here
 
    OFile$ = GetOpenFileName$("Select source audio file", ".\", Filter$, 1, Flags&, hWnd&&)
 
        SelectFile$ = OFile$
        'IF (Flags& AND OFN_READONLY) THEN PRINT "Read-only checkbox checked." 'read-only value in return
 
Function SecAsTime$ 
(value
) '                                                                                                 Function convert seconds to time format as 00:00:00     '75 = 01:15
 
    sec 
= Int(value 
- 60 * m2
)    set 
= CSng((value 
- 60 * m2
) - sec
)    SecAsTime$ = m2$ + ":" + sec$ + ":" + set$
 
 
 
'$include:'opensave.bm'
'$include:'winbox.bm'