0
0

When I use FSOUND_GetCurrentLevels streamChannel, VU_left, VU_Right for the first time the VU’s work correctly. However, if I stop the tune or load another tune they refuse to work. The only way to get them to work again is to shut down the player and re-open it.

Anybody got any ideas.

The routine I am using is:

Private Sub ProcessSampleVUMeters()
FSOUND_GetCurrentLevels streamChannel, VU_left, VU_Right
prcnt = VU_left
picVU(0).Line (0, 0)-(picVU(0).ScaleWidth, picVU(0).ScaleHeight), RGB(0, 0, 0), BF
picVU(0).Line (0, picVU(0).ScaleHeight)-(picVU(0).ScaleWidth, picVU(0).ScaleHeight – prcnt * picVU(0).ScaleHeight), RGB(255, 0, 0), BF
picVU(0).Refresh
prcnt1 = VU_Right
picVU(1).Line (0, 0)-(picVU(1).ScaleWidth, picVU(1).ScaleHeight), RGB(0, 0, 0), BF
picVU(1).Line (0, picVU(1).ScaleHeight)-(picVU(1).ScaleWidth, picVU(1).ScaleHeight – prcnt1 * picVU(1).ScaleHeight), RGB(255, 0, 0), BF picVU(1).Refresh
End Sub

  • You must to post comments
0
0

i don’t see anything wrong here. can you post your code for shuting
down your song and opening it?

  • You must to post comments
0
0

Probably could be written better but here it is:

Routine to Open A File

Private Sub cmdOpenFile_Click()
CheckInitialised
ofn.lpstrFilter = “All Supported Media Types” + Chr$(0) + “.mp3; *.mp2; *.wma; *.ogg; *.wav; *.aif;.s3m; .it; *.xm; *.mod;” + Chr$(0) _
+ “Windows Audio Files (
.wma)” + Chr$(0) + “.wma;” + Chr$(0) _
+ “Ogg Vorbis Audio Files (
.ogg)” + Chr$(0) + “.ogg;” + Chr$(0) _
+ “MP3 Audio Files (
.mp3)” + Chr$(0) + “.mp3;” + Chr$(0) _
+ “WAV Audio Files (
.wav)” + Chr$(0) + “.wav;” + Chr$(0) _
+ “AIF Audio Files (
.aif)” + Chr$(0) + “.aif;” + Chr$(0) _
+ “Scream Tracker 3 Files (
.s3m)” + Chr$(0) + “.s3m;” + Chr$(0) _
+ “IT Tracker Files (
.it)” + Chr$(0) + “.it;” + Chr$(0) _
+ “XM Files (
.xm)” + Chr$(0) + “.xm;” + Chr$(0) _
+ “Tracker Modules (
.mod)” + Chr$(0) + “*.mod;” + Chr$(0)
LoadFile
If filename <> “” Then
filename = Left(filename, Len(filename) – 1)
Label2 = filename
isPlaying = False
If TypeFlag = 0 Then
FMUSIC_FreeSong songHandle
songHandle = 0
Else
FSOUND_Stream_Close streamHandle
streamHandle = 0
End If
picSpectrum.Cls
cmdOpenFile.Enabled = True
cmdPlayFile.Enabled = True
If UCase(Right(filename, 3)) = “S3M” Or UCase(Right(filename, 3)) = “.IT” _
Or UCase(Right(filename, 3)) = “.XM” Or UCase(Right(filename, 3)) = “MOD” Then
TypeFlag = 0
songHandle = FMUSIC_LoadSong(filename)
ModType = FMUSIC_GetType(songHandle)
ModuleType
SetModuleData
Else
TypeFlag = 1
streamHandle = FSOUND_Stream_Open(filename, FSOUND_NORMAL, 0, 0)
lblSampleData(0) = PhraseTime(FSOUND_Stream_GetLengthMs(streamHandle) / 1000)
End If
End If
End Sub

Routine To Play The File

Private Sub cmdPlayFile_Click()
isPlaying = True
If TypeFlag = 0 Then
FMUSIC_PlaySong (songHandle)
Else
streamChannel = FSOUND_Stream_Play(FSOUND_FREE, streamHandle)
FSOUND_GetCurrentLevels channel1, VU_left, VU_Right
End If
cmdOpenFile.Enabled = False
cmdPlayFile.Enabled = False
Timer1.Enabled = True
End Sub

Routine To Stop The File

Private Sub cmdStopPlaying_Click()
isPlaying = False
If TypeFlag = 0 Then
FMUSIC_StopSong songHandle
Else
FSOUND_Stream_Stop streamHandle
streamChannel = 0
End If
cmdOpenFile.Enabled = True
cmdPlayFile.Enabled = True
Timer1.Enabled = False
picVU(0).Cls
picVU(1).Cls
picSpectrum.Cls
Label1 = songHandle
End Sub

Routines Called During Load & Stop

Private Sub CheckInitialised()
If Initialised = False Then
Initialised = FSOUND_Init(44100, 32, 0)
End If
End Sub

