English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. Blitz Basic

 
 
Thread Tools
Old 15 January 2021, 23:36   #1
Amiga1992
Registered User
 
Join Date: May 2001
Location: ?
Posts: 19,645
SetPeriod does not seem to like values I am inputting

I'm trying to change the pitch of a sound I loaded using SetPeriod, and I am using the following table (taken from the Protracker player source):

Code:
856,808,762,720,678,640,604,570,538,508,480,453
428,404,381,360,339,320,302,285,269,254,240,226
214,202,190,180,170,160,151,143,135,127,120,113
Which corresponds to:
Code:
C-1,C#1,D-1,D#1,E-1,F-1,F#1,G-1,G#1,A-1,A#1,B-1
C-2,C#2,D-2,D#2,E-2,F-2,F#2,G-2,G#2,A-2,A#2,B-2
C-3,C#3,D-3,D#3,E-3,F-3,F#3,G-3,G#3,A-3,A#3,B-3
Now, when I try values, I get random problems. Some times this works, sometimes it produces no sound or really low volume garble and I don't understand why. For example, 113,120 and 127 work. 226, 240 and 254 work too. But the pitch is the same as the previous set of 3?

Any ideas?

Last edited by Amiga1992; 16 January 2021 at 00:46.
Amiga1992 is offline  
Old 18 January 2021, 17:11   #2
Amiga1992
Registered User
 
Join Date: May 2001
Location: ?
Posts: 19,645
Nobody?

[edit] for reference, this is a simplified version of the code I am using:

Code:
Statement LaunchSample {track,period} 

	SHARED channelMask
	
	SetPeriod track, period
	Sound track, channelMask

End Statement

Last edited by Amiga1992; 19 January 2021 at 15:18.
Amiga1992 is offline  
Old 16 February 2021, 12:28   #3
8bitbubsy
Registered User
 
8bitbubsy's Avatar
 
Join Date: Sep 2009
Location: Norway
Posts: 1,710
Quote:
Originally Posted by Akira View Post
I'm trying to change the pitch of a sound I loaded using SetPeriod, and I am using the following table (taken from the Protracker player source):

Code:
856,808,762,720,678,640,604,570,538,508,480,453
428,404,381,360,339,320,302,285,269,254,240,226
214,202,190,180,170,160,151,143,135,127,120,113
Which corresponds to:
Code:
C-1,C#1,D-1,D#1,E-1,F-1,F#1,G-1,G#1,A-1,A#1,B-1
C-2,C#2,D-2,D#2,E-2,F-2,F#2,G-2,G#2,A-2,A#2,B-2
C-3,C#3,D-3,D#3,E-3,F-3,F#3,G-3,G#3,A-3,A#3,B-3
Now, when I try values, I get random problems. Some times this works, sometimes it produces no sound or really low volume garble and I don't understand why. For example, 113,120 and 127 work. 226, 240 and 254 work too. But the pitch is the same as the previous set of 3?

Any ideas?
It sounds like you are somehow working with bytes instead of words here.
8bitbubsy is offline  
Old 23 February 2021, 23:10   #4
Amiga1992
Registered User
 
Join Date: May 2001
Location: ?
Posts: 19,645
Quote:
Originally Posted by 8bitbubsy View Post
It sounds like you are somehow working with bytes instead of words here.
Hmm interesting, I would not know why, because Blitz defines these sound objects, and:

Code:
 _data.l             ;00: NULL if no sound present, else pointer to sound data
 _period.w           ;04: period of sound
 _length.w           ;06: length, in words, of sound data
 _loop.l             ;08: repeat to loop position of sound
 _looplength.w       ;12: length of looping section, in words
 _pad.b[2]           ;14:
Period is clearly defined as word.
Amiga1992 is offline  
Old 24 February 2021, 00:05   #5
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
Hmmm, I haven't looked at this properly on my own machine, but is it possible your types are getting mixed up? The struct definitely does use a word type, but if your function is taking a value of a different type, things might be getting mangled. Try defining the types in your statement definition:

Code:
Statement LaunchSample {track.w, period.w}
just in case they're defaulting to something else. Typically the default in Blitz is quick, which should cast to word without issues, but it can be changed.
Daedalus is offline  
Old 24 February 2021, 00:57   #6
Amiga1992
Registered User
 
Join Date: May 2001
Location: ?
Posts: 19,645
Quote:
Originally Posted by Daedalus View Post
just in case they're defaulting to something else. Typically the default in Blitz is quick, which should cast to word without issues, but it can be changed.
that would be weird because at the top of my code I made a
Code:
DEFTYPE .w
I'll try your suggestion anyway because I wouldn't be surprised Blitz is being a little jerk!.

[edit] gave it a try, same problem.
Could this be a bug in the sound library of Blitz?

Last edited by Amiga1992; 24 February 2021 at 01:06.
Amiga1992 is offline  
Old 24 February 2021, 09:42   #7
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
Absolutely, it could definitely be a bug, or even something silly like an error in the Newtype definition in bb2objtypes... At some point when I have time I'll try it out and see if I can spot anything.
Daedalus is offline  
Old 24 February 2021, 19:55   #8
Amiga1992
Registered User
 
Join Date: May 2001
Location: ?
Posts: 19,645
Quote:
Originally Posted by Daedalus View Post
Absolutely, it could definitely be a bug, or even something silly like an error in the Newtype definition in bb2objtypes... At some point when I have time I'll try it out and see if I can spot anything.
If the wrong type is being used, maybe it is teh Period function that is buggy?

I installed the latest UBB, I thought the sound library was patched, but I still get that "Illegal Chanel" (sic) error on compiling on the specific line that sets the period (which doesn't even use channel mask to work)
Amiga1992 is offline  
Old 10 March 2021, 00:28   #9
Amiga1992
Registered User
 
Join Date: May 2001
Location: ?
Posts: 19,645
Quote:
Originally Posted by 8bitbubsy View Post
It sounds like you are somehow working with bytes instead of words here.
Welp I am pretty sure 8bitbubsy's assumption here is the problem, and the problem seems to be in Blitz itself.

At the very least, SetPeriod is bugged and uses the wrong data type to try to change the period.
If anybody got it to work, ever, please post here and share exactly how.

My solution was to make my own routine to change the period.
Amiga1992 is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
SetPeriod Sound Issues LuMan Coders. Blitz Basic 20 19 January 2021 15:32
Default display values chip support.WinUAE 6 06 January 2018 14:00
Finegrain_cpu_speed values hexaae support.WinUAE 2 14 August 2016 14:36
Discretizing / Normalizing Values in C/C++ Zetr0 Coders. General 4 04 December 2006 09:29

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 19:39.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.07668 seconds with 13 queries