im sorry this is the complete file. my prob is this...i want the user to select a certain part and then cut and paste it into the same file. just like the nero wave editor...please help...thanks shawn
Get the selection (in samples) not in bytes, and calculate the starting position in the file, and the end position. Using a temporary file copy the data into it.
Then you have to make another temporary file but this time a real wav file, copy the data in front of where you wanna paste, then copy the data from the first temporary file, then copy the data after the pasted data... then you can delete the first temp file and the original file (or you can keep it as an undo).
Also, as a sugestion, take a look at this thread I posted in the CodeBank: VB - DirectXSound - An app that plays large WAV files
I see you want to add effects to the file, using DirectXSound, you can, and also you can play the file appliying the cut and paste information without actually doing it, you just read from the file randomly. You can do it as a preview before you actually make changes to the file.
For example, lets say you want to delete a part of the file, you can store the positions somwhere from where to where you don't want to play (the deleted part). When you play the file, when you get to the starting position, just jump in the file to the end of the deleted part, to the user it sounds as if that part was actually deleted.
There are a lot of things you can do dinamically, by playing the file the way I did in that thread, you can amplify the waveform data, add echo, all in the temporary buffer, just before you play it without actually changing the original file.
i have here a code to paste a selection intoa new file my problem is how will i paste it to the same file..could you help me in my codes?
Private Sub Command5_Click() ' Paste as New File
Dim FTemp As String
Dim InData As Long, LenData As Long
Dim InDataSel As Long, LenDataSel As Long
Dim SampIni As Long, BytInic As Long
Dim Nbits As Integer, StMo As String
Dim ydiv As Integer, SampFreq As Long
If MMCPart = False Or Label8.Caption = "" Then
Picture2.SetFocus
Exit Sub
End If
If Label16(4).Caption = "" Then
msg = "No Selection Made!"
MsgBox msg, vbOKOnly
Exit Sub
End If
MousePointer = vbHourglass ' Busy
Picture2.SetFocus
FTemp = App.Path & "\Untitled" & SCount + 1 & ".wav"
InData = Label11.Caption
SampIni = Label16(4).Caption ' Selection Begins
ydiv = Label12.Caption ' FileSize in Bytes
BytInic = SampIni * ydiv ' Location in the Wav of the Visible Selection
InDataSel = InData + BytInic
LenDataSel = Label16(6).Caption 'Selection Length in Samples
SampFreq = Label8.Caption ' Sampling Frequency
StMo = Label9.Caption ' Stereo Mono
Nbits = Val(Label10.Caption) ' Sampling Bits