Private Sub LoadFile()
ofn.lpstrInitialDir = CurDir
ofn.lpstrTitle = “File Open”
filename = “”
rtn = “”
ofn.lStructSize = Len(ofn)
ofn.hwndOwner = Form1.hwnd
ofn.hInstance = App.hInstance
ofn.lpstrFile = Space$(254)
ofn.nMaxFile = 255
ofn.lpstrFileTitle = Space$(254)
ofn.nMaxFileTitle = 255
ofn.flags = 0
a = GetOpenFileName(ofn)
filename = Trim$(ofn.lpstrFile)
End Sub

Private Sub SetModuleData()
lstSamples.Clear
lblModuleData(0) = ModTypeDesc
lblModuleData(2) = FMUSIC_GetNumSamples(songHandle)
For loopy = 0 To FMUSIC_GetNumSamples(songHandle) – 1
loopystr = Str(loopy) + 1
If Len(loopystr) = 1 Then loopystr = ” ” & loopystr
lstSamples.AddItem loopystr & “. #” & GetStringFromPointer(FMUSIC_GetSample(songHandle, loopy))
Next loopy
lblModuleData(3) = FMUSIC_GetNumChannels(songHandle)
lblModuleData(4) = FMUSIC_GetNumInstruments(songHandle)
lblModuleData(5) = “0/” & FMUSIC_GetNumPatterns(songHandle) – 1
lblModuleData(6) = GetStringFromPointer(FMUSIC_GetName(songHandle))
End Sub

Private Sub ModuleType()
Select Case ModType
Case 1
ModTypeDesc = “Protracker / Fasttracker”
Case 2
ModTypeDesc = “ScreamTracker 3”
Case 3
ModTypeDesc = “FastTracker 2”
Case 4
ModTypeDesc = “Impulse Tracker”
Case 5
ModTypeDesc = “MIDI file”
Case 6
ModTypeDesc = “FMOD Sample Bank file”
End Select
End Sub

Private Sub Timer1_Timer()
If TypeFlag = 0 Then
ret = FMUSIC_IsPlaying(songHandle)
lblModuleData(1) = PhraseTime(FMUSIC_GetTime(songHandle) / 1000)
lblModuleData(5) = FMUSIC_GetPattern(songHandle) & “/” & FMUSIC_GetNumPatterns(songHandle) – 1
lblModuleData(7) = FMUSIC_GetBPM(songHandle)
Else
ret = FSOUND_IsPlaying(streamChannel)
lblSampleData(1) = PhraseTime(FSOUND_Stream_GetTime(streamHandle) / 1000)
End If
Label4 = “CPUUsage: ” & Format(FSOUND_GetCPUUsage, “###0.00”) & “%”
End Sub

  • You must to post comments
0
0

[quote:1fajb0dh]
Private Sub cmdPlayFile_Click()
isPlaying = True
If TypeFlag = 0 Then
FMUSIC_PlaySong (songHandle)
Else
streamChannel = FSOUND_Stream_Play(FSOUND_FREE, streamHandle)
FSOUND_GetCurrentLevels channel1, VU_left, VU_Right
End If
cmdOpenFile.Enabled = False
cmdPlayFile.Enabled = False
Timer1.Enabled = True
End Sub
[/quote:1fajb0dh]

first off what is this for:
streamChannel = FSOUND_Stream_Play(FSOUND_FREE, streamHandle)
<B>FSOUND_GetCurrentLevels channel1, VU_left, VU_Right ?</B>

How is Private Sub ProcessSampleVUMeters() called anyway? timer?
maybe you are not calling after you shut down or load a new song?
I see no calls to this sub routine in here.

I can’t tell much with this.

  • You must to post comments
0
0

FSOUND_GetCurrentLevels channel1, VU_left, VU_Right isn’t needed and should have been removed.

The routine is being called from whether a CheckBox is checked or not.

Form_Load has the following code in:

Do Until StopProg
progEvents
DoEvents
Loop

and progEvents is:

Private Sub progEvents()
If isPlaying Then
If UseSpectrumBars Then
SpectrumBars
End If
If UseVUMeters Then
ProcessSampleVUMeters
End If
If Oscilate Then
Oscilater
End If
If Oscilate2 Then
Oscilater2
End If
If Oscilate3 Then
Oscilater3
End If
If Oscilate4 Then
Oscilater4
End If
If MyVUMeters = True Then
VolumeMeters
End If
End If
End Sub

Private Sub Check1_Click()
If Check1.Value = 0 Then
UseVUMeters = False
picVU(0).Cls
picVU(1).Cls
Else
UseVUMeters = True
End If
End Sub

Just to add a side note, I have cleaned up some of my code and the VU’s work fine now. Is there a way of getting them to work with an FSound file, i.e. a mod or s3m?

  • You must to post comments
0
0

Hay all,
Well, I don’t Know what is this all about, I’am using a timer to retrieve the Levels and the spectrum Each 15ms and the code is seperated completely from the main Intialize,Open code and works very fine,The timer is alwayes enabled but it checks first to see if there is any tracks currently playing on the Fmod System and if not it just ends the routin and try agian ,etc.

  • You must to post comments
Showing 5 results
Your Answer

Please first to submit.