This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
V497_Vesper's profile picture

How do I Change the Pitch of a Speaker?

Started by V497_Vesper, 30 May 2018 - 07:04 PM
V497_Vesper #1
Posted 30 May 2018 - 09:04 PM
Currently I am working on a project in Minecraft 1.7.10 using Nuclear Control, Project Red, Industrialcraft and Peripherals++,
I intend on building at least 11 Different structures Each with an individual Computerised Voice, I am also intending to design a Power level indicator similar to that of the Nuclear Control Program With Computer Controlled PA System you guys helped me get to work a few years ago but instead of the peripheral.wrap command being side specific I want it to be Flexible I.e the computer detects which side the peripheral is on how would I do this?
I also want to limit the block radius that it can be heard from
Edited on 30 May 2018 - 07:09 PM
Luca_S #2
Posted 30 May 2018 - 10:43 PM
This seems like several questions at once and I can't find the one from the title in your post so I would suggest you to read this(Especially "Posting a good question" and "Get Help faster") and then separate the questions more clearly.

To answer one part of your question: If you want to automatically find a specific peripheral the method peripheral.find might help you.
Afaik the speaker unfortunately isn't very well documented, but if you take a little peak into the source code of ComputerCraft here you will see that the playNote() functions takes the pitch of the speaker as the third argument.
Edited on 30 May 2018 - 08:43 PM
V497_Vesper #3
Posted 30 May 2018 - 10:49 PM
Acknowledged,
I will rephrase my Question; When Designing my program How do I get the Computer to find the peripheral?
Luca_S #4
Posted 30 May 2018 - 10:53 PM
Acknowledged,
I will rephrase my Question; When Designing my program How do I get the Computer to find the peripheral?

As I said above the method you are searching for is probably peripheral.find
V497_Vesper #5
Posted 30 May 2018 - 10:58 PM
Acknowledged,
I will rephrase my Question; When Designing my program How do I get the Computer to find the peripheral?

As I said above the method you are searching for is probably peripheral.find
I tried that and it didn't find the speaker, What i'd like to do is get the speaker to talk when the computer finds it after inputting a redstone signal
I guess I should also say this, I have no lua experience so I guess i have no idea where to start
Edited on 30 May 2018 - 09:01 PM
Luca_S #6
Posted 30 May 2018 - 11:05 PM
Arrrg sorry, just noticed that you aren't talking about the speaker that is implemented in CC in the newer versions, but the peripherals++ speaker.
The Peripherals++ Speaker seems to have documentation here so you can change the pitch and range with the 2nd and 3rd argument to the synthesize function.
Can you provide the exact code that you are using, either in a Code block or on pastebin please?
Edited on 30 May 2018 - 09:06 PM
V497_Vesper #7
Posted 30 May 2018 - 11:30 PM
Arrrg sorry, just noticed that you aren't talking about the speaker that is implemented in CC in the newer versions, but the peripherals++ speaker.
The Peripherals++ Speaker seems to have documentation here so you can change the pitch and range with the 2nd and 3rd argument to the synthesize function.

thanks but maybe you can help me if i explain my intentions more clearly;

What I intend to do is use Computercraft 1.7 Peripherals++ And Project red to design A Power Level indicator, A little machine that displays how much power is available in the building and when the power level reaches certain levels; more areas open up
What I am trying to get to work is this:

Precentages:
1, 000% (Emergency Power only, First Floor Open)
2, 010% (Floor 2 and Living quarters Open)
3, 020% (Floor 3 and Medical Bay Open)
4, 040% (Floor 4 and Mess Hall Open)
5, 055% (Floor 5 and Labs Open)
6, 070% (Floor 6 and Armory open)
7, 085% (Floors 7,8,9 Open and Lifts Operational)
8, 090% (Location Beacon Activated)
9, 100%( All floors and computers Open and activated)

What the speaker says at the precentages:
1, "Attention, Base offline Emergency Power Only"
2, "Power Level at 10%; Second Floor and Living Quarters Now Accessible."
3, "Power Level at 20%; Third Floor and Medical Bay Now Accessible"
4, "Power Level at 40%; Fourth Floor and Mess hall Now Accessible"
5, "Power Level at 50%; Fifth Floor and Research Labs Now Accessible"
6, "Power Level at 70%; Sixth Floor and Weapons Lab Now Accessible"
7, "Power Level at 85%; Seventh Floor Accessible and All Lifts Are now Active"
8, "Power Level at 90%; Location Beacon Activated, Transmitter Broadcasting on All Frequencies"
9, "Power Level at 100%; All Systems Active, Vault 104 Online!"

this will then send a redstone signal to another building and trigger a Light that is on A Massive "Control Panel" Lights representing all the Vaults; Each Vault has 2 lights representing it A red one and a Green one, the red one signifies that the Vault is offline and the Green light signifies that the vault is active, another fact is that when the power level reaches 90% it sends a redstone signal to a piston that Replaces a block underneath the Beacon that ativates said beacon so the vault can be found again

I'm trying to build a program that does all of this with a different Variations of the voice and to do that I need to figure out how the peripherals++ Speaker API works
Edited on 30 May 2018 - 09:34 PM
Bomb Bloke #8
Posted 31 May 2018 - 04:55 AM
Basic usage goes like this:

local mySpeaker = peripheral.find("speaker")  --# Wrap an attached speaker as "mySpeaker".

mySpeaker.speak("Hello world", 10, "English", true)  --# Talk to players within ten blocks with an English accent, halting execution until done.

You can use different "languages" to change the accent - there's no documented list that I'm aware of, though, so you'll just have to experiment. A few quick trails gets me some variation with "French", "Japanese", "German"…

If you specifically want to change the pitch of the voice, then you need to use "synthesize" instead of "speak". Catch is, in order to use the "pitch" parameter, you need to first supply the text, range, and voice, like so:

mySpeaker.synthesize("Hello world", 10, "someVoice", somePitchValue)

Again, valid voices don't seem to be documented - but I furthermore can't find any values the synth'll accept. Unless the voice parameter is left absent, and hence all the parameters after it, I can't get it to say anything!

It does sound like different accents through the speak function'll suit your purposes, though.