English Amiga Board

English Amiga Board (https://eab.abime.net/index.php)
-   Coders. Blitz Basic (https://eab.abime.net/forumdisplay.php?f=126)
-   -   SetPeriod does not seem to like values I am inputting (https://eab.abime.net/showthread.php?t=105415)

Amiga1992 15 January 2021 23:36

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? :confused

Any ideas?

Amiga1992 18 January 2021 17:11

Nobody? :crying

[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


8bitbubsy 16 February 2021 12:28

Quote:

Originally Posted by Akira (Post 1454253)
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? :confused

Any ideas?

It sounds like you are somehow working with bytes instead of words here.

Amiga1992 23 February 2021 23:10

Quote:

Originally Posted by 8bitbubsy (Post 1462799)
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.

Daedalus 24 February 2021 00:05

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.

Amiga1992 24 February 2021 00:57

Quote:

Originally Posted by Daedalus (Post 1464761)
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?

Daedalus 24 February 2021 09:42

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.

Amiga1992 24 February 2021 19:55

Quote:

Originally Posted by Daedalus (Post 1464840)
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 10 March 2021 00:28

Quote:

Originally Posted by 8bitbubsy (Post 1462799)
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.


All times are GMT +2. The time now is 07:25.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.

Page generated in 0.04576 seconds with 11 queries