How to get or save the pitch listing in praat using scripting - scripting

I am trying to use scripting in praat to either save or write to a file with the values given from using "Pitch Listing" under "Pitch". This is my code for the script so far:
selectObject: 1
View & Edit
editor: 1
Select: 0.0, 10000
Pitch listing
p$ = Get pitch
fileappend pitch123.txt 'p$'
This code only returns the mean for the sound file and I am wondering if there is a way to avoid getting small chunks of the file and getting the average pitch and instead being able to get the data given the way praat does it like so :
Time_s F0_Hz
0.254558 125.982312
0.264558 127.975510
0.274558 123.010164
0.284558 120.761760
0.294558 119.652539
0.304558 118.916850
Even just being able to save the file that pops up from "Pitch Listing" would work. Any help is appreciated. Thanks!

Using the new syntax (Praat >= 5.3.63), you can create a Pitch object and loop through the frames to get the Pitch value for that frame (by default, one frame every 10 msec).
writeFileLine: "./pitch_list.txt", "time,pitch"
selectObject: 1
To Pitch: 0, 75, 600
no_of_frames = Get number of frames
for frame from 1 to no_of_frames
time = Get time from frame number: frame
pitch = Get value in frame: frame, "Hertz"
appendFileLine: "pitch_list.txt", "'time','pitch'"
endfor

Related

Halcon - Move XLD line

I have a Iconic variable BackWallBoundaryLineXLD
It containts 2 points and the line connecting them.
I would need to move this line upwards 40 pixels, so basically change the row coordinate of the line to Currentvalue-40.
Is there a simple and clean way to do it, or do I have to extract the points first, edit them and then draw a new line?
Try
hom_mat2d_identity (HomMat2DIdentity)
hom_mat2d_translate (HomMat2DIdentity, -40, 0, HomMat2DTranslate)
affine_trans_contour_xld (BackWallBoundaryLineXLD, BackWallBoundaryLineXLDTranslated, HomMat2DTranslate)
Try using affine_trans_contour_xld(). You will have to setup a HomMat3D first that specifies your 40pixel translation.

pine script with two indicators one overlaid on the chart and another on its own?

I am trying to write a pine script with two indicators one overlaid on the chart (EMA) and another on its own?(Stoch) I cannot seem to find any info on how to separate these (Visually) but keep them within 1 pine script, ie to be able to take trading decisions based on these.
The earlier answer from Luc is right, unfortunately. Each script can either create plots that are overlaid on the default price chart, or shown in a different pane, but not both. But there is a workaround.
Suppose you've made some non-trivial calculation in your script and you'd like to put it in different pane. E.g. the next code:
//#version=4
study(title="Stochastic", shorttitle="Stoch", format=format.price, precision=2)
periodK = input(14, title="K", minval=1)
periodD = input(3, title="D", minval=1)
smoothK = input(3, title="Smooth", minval=1)
k = sma(stoch(close, high, low, periodK), smoothK)
d = sma(k, periodD)
plot(k, title="%K", color=color.blue)
plot(d, title="%D", color=color.orange)
h0 = hline(80)
h1 = hline(20)
fill(h0, h1, color=color.purple, transp=75)
// This next plot would work best in a separate pane
someNonTrivialCalculatedSeries = close
plot(ema(someNonTrivialCalculatedSeries, 25), title="Exporting Plot")
Because they have different scale, one of them most likely will break another indicator's scale.
So you'd like show Stoch in different pine, whereas ema() should be overlayed with the main chart. For that you should make the next steps:
Turn off in the study's the extra plot to return scale to normal:
Apply to the chart the next script:
//#version=4
study("NonOverlayIndicator", overlay=true)
src = input(defval=close, type=input.source)
plot(src)
Choose in the second's script inputs source required plot from the first script:
And voilà - you got the plots in different pines:
But if you want split the plots because you have retrictions on amount of studies you allowed to apply (e.g. 3 for free-account) - that won't help you.
It cannot be done. A script runs either in overlay=true mode on the chart, in which case it cannot direct plots elsewhere, or in a separate pane when overlay=false (the default).
When the script is running in a pane, it can change the color of the chart bars using barcolor(), but that's the only way it can modify the chart.
It is possible to rescale signals so that multiple bounded (e.g., 0-100, -1 to +1) signals generated by one script appear one on top of the other, but this is typically impossible in overlay mode, as the vertical scale varies with the bars on the chart. The only way for an overlay script to work with its own scale is when it uses No scale, but this prevents the indicator's plots to plot relative to price, and so the chart's bars.
Nice workaround from Michael.
Unfortunately, this only seems to work to pass data for one plot.
I would like to pass data for 3 different plots to the stock price graph.
If I try this, for 'input.source' I can only select the standard sources: "open, high, low, close ...". I can not select the data from other indicators.
If I remove plots 2 and 3, it works as Michael described.
Anybody has a workaround for the workaround..? ;-)

