Jump to content
IGNORED

Music is glitchy


PuzZLeR

Recommended Posts

Greetings.

 

A little music help if I may.

 

I've put together this little tune, which I got looping. However, after a few loops it starts to sound glitchy.

 

I've tried with several PCs, with headphones, with 3 emulators, and it still does this. I have no clue why, and it only happens with this tune of mine.

 

Do you get this too on your systems? If so, do you know why this happens, or how to correct it?

 

Thanks!

 

(3 files attached: The sample tune source, ROM, and accompanying constants.bas file.)

sample.bas constants.bas sample.rom

Link to comment
Share on other sites

I only can say: interesting! After leaving it to play for around one minute in my Macbook Pro, it starts chirping, like an artifact in the jzintv audio generator.

 

Anyway in real hardware this glitch shouldn't happen (I'll test it out of curiosity as soon as possible). Maybe @intvnut can chime in for an explanation?

 

I've made a video, the effect happens at 58 secs. approximately.

 

 

Edited by nanochess
Link to comment
Share on other sites

1 hour ago, nanochess said:

I only can say: interesting! After leaving it to play for around one minute in my Macbook Pro, it starts chirping, like an artifact in the jzintv audio generator.

 

Anyway in real hardware this glitch shouldn't happen (I'll test it out of curiosity as soon as possible). Maybe @intvnut can chime in for an explanation?

 

I've made a video, the effect happens at 58 secs. approximately.

 

 

I've heard that before in some tracks.  I think it's two channels oscillating in phase.  I do not know why it happens only sometimes, except that we have already established some time ago that there is no direct way to reset the oscillator counters.  What I think is that in jzIntv, the initial state of the PSG counters is deterministic, so if they eventually go in phase, they will always do so at the same point.

 

Do you have more than one channel playing the same sequence of notes on the same instrument?

 

    -dZ.

Edited by DZ-Jay
Link to comment
Share on other sites

Wow. I opened a can of worms on this one, didn't I? Ha ha. It was only really a simple little jingle. Nothing more. I swear! ?

 

Yes it does feel like it hits some sort of threshold, and kind of stays there. I can't see anything suspicious in the source file notes I attached. There are no super high or low notes, and it looks very simple to me, and I used no instruments, only the default music notes. It also behaves like this in Nostalgia and Bliss too. I'm also curious how it fares on real hardware as I still await the next batch of LTO Flash cartridges.

 

Sorry to bust your heads on this. I do hope it is somehow is a rewarding challenge you crave.

 

