Jump to content
IGNORED

How to Interlace Voice Samples?


Just Jeff

Recommended Posts

Good Morning,

 

Does anyone know of a tool that will take two blocks of data and combine them in an interlaced manner?

 

I have some voice samples for a 2600 game I'm writing that will run faster if two samples are stored together- a byte from one, then a byte from the other, and so on like this:

image.png.ee258d6e247cff7808443bd8252ab799.png1st byte is from "Hey Taxi", 2nd is from "Thanks", 3rd is from "Hey Taxi", 4th from "Thanks", and so on.

Thanks!

 

Link to comment
Share on other sites

I personally use the Python 3 programming language. This way I can store data in a sane format and write a script that converts it into whatever format is most optimal for my needs. 

 

For example, all of my NPC dialogs are stored right here in a very simple, straightforward python structure, very easy to modify unless you want to use the letter J.

 

In my final output, the data for every message is split across 4 rom banks. Each character is converted into offset location of that character's left or right sprite sheets, where each sheet crams in 43 different 5 byte character sprites into 128 bytes using a "superstring" algorithm to pack them in.

  • Like 1
Link to comment
Share on other sites

Hmm I checked it all out..   I think you guys give me too much credit.  Do I need to know Python?

 

I did think of something on the way to work the other day..  Using my graphics spreadsheet formula and just re-arranging it a little bit, I can paste the samples in columns B and C, then concatenate in column A, then copy/paste column A into my code. I would have to break up line 2 manually here to add my labels.  Is what your suggesting easier?

 

image.png.c01927f5e5137d8c04c6294a90ea4d5f.png

 

Thanks!

-Jeff

 

  • Like 1
Link to comment
Share on other sites

This is all really a bet on what is going to save you time. Will you only have to do this once and never change the data? one time cut and paste from excel seems like you are already done - time to move on…

 

Do you need to repeat the process over and over? At that point you maybe want to write a script so you can separate the data from the code.

 

But using data to write code and vice versa is what it’s all about - how you do it is up to you… for me I adopted python a while back for this kind of thing because for me it was a pretty easy jump from the languages I already used (basically, a better Perl) but I wouldn’t blink if I saw someone using something else 

  • Like 2
Link to comment
Share on other sites

Hi there,

On 10/16/2023 at 10:10 AM, Dave C said:

Do you need to repeat the process over and over? At that point you maybe want to write a script so you can separate the data from the code.

 

But using data to write code and vice versa is what it’s all about - how you do it is up to you… for me I adopted python a while back for this kind of thing because for me it was a pretty easy jump from the languages I already used (basically, a better Perl) but I wouldn’t blink if I saw someone using something else 

I actually have been sitting on a reverse engineering of Millipede asking myself this question.

 

I could post it as is but the graphics data is interleaved and may make it harder for someone to change the graphics. I’ve been debating having another tool create the include files for the graphics from another easier read and manipulated input that may be more straightforward in changing the graphics. 

 

I like your Python approach. Maybe I post the reverse engineered code as-is for now and revisit this.

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

it isn't strictly necessary to know python. I just personally find that once you know a bit of python, can be a very powerful tool for mangling data into different forms. The interleaved data problem can be solved in a few lines like so:

 

#!/usr/bin/env python3

sample1 = [
    0b0001,
    0b0011,
    0b0101,
    0b1101,
]
    
sample2 = [
    0b0010,
    0b0100,
    0b0110,
    0b1000,
]
    
interleaved = zip(sample1, sample2)
    
for s1, s2 in interleaved:
    print(f'.byte %{s1:08b}, %{s2:08b}')
    
with open(f'interleave_samples.asm', 'w') as file:
    file.write('interleave_samples_label:')
    for s1, s2 in interleaved:
        file.write(f'.byte %{s1:08b}, %{s2:08b}')

 

  • Like 1
Link to comment
Share on other sites

  • 1 month later...
On 10/16/2023 at 8:53 AM, Just Jeff said:

Hmm I checked it all out..   I think you guys give me too much credit.  Do I need to know Python?

 

I did think of something on the way to work the other day..  Using my graphics spreadsheet formula and just re-arranging it a little bit, I can paste the samples in columns B and C, then concatenate in column A, then copy/paste column A into my code. I would have to break up line 2 manually here to add my labels.  Is what your suggesting easier?

 

image.png.c01927f5e5137d8c04c6294a90ea4d5f.png

 

Thanks!

-Jeff

 

That's how I usually do this kind of thing too. Good old spreadsheets.

  • 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...