How do I display the output of a function of multiple qualtrics sliders in real time?

My colleague and I am designing a survey using Qualtrics. On one page respondents must move a series of sliders.
We need to display the output of a function of the values of the sliders on the same page, ideally also in the form of another slider.
All of this must be done while the respondent moves the sliders.
Concretely, suppose the following:
value of slider 1 = 30;
value of slider 2 = 10;
value of slider 3 = 0
Output to be displayed = 30 x 20 + 10 x 5 + 0 x 15 = 650
where the 20, 5 and 15 are just arbitrary constants in the background.
If the user were to move slider 1 to 31, the displayed output should automatically update in real time to 670.
Any tip on how this is done? We're newbies to qualtrics and completely inexperienced with Java, so we'd be very grateful to anyone willing to provide us with working code. Thanks!
An update on my question, and a clarification after a comment received.
We were of course not asking for someone else to do our job. Just for a pointer in the right direction.
Based on an answer to a different question, I've managed to put this javascript together. It works, which is encouraging..
Code follows.
Qualtrics.SurveyEngine.addOnReady(function()
{
/*Place your JavaScript here to run when the page is fully displayed*/
var that=this.questionId;
jQuery("<p style='width:100%'><br><strong> Output <span id='OUT'>0</span></strong>").insertAfter("table.sliderGrid");
jQuery(document).on('change', function(){
var firstslider=parseInt(jQuery("[id='"+that+"~1~result']").val());
var secondslider=parseInt(jQuery("[id='"+that+"~2~result']").val());
var N=firstlider+secondslider*2;
jQuery("#OUT").text(N);
});

Updating Progress Bar Value While Uploading the Image

I want to update both the label and progress bar like
Progress Label :if i uploading 5 image means 0/5 ->after one image uploaded the label should be updated as 1/5 like this ans so on at lst 5/5
i did this correctly using this code
self.progressLabel.text = [NSString stringWithFormat:#"%d/%lu",self.currentIndex,(unsigned long)self.arrayWithImages.count];
this will be used after successfully uploaded the image one by one .
Now i want to update the progress bar it is not updating correctly
i have did like this
int count = self.currentIndex++;
self.progressView.progress =count/self.arrayWithImages.count;
i am updating the current index value after successfull image uploads one by one .
Please help me to do this .
What type of object is progressView?
NSProgressIndicator does not have a progress property, it has doubleValue, which takes a value from 0-100
So you could try:
self.progressView.progress = (count/self.arrayWithImages.count)*100;
Just make sure that count is always less than or equal to self.arrayWithImages.count

DimpleJS overrideMax, Dates and series drawing order

I have this interactive chart here. As its data change depending on selected time period I wish to set the date range from Nov-10 to Jul-14, no matter the data. I know that I must use overrideMax on x axis, but I can't make it to work. I guess it's a matter of date formatting. Every single combination I've tried gives the following as result.
What is the right formatting? Thanks a lot.
EDIT: Thank you very much on your quick response, John. Now it is working. I'm loving Dimple more and more!
I have another question regarding this chart. Is there any way to arrange drawing order of series? I would like 'Previsión' to be sent to back. Now it is drawn depending on time period.
EDIT 2: Based on this other question I think I figured out a solution. With a 50ms delay after the chart is drawn I simple erase the circles and paths I wish to be at the front and then append them to the chart svg object.
setTimeout(function () {
var datoCircles = svg.selectAll('circle[id*=Dato]:not([id*=futuro])');
var prevCircles = svg.selectAll('circle[id*=Prev]');
var prevPaths = svg.selectAll('path[class*=Prev]');
datoCircles.remove();
prevCircles.remove();
prevPaths.remove();
// Convertimos la seleción d3 a objetos jQuery
$(svg.selectAll('svg > g')[0])
.append($(prevPaths[0]))
.append($(prevCircles[0]))
.append($(datoCircles[0]));
}, 50);
They need to be set with JavaScript date objects, as native date parsing in JavaScript causes cross browser problems, I recommend using the d3 method:
x.overrideMax = d3.time.format("%Y-%m-%d").parse("2014-05-09");
With this approach you can use whichever date format suits you.