(My_To_Do_List Update: Send Joe an email now that he's getting more LTO Flash. ?)

Link to comment
Share on other sites

People questioned my musical tastes over the years. (Yeah, into that "hard stuff" still.) But never knew it would violate an Inty sound chip, at least in emulation. (I liked this jingle because it sounds like a guitar solo. A bit.)

 

I know it's a hard problem, but I am still curious if this effect happens on real hardware. I don't think it unsafe, but if the experts say it's unsafe, then I'd rather it not tested if it's capable of busting a real AY.

 

Thanks again!

Link to comment
Share on other sites

2 minutes ago, PuzZLeR said:

People questioned my musical tastes over the years. (Yeah, into that "hard stuff" still.) But never knew it would violate an Inty sound chip, at least in emulation. (I liked this jingle because it sounds like a guitar solo. A bit.)

 

I know it's a hard problem, but I am still curious if this effect happens on real hardware. I don't think it unsafe, but if the experts say it's unsafe, then I'd rather it not tested if it's capable of busting a real AY.

 

Thanks again!

Well, I see that you are playing the same notes on two channels at a time, using the instrument (default), which suggests that the problem is that the oscillators go in opposite phase, cancelling each other out after a while.

 

(When I said before they were "in phase," I meant the effect typically called "phasing" or "flanging," which actually involves the waves being slightly out of phase, cancelling some harmonics.)

  • Like 1
Link to comment
Share on other sites

Hi DZ-Jay.

 

Do you think it would be unsafe on real hardware? I remember one of your posts somewhere that a stack overflow, although very dangerous to the program, will not affect hardware in any way. I'm thinking the same thing here, but still not sure. Just don't want anyone's Inty damaged by this. (Ha ha, but also serious.)

Link to comment
Share on other sites

On 1/20/2021 at 7:56 PM, PuzZLeR said:

Wow. I opened a can of worms on this one, didn't I? Ha ha. It was only really a simple little jingle. Nothing more. I swear! ?

 

Yes it does feel like it hits some sort of threshold, and kind of stays there. I can't see anything suspicious in the source file notes I attached. There are no super high or low notes, and it looks very simple to me, and I used no instruments, only the default music notes. It also behaves like this in Nostalgia and Bliss too. I'm also curious how it fares on real hardware as I still await the next batch of LTO Flash cartridges.

 

Sorry to bust your heads on this. I do hope it is somehow is a rewarding challenge you crave.

 

(My_To_Do_List Update: Send Joe an email now that he's getting more LTO Flash. ?)

If you want an LTO flash and you are in Toronto (so am I) send me a message, I'm handling Canadian sales for Joe and I have a few sitting in a box 10 feet away right now)

  • Thanks 1
Link to comment
Share on other sites

6 minutes ago, Steve Jones said:

If you want an LTO flash and you are in Toronto (so am I) send me a message, I'm handling Canadian sales for Joe and I have a few sitting in a box 10 feet away right now)

Hey, awesome! Yes I do!

 

I'm going to be busy this week during my free time (if any - you know how Toronto is, work, work, work, ha ha) trying to get an entry in for the contest, IF I can, but shortly after this I'll be sending you a message.

 

Thanks!

  • Like 1
Link to comment
Share on other sites

I doubt the AY chip would be harmed if two of the oscillators are in reverse phases, effectively cancelling the output. The question is how to avoid it, if changing the tone enable bit in register R7 will reset counters. While we can use SOUND 4,[NOISE 5 bits],[MIX] to set that register, I'm not sure what happens if one does that in the middle of the music player is operating, or if it does any difference.

Link to comment
Share on other sites

7 hours ago, PuzZLeR said:

Hi DZ-Jay.

 

Do you think it would be unsafe on real hardware? I remember one of your posts somewhere that a stack overflow, although very dangerous to the program, will not affect hardware in any way. I'm thinking the same thing here, but still not sure. Just don't want anyone's Inty damaged by this. (Ha ha, but also serious.)

Nah, it's not really something bad like that at all.  It's just a weird sound.  When two soundwaves synchronize their phases, they just tend to add to each other, but if they go slightly out of phase, they tend to cancel each other out.  It's just a weird sound effect, nothing more.

 

What I would recommend is just not making the same tune on two channels identical.  Not because it is bad or wrong, but because all it does is lead to that weird effect, which is probably not done on purpose.

 

Here's an excerpt from your code:

MUSIC F5,F5,A2#
MUSIC -,-,-
MUSIC C5#,C5#,-
MUSIC -,-,-
MUSIC -,-,A2#
MUSIC A4#,A4#,-
MUSIC -,-,-
MUSIC -,-,-
MUSIC F5,F5,A2#
MUSIC -,-,-
MUSIC C5#,C5#,-
MUSIC -,-,-
MUSIC -,-,A2#
MUSIC A4#,A4#,-
MUSIC -,-,-
MUSIC -,-,-
MUSIC F5,F5,A2#
MUSIC -,-,-
MUSIC C5#,C5#,-

 

Any particular reason why you have "F5#" and "C5#" and "A4#," etc., both playing on the first and second channel?

 

  -dZ.

Link to comment
Share on other sites

2 hours ago, carlsson said:

I doubt the AY chip would be harmed if two of the oscillators are in reverse phases, effectively cancelling the output. The question is how to avoid it, if changing the tone enable bit in register R7 will reset counters. While we can use SOUND 4,[NOISE 5 bits],[MIX] to set that register, I'm not sure what happens if one does that in the middle of the music player is operating, or if it does any difference.

I think the best way to "avoid it" is to just not play the same tune on two channels for such a long time without variation.  You could just either not do that, or change the instrument of one of them, or silence one of the channels occasionally.

 

I've noticed that doing the same thing in the Intellivision Music Tracker causes the waves to go out of phase a lot quicker.  That's probably because we are re-enabling the channel bits on every cycle, but in IntyBASIC, that's only done probably once.

 

Then again, I wonder if this is purely a jzIntv artefact.  I mean, it was just very recently that Joe Z. did some reverse engineering on the PSG to discover how the internal counters of the chip worked, and we learned once and for all that there appeared to be no deterministic way to reset the counters.

 

      -dZ.

Link to comment
Share on other sites

I would imagine one reason PuzZLeR uses two voices for the same tone is to accentuate those, making them sound louder but then again I haven't experimented if that really is the case, that volume on each channel are accumulated in the final output.

 

Again, this discussion reminds me about the VIC-I chip on the VIC-20 which generates similar artifacts. On that chip, the actual pulse width may change for each note played, and Viznut a number of years ago came up with a way to wait out the counters to deterministically be able to play notes at different pulse widths. Possibly the AY chip could be controlled in similar ways. Then again that chip is used on so many other systems that it should be common knowledge about counters and phases, unless the other systems use slightly fixed versions of the same chip.

Edited by carlsson
Link to comment
Share on other sites

1 hour ago, carlsson said:

I would imagine one reason PuzZLeR uses two voices for the same tone is to accentuate those, making them sound louder but then again I haven't experimented if that really is the case, that volume on each channel are accumulated in the final output.

 

I figured that.  However, in my experience, it's a crapshoot.  Like I said, in IntyBASIC, the emulator tends to put the oscillators in phase, causing them to go louder ... for a while at least; but I do not think you can control nor expect that in the real hardware, as we've find out empirically.

 

Quote

Again, this discussion reminds me about the VIC-I chip on the VIC-20 which generates similar artifacts. On that chip, the actual pulse width may change for each note played, and Viznut a number of years ago came up with a way to wait out the counters to deterministically be able to play notes at different pulse widths. Possibly the AY chip could be controlled in similar ways. Then again that chip is used on so many other systems that it should be common knowledge about counters and phases, unless the other systems use slightly fixed versions of the same chip.

That's the thing, we had the same theory for the PSG in the Intellivision (there were some discussions with Arnauld, Joe Z., Artrag, and a few others in the past; here and in the IntvPROG mailing list), but we couldn't find a way empirically to do so.  Then Joe Z. and a few others did a deep reverse-engineering analysis on the AY-3-8914, and discovered that there didn't seem to be a way to deterministically reset the counter.

 

The most you can do is put the counter down to its lowest level which causes it to alternate between 1 and 0.  But then, you can't really tell whether the oscillators will fall either in phase or out of phase, so still a crap shoot.  There may still be some way to figure that out, but as far as the experts have determined, there isn't one.

 

Here's the thread in the mailing list:

https://groups.io/g/intvprog/message/9239

 

Here's the consequential conclusion from Joe Z.:

Quote

They are free running.

 

Also, the reset condition for the count goes into a simple toggle flip-flop for the tone output. There's no way to reset that toggle to a known phase.

 

So, if you play the same tone on multiple channels, there's no way to fully control their relative phase on either version of the PSG. You do have more control over where toggles happen on the later design (greater-or-equal). You have zero control over whether it's outputting 0 or 1 on an active tone channel

 

The first sentence refers to the oscillators: they are free running, in that there is no mechanism for them to get synchronized or phased -- they are just there, counting on their own, and you just change the amount to which you divided them in order to produce output.

 

    -dZ.

Edited by DZ-Jay
  • Like 1
Link to comment
Share on other sites

Greetings folks.

 

Slow Me finally gets it. I was doing some "tweaking", trying different notes while keeping the old note on a different channel for reference till I delete it later, or "-" it. Yaddy, yah, yah, whatever. The point is that the way I edit or tweak notes leaves me with double notes on the same channel that I have to clean up later, and I simply forgot to do this in this case, which which caused the problem.

 

DOH!

 

Long story short: As pointed out before, it was having the same note on the multiple channels on the same line.

 

Problem solved my friends. You nailed it!

 

For the sake of completion, I upload the corrections. This time I avoid having the same note in double channels and the problem is solved. Same exact tune but NO issues this time. (Same constants.bas file as before.)

 

Thanks so much!

sample_fixed.bas sample_fixed.rom

Edited by PuzZLeR
Just a better explanation.
  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...